📄 song_task.lst
字号:
474 5 case KEY_DEC:
475 5 song_snd_dec(); /* decrement selected control */
476 5 print_sound_level(); /* display new level */
477 5 break;
478 5
479 5 case KEY_SOUND:
480 5 song_snd_select(); /* select next sound control */
481 5 print_sound(); /* display selected sound icon */
482 5 print_sound_level(); /* display new level */
483 5 break;
484 5
485 5 case KEY_REPEAT:
486 5 song_loop = ~song_loop; /* display repeat or not */
487 5 print_repeat(song_loop);
C51 COMPILER V7.02a SONG_TASK 09/13/2007 11:53:04 PAGE 9
488 5 break;
489 5
490 5 case KEY_STOP:
491 5 song_stop(); /* stop playing song */
492 5 Fclose();
493 5 song_state = SONG_STOP;
494 5 break;
495 5
496 5 default:
497 5 break;
498 5 }
499 4 gl_key_press = FALSE; /* ack key usage */
500 4 }
501 3 break;
502 3 }
503 2
504 2
505 2 case SONG_NEW:
506 2 {
507 3 #if PLAYER_PLAY_MODE == PLAY_DISK
508 3 if (File_type() == FILE_DIR)
509 3 {
510 4 if (file_entry_dir(FILE_MP3 | FILE_DIR) == OK)
511 4 { /* mp3 or dir in sub-dir */
512 5 song_state = SONG_NEW; /* stay in same state */
513 5 }
514 4 else
515 4 { /* no mp3 or dir in sub-dir */
516 5 song_state = SONG_NEXT; /* select next */
517 5 }
518 4 }
519 3 else
520 3 { /* file is MP3 */
521 4 song_state = SONG_INIT; /* new song */
522 4 print_repeat(song_loop);
523 4 print_file_name(); /* display file name */
524 4 }
525 3 break;
526 3 #else /* PLAYER_MODE == PLAY_DIR */
song_state = SONG_INIT; /* new song */
print_repeat(song_loop);
print_file_name(); /* display file name */
break;
#endif
532 3 }
533 2
534 2 case SONG_NEXT:
535 2 {
536 3 disp_name_stop(); /* stop scrolling */
537 3 #if PLAYER_PLAY_MODE == PLAY_DISK
538 3 if (file_seek_next(FILE_MP3 | FILE_DIR, FALSE))/* next song or dir */
539 3 { /* mp3 or dir selected */
540 4 song_state = SONG_NEW;
541 4 }
542 3 else
543 3 { /* at end of dir */
544 4 if (File_goto_parent(FILE_MP3 | FILE_DIR) == OK)
545 4 { /* parent exists, point on dir */
546 5 song_state = SONG_NEXT; /* next will select next file */
547 5 }
548 4 else
549 4 { /* no parent: end of root dir */
C51 COMPILER V7.02a SONG_TASK 09/13/2007 11:53:04 PAGE 10
550 5 if (loop)
551 5 {
552 6 song_state = SONG_NEW;
553 6 }
554 5 else
555 5 {
556 6 song_stop();
557 6 song_state = SONG_STOP;
558 6 }
559 5 }
560 4 }
561 3 break;
562 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;
}
break;
#endif
574 3 }
575 2
576 2 case SONG_PREV:
577 2 {
578 3 disp_name_stop(); /* stop scrolling */
579 3 #if PLAYER_PLAY_MODE == PLAY_DISK
580 3 while( song_state == SONG_PREV )
581 3 { /* prev song or dir */
582 4 if( !file_seek_prev(FILE_MP3 | FILE_DIR, FALSE))
583 4 { /* No mp3 or dir selected, at beginning of dir */
584 5 if (File_goto_parent(FILE_MP3 | FILE_DIR) != OK)
585 5 { /* no parent: beginning of root dir */
586 6 if (loop)
587 6 {
588 7 if(File_goto_last() != OK) /* goto to the end of dir */
589 7 { /* error system */
590 8 song_stop();
591 8 song_state = SONG_STOP;
592 8 }
593 7 }
594 6 else
595 6 { /* end of dir: stop */
596 7 song_stop();
597 7 song_state = SONG_STOP;
598 7 }
599 6 }
600 5 else
601 5 {
602 6 continue; /* goto to previous file in dir parent */
603 6 }
604 5 }
605 4
606 4 while (File_type() == FILE_DIR)
607 4 { /* file found is directory -> enter directory and goto last file */
608 5 if (file_entry_dir(FILE_MP3 | FILE_DIR) == OK)
609 5 { /* mp3 or dir in sub-dir */
610 6 if(File_goto_last() != OK) /* goto to the end of dir */
611 6 { /* error system */
C51 COMPILER V7.02a SONG_TASK 09/13/2007 11:53:04 PAGE 11
612 7 song_stop();
613 7 song_state = SONG_STOP;
614 7 }
615 6 }
616 5 else
617 5 {
618 6 break; /* directory empty goto search previous file */
619 6 }
620 5 }
621 4
622 4 if (File_type() == FILE_MP3)
623 4 { /* mp3 file -> stop research previous file */
624 5 song_state = SONG_NEW;
625 5 }
626 4 /* HERE song_state == SONG_PREV, if select file is empty directory or not mp3 file */
627 4 }
628 3 break;
629 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;
}
else
{ /* beginning of dir: stop */
song_stop();
song_state = SONG_STOP;
}
break;
#endif
641 3 }
642 2
643 2
644 2 case SONG_STOP:
645 2 {
646 3 disp_end_of_play(); /* end of music... */
647 3 disp_clock_reset(); /* reset clock timer */
648 3 print_file_name(); /* display file name */
649 3 song_state = SONG_IDLE;
650 3 break;
651 3 }
652 2
653 2
654 2 case SONG_NO_SONG:
655 2 {
656 3 if (gl_key_press) /* a key is pressed? */
657 3 {
658 4 switch (gl_key)
659 4 {
660 5 case KEY_MEM:
661 5 mem_select_next(); /* select next memory */
662 5 song_state = SONG_START;
663 5 break;
664 5
665 5 case KEY_MODE:
666 5 mode_set_init(); /* exit from song task */
667 5 song_state = SONG_START;
668 5 break;
669 5 }
670 4 gl_key_press = FALSE; /* ack key usage */
671 4 }
672 3 else
673 3 { /* check card presence */
C51 COMPILER V7.02a SONG_TASK 09/13/2007 11:53:04 PAGE 12
674 4 if (mem_check_card() == KO)
675 4 {
676 5 mem_select_next();
677 5 song_state = SONG_START; /* card has been unplugged */
678 5 }
679 4 }
680 3 break;
681 3 }
682 2
683 2
684 2 case SONG_ERROR:
685 2 {
686 3 song_stop(); /* stop playing song */
687 3 Fclose(); /* close opened file */
688 3 disp_clock_reset(); /* reset clock timer */
689 3 print_state_error(); /* display error icon */
690 3 disp_name_stop();
691 3 song_state = SONG_IDLE;
692 3 break;
693 3 }
694 2 }
695 1 }
696
697
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1003 ----
CONSTANT SIZE = 34 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 1 1
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 + -