diff options
Diffstat (limited to 'apps/wps.c')
-rw-r--r-- | apps/wps.c | 210 |
1 files changed, 42 insertions, 168 deletions
diff --git a/apps/wps.c b/apps/wps.c index 4699ed30d8..40cc2db335 100644 --- a/apps/wps.c +++ b/apps/wps.c | |||
@@ -74,12 +74,10 @@ static int ff_rewind_count = 0; | |||
74 | static struct mp3entry* id3 = NULL; | 74 | static struct mp3entry* id3 = NULL; |
75 | static int old_release_mask; | 75 | static int old_release_mask; |
76 | 76 | ||
77 | #ifdef CUSTOM_WPS | ||
78 | static char custom_wps[5][64]; | 77 | static char custom_wps[5][64]; |
79 | static char wps_display[5][64]; | 78 | static char wps_display[5][64]; |
80 | static int scroll_line; | 79 | static int scroll_line; |
81 | static int scroll_line_custom; | 80 | static int scroll_line_custom; |
82 | #endif | ||
83 | 81 | ||
84 | static void draw_screen(void) | 82 | static void draw_screen(void) |
85 | { | 83 | { |
@@ -105,7 +103,6 @@ static void draw_screen(void) | |||
105 | } | 103 | } |
106 | else | 104 | else |
107 | { | 105 | { |
108 | #ifdef CUSTOM_WPS | ||
109 | static int last_wps = -1; | 106 | static int last_wps = -1; |
110 | if ((last_wps != global_settings.wps_display | 107 | if ((last_wps != global_settings.wps_display |
111 | && global_settings.wps_display == PLAY_DISPLAY_CUSTOM_WPS)) | 108 | && global_settings.wps_display == PLAY_DISPLAY_CUSTOM_WPS)) |
@@ -113,7 +110,7 @@ static void draw_screen(void) | |||
113 | load_custom_wps(); | 110 | load_custom_wps(); |
114 | last_wps = global_settings.wps_display; | 111 | last_wps = global_settings.wps_display; |
115 | } | 112 | } |
116 | #endif | 113 | |
117 | switch ( global_settings.wps_display ) { | 114 | switch ( global_settings.wps_display ) { |
118 | case PLAY_DISPLAY_TRACK_TITLE: | 115 | case PLAY_DISPLAY_TRACK_TITLE: |
119 | { | 116 | { |
@@ -124,9 +121,7 @@ static void draw_screen(void) | |||
124 | char* szPeriod; | 121 | char* szPeriod; |
125 | char szArtist[26]; | 122 | char szArtist[26]; |
126 | char szBuff[257]; | 123 | char szBuff[257]; |
127 | #ifdef CUSTOM_WPS | ||
128 | int tmpcnt = 0; | 124 | int tmpcnt = 0; |
129 | #endif | ||
130 | 125 | ||
131 | szBuff[sizeof(szBuff)-1] = 0; | 126 | szBuff[sizeof(szBuff)-1] = 0; |
132 | strncpy(szBuff, id3->path, sizeof(szBuff)); | 127 | strncpy(szBuff, id3->path, sizeof(szBuff)); |
@@ -144,7 +139,7 @@ static void draw_screen(void) | |||
144 | szPeriod = strrchr(szDelimit, '.'); | 139 | szPeriod = strrchr(szDelimit, '.'); |
145 | if (szPeriod != NULL) | 140 | if (szPeriod != NULL) |
146 | *szPeriod = 0; | 141 | *szPeriod = 0; |
147 | #ifdef CUSTOM_WPS | 142 | |
148 | snprintf(wps_display[0],sizeof(wps_display[0]),"%s", | 143 | snprintf(wps_display[0],sizeof(wps_display[0]),"%s", |
149 | (++szDelimit)); | 144 | (++szDelimit)); |
150 | #ifdef HAVE_LCD_CHARCELLS | 145 | #ifdef HAVE_LCD_CHARCELLS |
@@ -155,14 +150,10 @@ static void draw_screen(void) | |||
155 | wps_display[tmpcnt][0] = 0; | 150 | wps_display[tmpcnt][0] = 0; |
156 | scroll_line = 0; | 151 | scroll_line = 0; |
157 | refresh_wps(false); | 152 | refresh_wps(false); |
158 | #else | ||
159 | lcd_puts_scroll(0, 1, (++szDelimit)); | ||
160 | #endif | ||
161 | break; | 153 | break; |
162 | } | 154 | } |
163 | case PLAY_DISPLAY_FILENAME_SCROLL: | 155 | case PLAY_DISPLAY_FILENAME_SCROLL: |
164 | { | 156 | { |
165 | #ifdef CUSTOM_WPS | ||
166 | snprintf(wps_display[0],sizeof(wps_display[0]),"%s", | 157 | snprintf(wps_display[0],sizeof(wps_display[0]),"%s", |
167 | "%pp/%pe: %fn"); | 158 | "%pp/%pe: %fn"); |
168 | #ifdef HAVE_LCD_CHARCELLS | 159 | #ifdef HAVE_LCD_CHARCELLS |
@@ -171,27 +162,6 @@ static void draw_screen(void) | |||
171 | #endif | 162 | #endif |
172 | scroll_line = 0; | 163 | scroll_line = 0; |
173 | refresh_wps(false); | 164 | refresh_wps(false); |
174 | #else | ||
175 | char buffer[64]; | ||
176 | char ch = '/'; | ||
177 | char* szLast = strrchr(id3->path, ch); | ||
178 | |||
179 | if (szLast) | ||
180 | { | ||
181 | snprintf(buffer, sizeof(buffer), "%d/%d: %s", | ||
182 | id3->index + 1, | ||
183 | playlist.amount, | ||
184 | ++szLast); | ||
185 | } | ||
186 | else | ||
187 | { | ||
188 | snprintf(buffer, sizeof(buffer), "%d/%d: %s", | ||
189 | id3->index + 1, | ||
190 | playlist.amount, | ||
191 | id3->path); | ||
192 | } | ||
193 | lcd_puts_scroll(0, 0, buffer); | ||
194 | #endif | ||
195 | break; | 165 | break; |
196 | } | 166 | } |
197 | case PLAY_DISPLAY_2LINEID3: | 167 | case PLAY_DISPLAY_2LINEID3: |
@@ -199,7 +169,6 @@ static void draw_screen(void) | |||
199 | #ifdef HAVE_LCD_BITMAP | 169 | #ifdef HAVE_LCD_BITMAP |
200 | int l = 0; | 170 | int l = 0; |
201 | 171 | ||
202 | #ifdef CUSTOM_WPS | ||
203 | snprintf(wps_display[l],sizeof(wps_display[l]),"%s","%fn"); | 172 | snprintf(wps_display[l],sizeof(wps_display[l]),"%s","%fn"); |
204 | snprintf(wps_display[l++],sizeof(wps_display[l]),"%s","%it"); | 173 | snprintf(wps_display[l++],sizeof(wps_display[l]),"%s","%it"); |
205 | snprintf(wps_display[l++],sizeof(wps_display[l]),"%s","%id"); | 174 | snprintf(wps_display[l++],sizeof(wps_display[l]),"%s","%id"); |
@@ -227,79 +196,25 @@ static void draw_screen(void) | |||
227 | scroll_line = 0; | 196 | scroll_line = 0; |
228 | refresh_wps(false); | 197 | refresh_wps(false); |
229 | #else | 198 | #else |
230 | char buffer[64]; | ||
231 | |||
232 | lcd_puts_scroll(0, l++, id3->path); | ||
233 | lcd_puts(0, l++, id3->title?id3->title:""); | ||
234 | lcd_puts(0, l++, id3->album?id3->album:""); | ||
235 | lcd_puts(0, l++, id3->artist?id3->artist:""); | ||
236 | |||
237 | if(!global_settings.statusbar && font_height <= 8) { | ||
238 | if(id3->vbr) | ||
239 | snprintf(buffer, sizeof(buffer), "%d kbit (avg)", | ||
240 | id3->bitrate); | ||
241 | else | ||
242 | snprintf(buffer, sizeof(buffer), "%d kbit", | ||
243 | id3->bitrate); | ||
244 | |||
245 | lcd_puts(0, l++, buffer); | ||
246 | snprintf(buffer,sizeof(buffer), "%d Hz", id3->frequency); | ||
247 | lcd_puts(0, l++, buffer); | ||
248 | } | ||
249 | else { | ||
250 | if(id3->vbr) | ||
251 | snprintf(buffer, sizeof(buffer), "%dkbit(a) %dHz", | ||
252 | id3->bitrate, id3->frequency); | ||
253 | else | ||
254 | snprintf(buffer, sizeof(buffer), "%dkbit %dHz", | ||
255 | id3->bitrate, id3->frequency); | ||
256 | |||
257 | lcd_puts(0, l++, buffer); | ||
258 | } | ||
259 | #endif | ||
260 | #else | ||
261 | #ifdef CUSTOM_WPS | ||
262 | snprintf(wps_display[0],sizeof(wps_display[0]),"%s","%ia"); | 199 | snprintf(wps_display[0],sizeof(wps_display[0]),"%s","%ia"); |
263 | snprintf(wps_display[1],sizeof(wps_display[1]),"%s","%it"); | 200 | snprintf(wps_display[1],sizeof(wps_display[1]),"%s","%it"); |
264 | scroll_line = 1; | 201 | scroll_line = 1; |
265 | refresh_wps(false); | 202 | refresh_wps(false); |
266 | #else | ||
267 | lcd_puts(0, 0, id3->artist?id3->artist:"<no artist>"); | ||
268 | lcd_puts_scroll(0, 1, id3->title?id3->title:"<no title>"); | ||
269 | #endif | ||
270 | #endif | 203 | #endif |
271 | break; | 204 | break; |
272 | } | 205 | } |
273 | #ifdef HAVE_LCD_CHARCELLS | 206 | #ifdef HAVE_LCD_CHARCELLS |
274 | case PLAY_DISPLAY_1LINEID3: | 207 | case PLAY_DISPLAY_1LINEID3: |
275 | { | 208 | { |
276 | #ifdef CUSTOM_WPS | ||
277 | snprintf(wps_display[0],sizeof(wps_display[0]),"%s", | 209 | snprintf(wps_display[0],sizeof(wps_display[0]),"%s", |
278 | "%pp/%pe: %fc"); | 210 | "%pp/%pe: %fc"); |
279 | snprintf(wps_display[1],sizeof(wps_display[1]),"%s", | 211 | snprintf(wps_display[1],sizeof(wps_display[1]),"%s", |
280 | "%pc/%pt"); | 212 | "%pc/%pt"); |
281 | scroll_line = 0; | 213 | scroll_line = 0; |
282 | refresh_wps(false); | 214 | refresh_wps(false); |
283 | #else | ||
284 | char buffer[64]; | ||
285 | char ch = '/'; | ||
286 | char* szLast = strrchr(id3->path, ch); | ||
287 | |||
288 | if(id3->artist && id3->title) | ||
289 | snprintf(buffer, sizeof(buffer), "%d/%d: %s - %s", | ||
290 | id3->index + 1, playlist.amount, | ||
291 | id3->artist?id3->artist:"<no artist>", | ||
292 | id3->title?id3->title:"<no title>"); | ||
293 | else | ||
294 | snprintf(buffer, sizeof(buffer), "%d/%d: %s", | ||
295 | id3->index + 1, playlist.amount, | ||
296 | szLast?++szLast:id3->path); | ||
297 | lcd_puts_scroll(0, 0, buffer); | ||
298 | #endif | ||
299 | break; | 215 | break; |
300 | } | 216 | } |
301 | #endif | 217 | #endif |
302 | #ifdef CUSTOM_WPS | ||
303 | case PLAY_DISPLAY_CUSTOM_WPS: | 218 | case PLAY_DISPLAY_CUSTOM_WPS: |
304 | { | 219 | { |
305 | if(custom_wps[0] == 0) | 220 | if(custom_wps[0] == 0) |
@@ -312,22 +227,30 @@ static void draw_screen(void) | |||
312 | refresh_wps(false); | 227 | refresh_wps(false); |
313 | break; | 228 | break; |
314 | } | 229 | } |
315 | #endif | ||
316 | } | 230 | } |
317 | } | 231 | } |
318 | status_draw(); | 232 | status_draw(); |
319 | lcd_update(); | 233 | lcd_update(); |
320 | } | 234 | } |
321 | 235 | ||
322 | #ifdef CUSTOM_WPS | 236 | #ifdef PLAYER_PROGRESS |
237 | int bin2int(char *input, int size) | ||
238 | { | ||
239 | int result=0; | ||
240 | while(size--) { | ||
241 | result <<= 1; | ||
242 | result += (*input++ - '0'); | ||
243 | } | ||
244 | return result; | ||
245 | } | ||
246 | #endif | ||
247 | |||
323 | bool refresh_wps(bool refresh_scroll) | 248 | bool refresh_wps(bool refresh_scroll) |
324 | { | 249 | { |
325 | int l; | 250 | int l; |
326 | #ifdef CUSTOM_WPS | ||
327 | #ifdef HAVE_LCD_BITMAP | 251 | #ifdef HAVE_LCD_BITMAP |
328 | int bmp_time_line; | 252 | int bmp_time_line; |
329 | #endif | 253 | #endif |
330 | #endif | ||
331 | 254 | ||
332 | if(!id3) | 255 | if(!id3) |
333 | { | 256 | { |
@@ -370,9 +293,37 @@ bool refresh_wps(bool refresh_scroll) | |||
370 | slidebar(0, LCD_HEIGHT-6, LCD_WIDTH, 6, id3->elapsed*100/id3->length, Grow_Right); | 293 | slidebar(0, LCD_HEIGHT-6, LCD_WIDTH, 6, id3->elapsed*100/id3->length, Grow_Right); |
371 | lcd_update(); | 294 | lcd_update(); |
372 | #endif | 295 | #endif |
296 | #ifdef PLAYER_PROGRESS | ||
297 | #ifdef HAVE_LCD_CHARCELLS | ||
298 | draw_player_progress(10,1); | ||
299 | #endif | ||
300 | #endif | ||
373 | return(true); | 301 | return(true); |
374 | } | 302 | } |
375 | 303 | ||
304 | #ifdef PLAYER_PROGRESS | ||
305 | #ifdef HAVE_LCD_CHARCELLS | ||
306 | void draw_player_progress(int x, int y) | ||
307 | { | ||
308 | char player_progressbar[8]; | ||
309 | char binline[35]; | ||
310 | char charline[5]; | ||
311 | int songpos = 0; | ||
312 | int tmpcnt; | ||
313 | |||
314 | memset(binline, 0, sizeof(binline)); | ||
315 | memset(charline, 0, sizeof(charline)); | ||
316 | songpos = (id3->elapsed * 35) / id3->length; | ||
317 | for(tmpcnt=0;tmpcnt<=songpos;tmpcnt++) | ||
318 | binline[tmpcnt] = 1; | ||
319 | for(tmpcnt=0;tmpcnt<=6;tmpcnt++) | ||
320 | player_progressbar[tmpcnt] = bin2int(binline+(tmpcnt*5),4); | ||
321 | lcd_define_pattern(8,player_progressbar,7); | ||
322 | lcd_puts(x,y,"\01"); | ||
323 | } | ||
324 | #endif | ||
325 | #endif | ||
326 | |||
376 | bool load_custom_wps(void) | 327 | bool load_custom_wps(void) |
377 | { | 328 | { |
378 | #ifdef SIMULATOR | 329 | #ifdef SIMULATOR |
@@ -625,7 +576,6 @@ bool display_custom_wps(int x_val, int y_val, bool do_scroll, char *wps_string) | |||
625 | } | 576 | } |
626 | return(true); | 577 | return(true); |
627 | } | 578 | } |
628 | #endif | ||
629 | 579 | ||
630 | int player_id3_show(void) | 580 | int player_id3_show(void) |
631 | { | 581 | { |
@@ -745,50 +695,6 @@ int player_id3_show(void) | |||
745 | return(0); | 695 | return(0); |
746 | } | 696 | } |
747 | 697 | ||
748 | #ifndef CUSTOM_WPS | ||
749 | static void display_file_time(void) | ||
750 | { | ||
751 | char buffer[32]; | ||
752 | int elapsed = id3->elapsed + ff_rewind_count; | ||
753 | |||
754 | #ifdef HAVE_LCD_BITMAP | ||
755 | int line; | ||
756 | if(global_settings.statusbar) | ||
757 | line = 5; | ||
758 | else | ||
759 | line = 6; | ||
760 | snprintf(buffer,sizeof(buffer), | ||
761 | "Time:%3d:%02d/%d:%02d", | ||
762 | elapsed / 60000, | ||
763 | elapsed % 60000 / 1000, | ||
764 | id3->length / 60000, | ||
765 | id3->length % 60000 / 1000 ); | ||
766 | |||
767 | lcd_puts(0, line, buffer); | ||
768 | slidebar(0, LCD_HEIGHT-6, LCD_WIDTH, 6, | ||
769 | elapsed*100/id3->length, Grow_Right); | ||
770 | lcd_update(); | ||
771 | #else | ||
772 | /* Display time with the filename scroll only because | ||
773 | the screen has room. */ | ||
774 | if ((global_settings.wps_display == PLAY_DISPLAY_FILENAME_SCROLL) || | ||
775 | global_settings.wps_display == PLAY_DISPLAY_1LINEID3 || | ||
776 | global_settings.wps_display == PLAY_DISPLAY_CUSTOM_WPS || | ||
777 | ff_rewind) | ||
778 | { | ||
779 | snprintf(buffer,sizeof(buffer), "%d:%02d/%d:%02d ", | ||
780 | elapsed / 60000, | ||
781 | elapsed % 60000 / 1000, | ||
782 | id3->length / 60000, | ||
783 | id3->length % 60000 / 1000 ); | ||
784 | |||
785 | lcd_puts(0, 1, buffer); | ||
786 | lcd_update(); | ||
787 | } | ||
788 | #endif | ||
789 | } | ||
790 | #endif | ||
791 | |||
792 | void display_volume_level(int vol_level) | 698 | void display_volume_level(int vol_level) |
793 | { | 699 | { |
794 | char buffer[32]; | 700 | char buffer[32]; |
@@ -926,11 +832,7 @@ static bool ffwd_rew(int button) | |||
926 | if ((int)(id3->elapsed + ff_rewind_count) < 0) | 832 | if ((int)(id3->elapsed + ff_rewind_count) < 0) |
927 | ff_rewind_count = -id3->elapsed; | 833 | ff_rewind_count = -id3->elapsed; |
928 | 834 | ||
929 | #ifdef CUSTOM_WPS | ||
930 | refresh_wps(false); | 835 | refresh_wps(false); |
931 | #else | ||
932 | display_file_time(); | ||
933 | #endif | ||
934 | break; | 836 | break; |
935 | 837 | ||
936 | case BUTTON_RIGHT | BUTTON_REPEAT: | 838 | case BUTTON_RIGHT | BUTTON_REPEAT: |
@@ -974,11 +876,7 @@ static bool ffwd_rew(int button) | |||
974 | if ((id3->elapsed + ff_rewind_count) > id3->length) | 876 | if ((id3->elapsed + ff_rewind_count) > id3->length) |
975 | ff_rewind_count = id3->length - id3->elapsed; | 877 | ff_rewind_count = id3->length - id3->elapsed; |
976 | 878 | ||
977 | #ifdef CUSTOM_WPS | ||
978 | refresh_wps(false); | 879 | refresh_wps(false); |
979 | #else | ||
980 | display_file_time(); | ||
981 | #endif | ||
982 | break; | 880 | break; |
983 | 881 | ||
984 | case BUTTON_LEFT | BUTTON_REL: | 882 | case BUTTON_LEFT | BUTTON_REL: |
@@ -1024,9 +922,7 @@ static bool ffwd_rew(int button) | |||
1024 | if (!exit) | 922 | if (!exit) |
1025 | button = button_get(true); | 923 | button = button_get(true); |
1026 | } | 924 | } |
1027 | #ifdef CUSTOM_WPS | ||
1028 | refresh_wps(true); | 925 | refresh_wps(true); |
1029 | #endif | ||
1030 | return usb; | 926 | return usb; |
1031 | } | 927 | } |
1032 | 928 | ||
@@ -1037,17 +933,11 @@ static void update(void) | |||
1037 | lcd_stop_scroll(); | 933 | lcd_stop_scroll(); |
1038 | id3 = mpeg_current_track(); | 934 | id3 = mpeg_current_track(); |
1039 | draw_screen(); | 935 | draw_screen(); |
1040 | #ifdef CUSTOM_WPS | ||
1041 | refresh_wps(true); | 936 | refresh_wps(true); |
1042 | #endif | ||
1043 | } | 937 | } |
1044 | 938 | ||
1045 | if (id3) { | 939 | if (id3) { |
1046 | #ifdef CUSTOM_WPS | ||
1047 | refresh_wps(false); | 940 | refresh_wps(false); |
1048 | #else | ||
1049 | display_file_time(); | ||
1050 | #endif | ||
1051 | } | 941 | } |
1052 | 942 | ||
1053 | status_draw(); | 943 | status_draw(); |
@@ -1075,9 +965,7 @@ static bool keylock(void) | |||
1075 | #endif | 965 | #endif |
1076 | display_keylock_text(true); | 966 | display_keylock_text(true); |
1077 | keys_locked = true; | 967 | keys_locked = true; |
1078 | #ifdef CUSTOM_WPS | ||
1079 | refresh_wps(true); | 968 | refresh_wps(true); |
1080 | #endif | ||
1081 | draw_screen(); | 969 | draw_screen(); |
1082 | status_draw(); | 970 | status_draw(); |
1083 | while (button_get(false)); /* clear button queue */ | 971 | while (button_get(false)); /* clear button queue */ |
@@ -1118,9 +1006,7 @@ static bool keylock(void) | |||
1118 | default: | 1006 | default: |
1119 | display_keylock_text(true); | 1007 | display_keylock_text(true); |
1120 | while (button_get(false)); /* clear button queue */ | 1008 | while (button_get(false)); /* clear button queue */ |
1121 | #ifdef CUSTOM_WPS | ||
1122 | refresh_wps(true); | 1009 | refresh_wps(true); |
1123 | #endif | ||
1124 | draw_screen(); | 1010 | draw_screen(); |
1125 | break; | 1011 | break; |
1126 | } | 1012 | } |
@@ -1238,9 +1124,7 @@ static bool menu(void) | |||
1238 | #endif | 1124 | #endif |
1239 | 1125 | ||
1240 | draw_screen(); | 1126 | draw_screen(); |
1241 | #ifdef CUSTOM_WPS | ||
1242 | refresh_wps(true); | 1127 | refresh_wps(true); |
1243 | #endif | ||
1244 | return false; | 1128 | return false; |
1245 | } | 1129 | } |
1246 | 1130 | ||
@@ -1268,20 +1152,14 @@ int wps_show(void) | |||
1268 | ff_rewind = false; | 1152 | ff_rewind = false; |
1269 | ff_rewind_count = 0; | 1153 | ff_rewind_count = 0; |
1270 | 1154 | ||
1271 | #ifdef CUSTOM_WPS | ||
1272 | load_custom_wps(); /* Load the Custom WPS file, if there is one */ | 1155 | load_custom_wps(); /* Load the Custom WPS file, if there is one */ |
1273 | #endif | ||
1274 | 1156 | ||
1275 | if(mpeg_is_playing()) | 1157 | if(mpeg_is_playing()) |
1276 | { | 1158 | { |
1277 | id3 = mpeg_current_track(); | 1159 | id3 = mpeg_current_track(); |
1278 | if (id3) { | 1160 | if (id3) { |
1279 | draw_screen(); | 1161 | draw_screen(); |
1280 | #ifdef CUSTOM_WPS | ||
1281 | refresh_wps(true); | 1162 | refresh_wps(true); |
1282 | #else | ||
1283 | display_file_time(); | ||
1284 | #endif | ||
1285 | } | 1163 | } |
1286 | restore = true; | 1164 | restore = true; |
1287 | } | 1165 | } |
@@ -1443,11 +1321,7 @@ int wps_show(void) | |||
1443 | restore = false; | 1321 | restore = false; |
1444 | draw_screen(); | 1322 | draw_screen(); |
1445 | if (id3) | 1323 | if (id3) |
1446 | #ifdef CUSTOM_WPS | ||
1447 | refresh_wps(false); | 1324 | refresh_wps(false); |
1448 | #else | ||
1449 | display_file_time(); | ||
1450 | #endif | ||
1451 | } | 1325 | } |
1452 | } | 1326 | } |
1453 | } | 1327 | } |