diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/wps-display.c | 79 |
1 files changed, 48 insertions, 31 deletions
diff --git a/apps/wps-display.c b/apps/wps-display.c index 26392a2701..f35dfd6fc6 100644 --- a/apps/wps-display.c +++ b/apps/wps-display.c | |||
@@ -59,11 +59,12 @@ | |||
59 | #define FORMAT_BUFFER_SIZE 300 | 59 | #define FORMAT_BUFFER_SIZE 300 |
60 | 60 | ||
61 | #ifdef HAVE_LCD_CHARCELLS | 61 | #ifdef HAVE_LCD_CHARCELLS |
62 | static unsigned char wps_progress_pat[6]={0,0,0,0,0,0}; | 62 | static unsigned char wps_progress_pat[8]={0,0,0,0,0,0,0,0}; |
63 | static bool full_line_progressbar=0; | 63 | static bool full_line_progressbar=0; |
64 | static bool draw_player_progress(struct mp3entry* id3, int ff_rewwind_count); | 64 | static bool draw_player_progress(struct mp3entry* id3, int ff_rewwind_count); |
65 | static void draw_player_fullbar(char* buf, int buf_size, | 65 | static void draw_player_fullbar(char* buf, int buf_size, |
66 | struct mp3entry* id3, int ff_rewwind_count); | 66 | struct mp3entry* id3, int ff_rewwind_count); |
67 | static char map_fullbar_char(char ascii_val); | ||
67 | #endif | 68 | #endif |
68 | 69 | ||
69 | static char format_buffer[FORMAT_BUFFER_SIZE]; | 70 | static char format_buffer[FORMAT_BUFFER_SIZE]; |
@@ -656,7 +657,7 @@ bool wps_refresh(struct mp3entry* id3, int ffwd_offset, unsigned char refresh_mo | |||
656 | bool enable_pm = false; | 657 | bool enable_pm = false; |
657 | #endif | 658 | #endif |
658 | #ifdef HAVE_LCD_CHARCELLS | 659 | #ifdef HAVE_LCD_CHARCELLS |
659 | for (i=0; i<6; i++) { | 660 | for (i=0; i<8; i++) { |
660 | if (wps_progress_pat[i]==0) | 661 | if (wps_progress_pat[i]==0) |
661 | wps_progress_pat[i]=lcd_get_locked_pattern(); | 662 | wps_progress_pat[i]=lcd_get_locked_pattern(); |
662 | } | 663 | } |
@@ -837,11 +838,11 @@ static bool draw_player_progress(struct mp3entry* id3, int ff_rewwind_count) | |||
837 | static void draw_player_fullbar(char* buf, int buf_size, | 838 | static void draw_player_fullbar(char* buf, int buf_size, |
838 | struct mp3entry* id3, int ff_rewwind_count) | 839 | struct mp3entry* id3, int ff_rewwind_count) |
839 | { | 840 | { |
840 | int i,j,digit; | 841 | int i,j,lcd_char_pos; |
841 | 842 | ||
842 | char player_progressbar[7]; | 843 | char player_progressbar[7]; |
843 | char binline[36]; | 844 | char binline[36]; |
844 | char numbers[11][4][3]={{{1,1,1},{1,0,1},{1,0,1},{1,1,1}},/*0*/ | 845 | char numbers[12][4][3]={{{1,1,1},{1,0,1},{1,0,1},{1,1,1}},/*0*/ |
845 | {{0,1,0},{1,1,0},{0,1,0},{0,1,0}},/*1*/ | 846 | {{0,1,0},{1,1,0},{0,1,0},{0,1,0}},/*1*/ |
846 | {{1,1,1},{0,0,1},{0,1,0},{1,1,1}},/*2*/ | 847 | {{1,1,1},{0,0,1},{0,1,0},{1,1,1}},/*2*/ |
847 | {{1,1,1},{0,0,1},{0,1,1},{1,1,1}},/*3*/ | 848 | {{1,1,1},{0,0,1},{0,1,1},{1,1,1}},/*3*/ |
@@ -851,17 +852,19 @@ static void draw_player_fullbar(char* buf, int buf_size, | |||
851 | {{1,1,1},{0,0,1},{0,1,0},{1,0,0}},/*7*/ | 852 | {{1,1,1},{0,0,1},{0,1,0},{1,0,0}},/*7*/ |
852 | {{1,1,1},{1,1,1},{1,0,1},{1,1,1}},/*8*/ | 853 | {{1,1,1},{1,1,1},{1,0,1},{1,1,1}},/*8*/ |
853 | {{1,1,1},{1,1,1},{0,0,1},{1,1,1}},/*9*/ | 854 | {{1,1,1},{1,1,1},{0,0,1},{1,1,1}},/*9*/ |
854 | {{0,0,0},{0,1,0},{0,0,0},{0,1,0}}};/*:*/ | 855 | {{0,0,0},{0,1,0},{0,0,0},{0,1,0}},/*:*/ |
856 | {{0,0,0},{0,0,0},{0,0,0},{0,0,0}}};/*<blank>*/ | ||
855 | 857 | ||
856 | int songpos = 0; | 858 | int songpos = 0; |
857 | int digits[5]; | 859 | int digits[6]; |
858 | int time; | 860 | int time; |
861 | char timestr[7]; | ||
859 | 862 | ||
860 | for (i=0; i < buf_size; i++) | 863 | for (i=0; i < buf_size; i++) |
861 | buf[i] = ' '; | 864 | buf[i] = ' '; |
862 | 865 | ||
863 | if(id3->elapsed >= id3->length) | 866 | if(id3->elapsed >= id3->length) |
864 | songpos = 11; | 867 | songpos = 55; |
865 | else { | 868 | else { |
866 | if(wps_time_countup == false) | 869 | if(wps_time_countup == false) |
867 | songpos = ((id3->elapsed - ff_rewwind_count) * 55) / id3->length; | 870 | songpos = ((id3->elapsed - ff_rewwind_count) * 55) / id3->length; |
@@ -871,22 +874,22 @@ static void draw_player_fullbar(char* buf, int buf_size, | |||
871 | 874 | ||
872 | time=(id3->elapsed + ff_rewind_count); | 875 | time=(id3->elapsed + ff_rewind_count); |
873 | 876 | ||
874 | digits[4]=(time % 60000 / 1000 ) % 10; | 877 | memset(timestr, 0, sizeof(timestr)); |
875 | digits[3]=(time % 60000 / 10000) % 10; | 878 | format_time(timestr, sizeof(timestr), time); |
876 | digits[2]=10; /*:*/ | 879 | for(lcd_char_pos=0; lcd_char_pos<6; lcd_char_pos++) { |
877 | digits[1]=(time / 60000 ) % 10; | 880 | digits[lcd_char_pos] = map_fullbar_char(timestr[lcd_char_pos]); |
878 | digits[0]=(time / 600000) % 10; | 881 | } |
879 | 882 | ||
880 | /* build the progressbar-icon */ | 883 | /* build the progressbar-icons */ |
881 | for (digit=0; digit <=4; digit++) { | 884 | for (lcd_char_pos=0; lcd_char_pos<6; lcd_char_pos++) { |
882 | memset(binline, 0, sizeof binline); | 885 | memset(binline, 0, sizeof binline); |
883 | memset(player_progressbar, 0, sizeof player_progressbar); | 886 | memset(player_progressbar, 0, sizeof player_progressbar); |
884 | 887 | ||
885 | /* make the character (progressbar & digit)*/ | 888 | /* make the character (progressbar & digit)*/ |
886 | for (i=0; i<=6; i++) { | 889 | for (i=0; i<7; i++) { |
887 | for (j=0;j<5;j++) { | 890 | for (j=0;j<5;j++) { |
888 | /* make the progressbar */ | 891 | /* make the progressbar */ |
889 | if (digit==(songpos/5)) { | 892 | if (lcd_char_pos==(songpos/5)) { |
890 | /* partial */ | 893 | /* partial */ |
891 | if ((j<(songpos%5))&&(i>4)) | 894 | if ((j<(songpos%5))&&(i>4)) |
892 | binline[i*5+j] = 1; | 895 | binline[i*5+j] = 1; |
@@ -894,7 +897,7 @@ static void draw_player_fullbar(char* buf, int buf_size, | |||
894 | binline[i*5+j] = 0; | 897 | binline[i*5+j] = 0; |
895 | } | 898 | } |
896 | else { | 899 | else { |
897 | if (digit<(songpos/5)) { | 900 | if (lcd_char_pos<(songpos/5)) { |
898 | /* full character */ | 901 | /* full character */ |
899 | if (i>4) | 902 | if (i>4) |
900 | binline[i*5+j] = 1; | 903 | binline[i*5+j] = 1; |
@@ -902,7 +905,7 @@ static void draw_player_fullbar(char* buf, int buf_size, | |||
902 | } | 905 | } |
903 | /* insert the digit */ | 906 | /* insert the digit */ |
904 | if ((j<3)&&(i<4)) { | 907 | if ((j<3)&&(i<4)) { |
905 | if (numbers[digits[digit]][i][j]==1) | 908 | if (numbers[digits[lcd_char_pos]][i][j]==1) |
906 | binline[i*5+j] = 1; | 909 | binline[i*5+j] = 1; |
907 | } | 910 | } |
908 | } | 911 | } |
@@ -915,18 +918,23 @@ static void draw_player_fullbar(char* buf, int buf_size, | |||
915 | } | 918 | } |
916 | } | 919 | } |
917 | 920 | ||
918 | lcd_define_pattern(wps_progress_pat[digit],player_progressbar); | 921 | lcd_define_pattern(wps_progress_pat[lcd_char_pos+1],player_progressbar); |
919 | buf[digit]=wps_progress_pat[digit]; | 922 | buf[lcd_char_pos]=wps_progress_pat[lcd_char_pos+1]; |
920 | 923 | ||
921 | } | 924 | } |
922 | 925 | ||
923 | /* make rest of the progressbar if necessary */ | 926 | /* make rest of the progressbar if necessary */ |
924 | if (songpos/5>4) { | 927 | if (songpos/5>5) { |
925 | 928 | ||
929 | /* set the characters positions that use the full 5 pixel wide bar */ | ||
930 | for (lcd_char_pos=6; lcd_char_pos < (songpos/5); lcd_char_pos++) | ||
931 | buf[lcd_char_pos] = 0x86; /* '_' */ | ||
932 | |||
933 | /* build the partial bar character for the tail character position */ | ||
926 | memset(binline, 0, sizeof binline); | 934 | memset(binline, 0, sizeof binline); |
927 | memset(player_progressbar, 0, sizeof player_progressbar); | 935 | memset(player_progressbar, 0, sizeof player_progressbar); |
928 | 936 | ||
929 | for (i=5; i<=6; i++) { | 937 | for (i=5; i<7; i++) { |
930 | for (j=0;j<5;j++) { | 938 | for (j=0;j<5;j++) { |
931 | if (j<(songpos%5)) { | 939 | if (j<(songpos%5)) { |
932 | binline[i*5+j] = 1; | 940 | binline[i*5+j] = 1; |
@@ -934,23 +942,32 @@ static void draw_player_fullbar(char* buf, int buf_size, | |||
934 | } | 942 | } |
935 | } | 943 | } |
936 | 944 | ||
937 | for (i=0; i<=6; i++) { | 945 | for (i=0; i<7; i++) { |
938 | for (j=0;j<5;j++) { | 946 | for (j=0;j<5;j++) { |
939 | player_progressbar[i] <<= 1; | 947 | player_progressbar[i] <<= 1; |
940 | player_progressbar[i] += binline[i*5+j]; | 948 | player_progressbar[i] += binline[i*5+j]; |
941 | } | 949 | } |
942 | } | 950 | } |
943 | 951 | ||
944 | lcd_define_pattern(wps_progress_pat[5],player_progressbar); | 952 | lcd_define_pattern(wps_progress_pat[7],player_progressbar); |
945 | 953 | ||
946 | for (i=5; i < (songpos/5); i++) | 954 | buf[songpos/5]=wps_progress_pat[7]; |
947 | buf[i] = 0x86; /* '_' */ | ||
948 | |||
949 | buf[songpos/5]=wps_progress_pat[5]; | ||
950 | } | 955 | } |
951 | |||
952 | } | 956 | } |
953 | 957 | ||
958 | static char map_fullbar_char(char ascii_val) | ||
959 | { | ||
960 | if (ascii_val >= '0' && ascii_val <= '9') { | ||
961 | return(ascii_val - '0'); | ||
962 | } | ||
963 | else if (ascii_val == ':') { | ||
964 | return(10); | ||
965 | } | ||
966 | else | ||
967 | return(11); /* anything besides a number or ':' is mapped to <blank> */ | ||
968 | } | ||
969 | |||
970 | |||
954 | #endif | 971 | #endif |
955 | 972 | ||
956 | /* ----------------------------------------------------------------- | 973 | /* ----------------------------------------------------------------- |