diff options
Diffstat (limited to 'apps/wps.c')
-rw-r--r-- | apps/wps.c | 157 |
1 files changed, 145 insertions, 12 deletions
diff --git a/apps/wps.c b/apps/wps.c index d10eb92655..cc826cab00 100644 --- a/apps/wps.c +++ b/apps/wps.c | |||
@@ -45,7 +45,7 @@ | |||
45 | /* 3% of 30min file == 54s step size */ | 45 | /* 3% of 30min file == 54s step size */ |
46 | 46 | ||
47 | #ifdef HAVE_RECORDER_KEYPAD | 47 | #ifdef HAVE_RECORDER_KEYPAD |
48 | #define RELEASE_MASK (BUTTON_F1 | BUTTON_F2 | BUTTON_F3 | BUTTON_DOWN | BUTTON_LEFT | BUTTON_RIGHT | BUTTON_UP) | 48 | #define RELEASE_MASK (BUTTON_F1 | BUTTON_F2 | BUTTON_F3 | BUTTON_DOWN | BUTTON_LEFT | BUTTON_RIGHT | BUTTON_UP | BUTTON_ON | BUTTON_PLAY ) |
49 | #else | 49 | #else |
50 | #define RELEASE_MASK (BUTTON_MENU | BUTTON_STOP | BUTTON_LEFT | BUTTON_RIGHT | BUTTON_PLAY) | 50 | #define RELEASE_MASK (BUTTON_MENU | BUTTON_STOP | BUTTON_LEFT | BUTTON_RIGHT | BUTTON_PLAY) |
51 | #endif | 51 | #endif |
@@ -624,6 +624,120 @@ static bool menu(void) | |||
624 | } | 624 | } |
625 | 625 | ||
626 | #ifdef HAVE_LCD_BITMAP | 626 | #ifdef HAVE_LCD_BITMAP |
627 | /* returns: | ||
628 | 0 if no key was pressed | ||
629 | 1 if a key was pressed (or if ON was held down long enough to repeat) | ||
630 | 2 if USB was connected */ | ||
631 | int on_screen(void) | ||
632 | { | ||
633 | static int pitch = 100; | ||
634 | bool exit = false; | ||
635 | bool used = false; | ||
636 | #ifdef SIMULATOR | ||
637 | bool draw = true; | ||
638 | #else | ||
639 | bool draw = false; | ||
640 | #endif | ||
641 | |||
642 | while (!exit) { | ||
643 | |||
644 | if ( draw ) { | ||
645 | char* ptr; | ||
646 | char buf[32]; | ||
647 | int w, h; | ||
648 | |||
649 | lcd_scroll_pause(); | ||
650 | lcd_clear_display(); | ||
651 | |||
652 | ptr = "Pitch up"; | ||
653 | lcd_getstringsize(ptr,FONT_UI,&w,&h); | ||
654 | lcd_putsxy((LCD_WIDTH-w)/2, 0, ptr, FONT_UI); | ||
655 | lcd_bitmap(bitmap_icons_7x8[Icon_UpArrow], | ||
656 | LCD_WIDTH/2 - 3, h*2, 7, 8, true); | ||
657 | |||
658 | snprintf(buf, sizeof buf, "%d%%", pitch); | ||
659 | lcd_getstringsize(buf,FONT_UI,&w,&h); | ||
660 | lcd_putsxy((LCD_WIDTH-w)/2, h, buf, FONT_UI); | ||
661 | |||
662 | ptr = "Pitch down"; | ||
663 | lcd_getstringsize(ptr,FONT_UI,&w,&h); | ||
664 | lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr, FONT_UI); | ||
665 | lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow], | ||
666 | LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true); | ||
667 | |||
668 | ptr = "Pause"; | ||
669 | lcd_getstringsize(ptr,FONT_UI,&w,&h); | ||
670 | lcd_putsxy((LCD_WIDTH-(w/2))/2, LCD_HEIGHT/2 - h/2, ptr, FONT_UI); | ||
671 | lcd_bitmap(bitmap_icons_7x8[Icon_Pause], | ||
672 | (LCD_WIDTH-(w/2))/2-10, LCD_HEIGHT/2 - h/2, 7, 8, true); | ||
673 | |||
674 | lcd_update(); | ||
675 | } | ||
676 | |||
677 | /* use lastbutton, so the main loop can decide whether to | ||
678 | exit to browser or not */ | ||
679 | switch (button_get(true)) { | ||
680 | case BUTTON_UP: | ||
681 | case BUTTON_ON | BUTTON_UP: | ||
682 | case BUTTON_ON | BUTTON_UP | BUTTON_REPEAT: | ||
683 | used = true; | ||
684 | pitch++; | ||
685 | if ( pitch > 200 ) | ||
686 | pitch = 200; | ||
687 | #ifdef HAVE_MAS3587F | ||
688 | mpeg_set_pitch(pitch); | ||
689 | #endif | ||
690 | break; | ||
691 | |||
692 | case BUTTON_DOWN: | ||
693 | case BUTTON_ON | BUTTON_DOWN: | ||
694 | case BUTTON_ON | BUTTON_DOWN | BUTTON_REPEAT: | ||
695 | used = true; | ||
696 | pitch--; | ||
697 | if ( pitch < 50 ) | ||
698 | pitch = 50; | ||
699 | #ifdef HAVE_MAS3587F | ||
700 | mpeg_set_pitch(pitch); | ||
701 | #endif | ||
702 | break; | ||
703 | |||
704 | case BUTTON_ON | BUTTON_PLAY: | ||
705 | mpeg_pause(); | ||
706 | used = true; | ||
707 | break; | ||
708 | |||
709 | case BUTTON_PLAY | BUTTON_REL: | ||
710 | mpeg_resume(); | ||
711 | used = true; | ||
712 | break; | ||
713 | |||
714 | #ifdef SIMULATOR | ||
715 | case BUTTON_ON: | ||
716 | #else | ||
717 | case BUTTON_ON | BUTTON_REL: | ||
718 | #endif | ||
719 | exit = true; | ||
720 | break; | ||
721 | |||
722 | case BUTTON_ON | BUTTON_REPEAT: | ||
723 | draw = true; | ||
724 | used = true; | ||
725 | break; | ||
726 | |||
727 | #ifndef SIMULATOR | ||
728 | case SYS_USB_CONNECTED: | ||
729 | handle_usb(); | ||
730 | return 2; | ||
731 | #endif | ||
732 | } | ||
733 | } | ||
734 | |||
735 | if ( used ) | ||
736 | return 1; | ||
737 | else | ||
738 | return 0; | ||
739 | } | ||
740 | |||
627 | bool f2_screen(void) | 741 | bool f2_screen(void) |
628 | { | 742 | { |
629 | bool exit = false; | 743 | bool exit = false; |
@@ -764,12 +878,14 @@ bool f3_screen(void) | |||
764 | int wps_show(void) | 878 | int wps_show(void) |
765 | { | 879 | { |
766 | int button, lastbutton = 0; | 880 | int button, lastbutton = 0; |
881 | int old_repeat_mask; | ||
767 | bool ignore_keyup = true; | 882 | bool ignore_keyup = true; |
768 | bool restore = false; | 883 | bool restore = false; |
769 | 884 | ||
770 | id3 = NULL; | 885 | id3 = NULL; |
771 | 886 | ||
772 | old_release_mask = button_set_release(RELEASE_MASK); | 887 | old_release_mask = button_set_release(RELEASE_MASK); |
888 | old_repeat_mask = button_set_repeat(~0); | ||
773 | 889 | ||
774 | #ifdef HAVE_LCD_CHARCELLS | 890 | #ifdef HAVE_LCD_CHARCELLS |
775 | lcd_icon(ICON_AUDIO, true); | 891 | lcd_icon(ICON_AUDIO, true); |
@@ -807,19 +923,36 @@ int wps_show(void) | |||
807 | 923 | ||
808 | switch(button) | 924 | switch(button) |
809 | { | 925 | { |
810 | /* exit to dir browser */ | ||
811 | case BUTTON_ON: | 926 | case BUTTON_ON: |
812 | #ifdef HAVE_LCD_CHARCELLS | 927 | #ifdef HAVE_RECORDER_KEYPAD |
813 | lcd_icon(ICON_RECORD, false); | 928 | switch (on_screen()) { |
814 | lcd_icon(ICON_AUDIO, false); | 929 | case 2: |
930 | /* usb connected? */ | ||
931 | return SYS_USB_CONNECTED; | ||
932 | |||
933 | case 1: | ||
934 | /* was on_screen used? */ | ||
935 | restore = true; | ||
936 | break; | ||
937 | |||
938 | case 0: | ||
939 | /* otherwise, exit to browser */ | ||
940 | #else | ||
941 | lcd_icon(ICON_RECORD, false); | ||
942 | lcd_icon(ICON_AUDIO, false); | ||
943 | #endif | ||
944 | /* set dir browser to current playing song */ | ||
945 | if (global_settings.browse_current && id3) | ||
946 | set_current_file(id3->path); | ||
947 | |||
948 | button_set_release(old_release_mask); | ||
949 | button_set_repeat(old_repeat_mask); | ||
950 | return 0; | ||
951 | #ifdef HAVE_RECORDER_KEYPAD | ||
952 | } | ||
953 | break; | ||
815 | #endif | 954 | #endif |
816 | /* set dir browser to current playing song */ | ||
817 | if (global_settings.browse_current && id3) | ||
818 | set_current_file(id3->path); | ||
819 | 955 | ||
820 | button_set_release(old_release_mask); | ||
821 | return 0; | ||
822 | |||
823 | /* play/pause */ | 956 | /* play/pause */ |
824 | case BUTTON_PLAY: | 957 | case BUTTON_PLAY: |
825 | if ( paused ) | 958 | if ( paused ) |
@@ -937,7 +1070,7 @@ int wps_show(void) | |||
937 | #else | 1070 | #else |
938 | case BUTTON_STOP | BUTTON_REL: | 1071 | case BUTTON_STOP | BUTTON_REL: |
939 | if ( lastbutton != BUTTON_STOP ) | 1072 | if ( lastbutton != BUTTON_STOP ) |
940 | break; | 1073 | break; |
941 | #endif | 1074 | #endif |
942 | #ifdef HAVE_LCD_CHARCELLS | 1075 | #ifdef HAVE_LCD_CHARCELLS |
943 | lcd_icon(ICON_RECORD, false); | 1076 | lcd_icon(ICON_RECORD, false); |