📄 song_task.lst
字号:
298 5 print_state_pause(); /* display pause icon */
299 5 song_state = SONG_PAUSE;
300 5 break;
301 5
302 5 case KEY_NEXT:
C51 COMPILER V7.50 SONG_TASK 06/03/2006 10:32:53 PAGE 6
303 5 song_pause(); /* pause playing song */
304 5 disp_clock_stop(); /* suspend clock timer */
305 5 Fclose();
306 5 loop = TRUE; /* keypad action so loop */
307 5 song_state = SONG_NEXT;
308 5 break;
309 5
310 5 case KEY_PREV:
311 5 song_pause(); /* pause playing song */
312 5 disp_clock_stop(); /* suspend clock timer */
313 5 Fclose();
314 5 loop = TRUE;
315 5 song_state = SONG_PREV;
316 5 break;
317 5
318 5 case KEY_INC:
319 5 song_snd_inc(); /* increment selected control */
320 5 print_sound_level(); /* display new level */
321 5 break;
322 5
323 5 case KEY_DEC:
324 5 song_snd_dec(); /* decrement selected control */
325 5 print_sound_level(); /* display new level */
326 5 break;
327 5
328 5 // case KEY_SOUND:
329 5 // song_snd_select(); /* select next sound control */
330 5 // print_sound(); /* display selected sound icon */
331 5 // print_sound_level(); /* display new level */
332 5 // break;
333 5
334 5 case KEY_REPEAT:
335 5 song_loop = ~song_loop; /* display repeat or not */
336 5 print_repeat(song_loop);
337 5 break;
338 5
339 5 case KEY_STOP:
340 5 song_stop(); /* stop playing song */
341 5 Fclose();
342 5 song_state = SONG_STOP;
343 5 break;
344 5
345 5 default:
346 5 break;
347 5 }
348 4 gl_key_press = FALSE; /* ack key usage */
349 4 }
350 3 break;
351 3 }
352 2
353 2
354 2 case SONG_PAUSE: /* one file openned */
355 2 {
356 3 if (gl_key_press) /* a key is pressed? */
357 3 {
358 4 switch (gl_key)
359 4 {
360 5 case KEY_PLAY:
361 5 disp_clock_start(); /* restart clock timer */
362 5 Aud_song_play(); /* restart sample request */
363 5 print_state_play(); /* display play icon */
364 5 song_state = SONG_PLAY;
C51 COMPILER V7.50 SONG_TASK 06/03/2006 10:32:53 PAGE 7
365 5 break;
366 5
367 5 case KEY_NEXT:
368 5 song_pause(); /* pause playing song */
369 5 Fclose();
370 5 loop = TRUE; /* keypad action so loop */
371 5 song_state = SONG_NEXT;
372 5 break;
373 5
374 5 case KEY_PREV:
375 5 song_pause(); /* pause playing song */
376 5 Fclose();
377 5 loop = TRUE; /* keypad action so loop */
378 5 song_state = SONG_PREV;
379 5 break;
380 5
381 5 case KEY_INC:
382 5 song_snd_inc(); /* increment selected control */
383 5 print_sound_level(); /* display new level */
384 5 break;
385 5
386 5 case KEY_DEC:
387 5 song_snd_dec(); /* decrement selected control */
388 5 print_sound_level(); /* display new level */
389 5 break;
390 5
391 5 // case KEY_SOUND:
392 5 // song_snd_select(); /* select next sound control */
393 5 // print_sound(); /* display selected sound icon */
394 5 // print_sound_level(); /* display new level */
395 5 // break;
396 5
397 5 case KEY_REPEAT:
398 5 song_loop = ~song_loop; /* display repeat or not */
399 5 print_repeat(song_loop);
400 5 break;
401 5
402 5 case KEY_STOP:
403 5 song_stop(); /* stop playing song */
404 5 Fclose();
405 5 song_state = SONG_STOP;
406 5 break;
407 5
408 5 default:
409 5 break;
410 5 }
411 4 gl_key_press = FALSE; /* ack key usage */
412 4 }
413 3 break;
414 3 }
415 2
416 2
417 2 case SONG_NEW:
418 2 {
419 3 #if PLAYER_PLAY_MODE == PLAY_DISK
420 3 if (File_type() == FILE_DIR)
421 3 {
422 4 if (file_entry_dir(FILE_MP3 | FILE_DIR) == OK)
423 4 { /* mp3 or dir in sub-dir */
424 5 song_state = SONG_NEW; /* stay in same state */
425 5 }
426 4 else
C51 COMPILER V7.50 SONG_TASK 06/03/2006 10:32:53 PAGE 8
427 4 { /* no mp3 or dir in sub-dir */
428 5 song_state = SONG_NEXT; /* select next */
429 5 }
430 4 }
431 3 else
432 3 { /* file is MP3 */
433 4 song_state = SONG_INIT; /* new song */
434 4 // print_repeat(song_loop);
435 4 Mp3_set_right_vol(0);
436 4 Mp3_set_left_vol(0);
437 4 print_file_name(); /* display file name */
438 4 }
439 3 break;
440 3 #else /* PLAYER_MODE == PLAY_DIR */
song_state = SONG_INIT; /* new song */
print_repeat(song_loop);
Mp3_set_right_vol(0);
Mp3_set_left_vol(0);
print_file_name(); /* display file name */
break;
#endif
448 3 }
449 2
450 2 case SONG_NEXT:
451 2 {
452 3 // printch(0x90,"下首 ");
453 3 //disp_name_stop(); /* stop scrolling */
454 3 #if PLAYER_PLAY_MODE == PLAY_DISK
455 3 if (file_seek_next(FILE_MP3 | FILE_DIR, FALSE))/* next song or dir */
456 3 { /* mp3 or dir selected */
457 4 song_state = SONG_NEW;
458 4 }
459 3 else
460 3 { /* at end of dir */
461 4 if (File_goto_parent(FILE_MP3 | FILE_DIR) == OK)
462 4 { /* parent exists, point on dir */
463 5 song_state = SONG_NEXT; /* next will select next file */
464 5 }
465 4 else
466 4 { /* no parent: end of root dir */
467 5 if (loop)
468 5 {
469 6 song_state = SONG_NEW;
470 6 }
471 5 else
472 5 {
473 6 song_stop();
474 6 song_state = SONG_STOP;
475 6 }
476 5 }
477 4 }
478 3 break;
479 3 #else /* PLAYER_MODE == PLAY_DIR */
if (file_seek_next(FILE_MP3, loop)) /* select next song */
{ /* still some file to play */
song_state = SONG_NEW;
}
else
{ /* end of dir: stop */
song_stop();
song_state = SONG_STOP;
}
C51 COMPILER V7.50 SONG_TASK 06/03/2006 10:32:53 PAGE 9
break;
#endif
491 3 }
492 2
493 2 case SONG_PREV:
494 2 {
495 3 // printch(0x90,"前首 ");
496 3 disp_name_stop(); /* stop scrolling */
497 3 #if PLAYER_PLAY_MODE == PLAY_DISK
498 3 while( song_state == SONG_PREV )
499 3 { /* prev song or dir */
500 4 if( !file_seek_prev(FILE_MP3 | FILE_DIR, FALSE))
501 4 { /* No mp3 or dir selected, at beginning of dir */
502 5 if (File_goto_parent(FILE_MP3 | FILE_DIR) != OK)
503 5 { /* no parent: beginning of root dir */
504 6 if (loop)
505 6 {
506 7 if(File_goto_last() != OK) /* goto to the end of dir */
507 7 { /* error system */
508 8 song_stop();
509 8 song_state = SONG_STOP;
510 8 }
511 7 }
512 6 else
513 6 { /* end of dir: stop */
514 7 song_stop();
515 7 song_state = SONG_STOP;
516 7 }
517 6 }
518 5 else
519 5 {
520 6 continue; /* goto to previous file in dir parent */
521 6 }
522 5 }
523 4
524 4 while (File_type() == FILE_DIR)
525 4 { /* file found is directory -> enter directory and goto last file */
526 5 if (file_entry_dir(FILE_MP3 | FILE_DIR) == OK)
527 5 { /* mp3 or dir in sub-dir */
528 6 if(File_goto_last() != OK) /* goto to the end of dir */
529 6 { /* error system */
530 7 song_stop();
531 7 song_state = SONG_STOP;
532 7 }
533 6 }
534 5 else
535 5 {
536 6 break; /* directory empty goto search previous file */
537 6 }
538 5 }
539 4
540 4 if (File_type() == FILE_MP3)
541 4 { /* mp3 file -> stop research previous file */
542 5 song_state = SONG_NEW;
543 5 }
544 4 /* HERE song_state == SONG_PREV, if select file is empty directory or not mp3 file */
545 4 }
546 3 break;
547 3 #else /* PLAYER_MODE == PLAY_DIR */
if (file_seek_prev(FILE_MP3, loop)) /* select prev song */
{ /* still some file to play */
song_state = SONG_NEW;
C51 COMPILER V7.50 SONG_TASK 06/03/2006 10:32:53 PAGE 10
}
else
{ /* beginning of dir: stop */
song_stop();
song_state = SONG_STOP;
}
break;
#endif
559 3 }
560 2
561 2
562 2 case SONG_STOP:
563 2 {
564 3 printch(0x90,"停止 ");
565 3 disp_end_of_play(); /* end of music... */
566 3 disp_clock_reset(); /* reset clock timer */
567 3 print_file_name(); /* display file name */
568 3 song_state = SONG_IDLE;
569 3 break;
570 3 }
571 2
572 2
573 2 case SONG_ERROR:
574 2 {
575 3 song_stop(); /* stop playing song */
576 3 Fclose(); /* close opened file */
577 3 disp_clock_reset(); /* reset clock timer */
578 3 print_state_error(); /* display error icon */
579 3 disp_name_stop();
580 3 song_state = SONG_IDLE;
581 3 break;
582 3 }
583 2 }
584 1 }
585
586
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 840 ----
CONSTANT SIZE = 21 ----
XDATA SIZE = 1 ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = 1 1
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -