diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/settings.h | 7 | ||||
-rw-r--r-- | apps/settings_menu.c | 1 | ||||
-rw-r--r-- | apps/wps.c | 257 | ||||
-rw-r--r-- | apps/wps.h | 3 |
4 files changed, 167 insertions, 101 deletions
diff --git a/apps/settings.h b/apps/settings.h index 36cf4930e1..fe85c13bfd 100644 --- a/apps/settings.h +++ b/apps/settings.h | |||
@@ -23,6 +23,9 @@ | |||
23 | #include <stdbool.h> | 23 | #include <stdbool.h> |
24 | #include "file.h" | 24 | #include "file.h" |
25 | 25 | ||
26 | /* Custom WPS Parsing - Uncomment to enable - PLAYER ONLY */ | ||
27 | /* #define CUSTOM_WPS */ | ||
28 | |||
26 | /* data structures */ | 29 | /* data structures */ |
27 | 30 | ||
28 | #define RESUME_OFF 0 | 31 | #define RESUME_OFF 0 |
@@ -63,6 +66,10 @@ struct user_settings | |||
63 | bool sort_case; /* dir sort order: 0=case insensitive, 1=sensitive */ | 66 | bool sort_case; /* dir sort order: 0=case insensitive, 1=sensitive */ |
64 | int scroll_speed; /* long texts scrolling speed: 1-20 */ | 67 | int scroll_speed; /* long texts scrolling speed: 1-20 */ |
65 | bool playlist_shuffle; | 68 | bool playlist_shuffle; |
69 | #ifdef CUSTOM_WPS | ||
70 | char custom_wps[64]; /* custom WPS string */ | ||
71 | bool wps_changed; /* to reload Custom WPS if changed to it */ | ||
72 | #endif | ||
66 | 73 | ||
67 | /* while playing screen settings */ | 74 | /* while playing screen settings */ |
68 | int wps_display; /* 0=id3, 1=file, 2=parse */ | 75 | int wps_display; /* 0=id3, 1=file, 2=parse */ |
diff --git a/apps/settings_menu.c b/apps/settings_menu.c index 2bb4ef4481..d950bf3b63 100644 --- a/apps/settings_menu.c +++ b/apps/settings_menu.c | |||
@@ -103,6 +103,7 @@ static Menu wps_set(void) | |||
103 | char* names[] = { "1 Line ID3", "2 Line ID3", "File ", | 103 | char* names[] = { "1 Line ID3", "2 Line ID3", "File ", |
104 | "Parse ", "Custom WPS " }; | 104 | "Parse ", "Custom WPS " }; |
105 | set_option("[WPS display]", &global_settings.wps_display, names, 5 ); | 105 | set_option("[WPS display]", &global_settings.wps_display, names, 5 ); |
106 | global_settings.wps_changed = true; | ||
106 | #else | 107 | #else |
107 | char* names[] = { "1 Line ID3", "2 Line ID3", "File ", | 108 | char* names[] = { "1 Line ID3", "2 Line ID3", "File ", |
108 | "Parse " }; | 109 | "Parse " }; |
diff --git a/apps/wps.c b/apps/wps.c index 7b44e88804..32bbd0de9d 100644 --- a/apps/wps.c +++ b/apps/wps.c | |||
@@ -90,6 +90,13 @@ static void draw_screen(struct mp3entry* id3) | |||
90 | } | 90 | } |
91 | else | 91 | else |
92 | { | 92 | { |
93 | #ifdef CUSTOM_WPS | ||
94 | if(global_settings.wps_changed) { | ||
95 | if(global_settings.wps_display == PLAY_DISPLAY_CUSTOM_WPS) | ||
96 | load_custom_wps(); | ||
97 | global_settings.wps_changed = false; | ||
98 | } | ||
99 | #endif | ||
93 | switch ( global_settings.wps_display ) { | 100 | switch ( global_settings.wps_display ) { |
94 | case PLAY_DISPLAY_TRACK_TITLE: | 101 | case PLAY_DISPLAY_TRACK_TITLE: |
95 | { | 102 | { |
@@ -123,6 +130,9 @@ static void draw_screen(struct mp3entry* id3) | |||
123 | } | 130 | } |
124 | case PLAY_DISPLAY_FILENAME_SCROLL: | 131 | case PLAY_DISPLAY_FILENAME_SCROLL: |
125 | { | 132 | { |
133 | #ifdef CUSTOM_WPS | ||
134 | display_custom_wps(0, 0, true, "%pp/%pe: %fn"); | ||
135 | #else | ||
126 | char buffer[64]; | 136 | char buffer[64]; |
127 | char ch = '/'; | 137 | char ch = '/'; |
128 | char* szLast = strrchr(id3->path, ch); | 138 | char* szLast = strrchr(id3->path, ch); |
@@ -142,6 +152,7 @@ static void draw_screen(struct mp3entry* id3) | |||
142 | id3->path); | 152 | id3->path); |
143 | } | 153 | } |
144 | lcd_puts_scroll(0, 0, buffer); | 154 | lcd_puts_scroll(0, 0, buffer); |
155 | #endif | ||
145 | break; | 156 | break; |
146 | } | 157 | } |
147 | case PLAY_DISPLAY_2LINEID3: | 158 | case PLAY_DISPLAY_2LINEID3: |
@@ -178,14 +189,22 @@ static void draw_screen(struct mp3entry* id3) | |||
178 | lcd_puts(0, l++, buffer); | 189 | lcd_puts(0, l++, buffer); |
179 | } | 190 | } |
180 | #else | 191 | #else |
192 | #ifdef CUSTOM_WPS | ||
193 | display_custom_wps(0, l++, false, "%ia"); | ||
194 | display_custom_wps(0, l++, true, "%it"); | ||
195 | #else | ||
181 | lcd_puts(0, l++, id3->artist?id3->artist:"<no artist>"); | 196 | lcd_puts(0, l++, id3->artist?id3->artist:"<no artist>"); |
182 | lcd_puts_scroll(0, l++, id3->title?id3->title:"<no title>"); | 197 | lcd_puts_scroll(0, l++, id3->title?id3->title:"<no title>"); |
183 | #endif | 198 | #endif |
199 | #endif | ||
184 | break; | 200 | break; |
185 | } | 201 | } |
186 | #ifdef HAVE_LCD_CHARCELLS | 202 | #ifdef HAVE_LCD_CHARCELLS |
187 | case PLAY_DISPLAY_1LINEID3: | 203 | case PLAY_DISPLAY_1LINEID3: |
188 | { | 204 | { |
205 | #ifdef CUSTOM_WPS | ||
206 | display_custom_wps(0, 0, true, "%pp/%pe: %fc"); | ||
207 | #else | ||
189 | char buffer[64]; | 208 | char buffer[64]; |
190 | char ch = '/'; | 209 | char ch = '/'; |
191 | char* szLast = strrchr(id3->path, ch); | 210 | char* szLast = strrchr(id3->path, ch); |
@@ -200,12 +219,17 @@ static void draw_screen(struct mp3entry* id3) | |||
200 | id3->index + 1, playlist.amount, | 219 | id3->index + 1, playlist.amount, |
201 | szLast?++szLast:id3->path); | 220 | szLast?++szLast:id3->path); |
202 | lcd_puts_scroll(0, 0, buffer); | 221 | lcd_puts_scroll(0, 0, buffer); |
222 | #endif | ||
203 | break; | 223 | break; |
204 | } | 224 | } |
205 | #ifdef CUSTOM_WPS | 225 | #ifdef CUSTOM_WPS |
206 | case PLAY_DISPLAY_CUSTOM_WPS: | 226 | case PLAY_DISPLAY_CUSTOM_WPS: |
207 | { | 227 | { |
208 | wps_load_custom_config(); | 228 | if(global_settings.custom_wps[0] == 0) |
229 | snprintf(global_settings.custom_wps, sizeof(global_settings.custom_wps), | ||
230 | "Couldn't Load Custom WPS"); | ||
231 | display_custom_wps(0, 0, true, global_settings.custom_wps); | ||
232 | break; | ||
209 | } | 233 | } |
210 | #endif | 234 | #endif |
211 | #endif | 235 | #endif |
@@ -216,14 +240,31 @@ static void draw_screen(struct mp3entry* id3) | |||
216 | } | 240 | } |
217 | 241 | ||
218 | #ifdef CUSTOM_WPS | 242 | #ifdef CUSTOM_WPS |
219 | int wps_load_custom_config(void) | 243 | bool load_custom_wps(void) |
244 | { | ||
245 | int fd; | ||
246 | |||
247 | fd = open("/wps.config", O_RDONLY); | ||
248 | if(-1 == fd) | ||
249 | { | ||
250 | global_settings.custom_wps[0] = 0; | ||
251 | close(fd); | ||
252 | return(false); | ||
253 | } | ||
254 | read(fd, global_settings.custom_wps, sizeof(global_settings.custom_wps)); | ||
255 | close(fd); | ||
256 | return(true); | ||
257 | } | ||
258 | |||
259 | bool display_custom_wps(int x_val, int y_val, bool do_scroll, char *wps_string) | ||
220 | { | 260 | { |
221 | char buffer[128]; | 261 | char buffer[128]; |
222 | char tmpbuf[64]; | 262 | char tmpbuf[64]; |
223 | char cchr1[0] = ""; | 263 | char cchr1; |
224 | char cchr2[0] = ""; | 264 | char cchr2; |
225 | int i; | 265 | char cchr3; |
226 | int fd; | 266 | unsigned int seek; |
267 | |||
227 | struct mp3entry* id3 = NULL; | 268 | struct mp3entry* id3 = NULL; |
228 | char* szLast; | 269 | char* szLast; |
229 | 270 | ||
@@ -233,116 +274,128 @@ int wps_load_custom_config(void) | |||
233 | /* point to the first letter in the file name */ | 274 | /* point to the first letter in the file name */ |
234 | szLast++; | 275 | szLast++; |
235 | 276 | ||
236 | buffer[0]=0; | 277 | buffer[0] = 0; |
237 | lcd_stop_scroll(); | ||
238 | 278 | ||
239 | fd = open("/wps.config", O_RDONLY); | 279 | seek = -1; |
240 | if(-1 == fd) | ||
241 | { | ||
242 | lcd_puts(0, 0, " *Error* "); | ||
243 | sleep(HZ); | ||
244 | lcd_puts_scroll(0, 1, "--Couldn't Load wps.config--"); | ||
245 | sleep(HZ*5); | ||
246 | global_settings.wps_display = 0; | ||
247 | settings_save(); | ||
248 | draw_screen(id3); | ||
249 | return(-1); | ||
250 | } | ||
251 | while(1) | 280 | while(1) |
252 | { | 281 | { |
253 | i = read(fd, cchr1, 1); | 282 | seek++; |
254 | if(i <= 0) | 283 | cchr1 = wps_string[seek]; |
255 | { | 284 | tmpbuf[0] = 0; |
256 | close(fd); | 285 | switch(cchr1) |
257 | lcd_puts_scroll(0, 0, buffer); | ||
258 | return(1); | ||
259 | } | ||
260 | switch(cchr1[0]) | ||
261 | { | 286 | { |
262 | case '%': | 287 | case '%': |
263 | i = read(fd, cchr2, 1); | 288 | seek++; |
264 | if(i <= 0) | 289 | cchr2 = wps_string[seek]; |
290 | switch(cchr2) | ||
265 | { | 291 | { |
266 | close(fd); | 292 | case 'i': /* ID3 Information */ |
267 | lcd_puts_scroll(0, 0, buffer); | 293 | seek++; |
268 | return(1); | 294 | cchr3 = wps_string[seek]; |
269 | } | 295 | switch(cchr3) |
270 | switch(cchr2[0]) | 296 | { |
271 | { | 297 | case 't': /* ID3 Title */ |
272 | case 't': /* ID3 Title */ | 298 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", |
273 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", id3->title); | 299 | id3->title?id3->title:"<no title>"); |
274 | break; | 300 | break; |
275 | case 'a': /* ID3 Artist */ | 301 | case 'a': /* ID3 Artist */ |
276 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", id3->artist); | 302 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", |
277 | break; | 303 | id3->artist?id3->artist:"<no artist>"); |
278 | case 'n': /* ID3 Track Number */ | 304 | break; |
279 | snprintf(tmpbuf, sizeof(tmpbuf), "%d", id3->tracknum); | 305 | case 'n': /* ID3 Track Number */ |
280 | break; | 306 | snprintf(tmpbuf, sizeof(tmpbuf), "%d", id3->tracknum); |
281 | case 'u': /* ID3 Album */ | 307 | break; |
282 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", id3->album); | 308 | case 'd': /* ID3 Album/Disc */ |
283 | break; | 309 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", id3->album); |
284 | case 'c': /* Conditional Filename \ ID3 Artist-Title */ | 310 | break; |
285 | if(id3->artist && id3->title) | 311 | } |
286 | snprintf(tmpbuf, sizeof(tmpbuf), "%s - %s", | ||
287 | id3->artist?id3->artist:"<no artist>", | ||
288 | id3->title?id3->title:"<no title>"); | ||
289 | else | ||
290 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", | ||
291 | szLast?szLast:id3->path); | ||
292 | break; | ||
293 | case 'h': /* Conditional Filename \ ID3 Title-Artist */ | ||
294 | if(id3->artist && id3->title) | ||
295 | snprintf(tmpbuf, sizeof(tmpbuf), "%s - %s", | ||
296 | id3->title?id3->title:"<no title>", | ||
297 | id3->artist?id3->artist:"<no artist>"); | ||
298 | else | ||
299 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", | ||
300 | szLast?szLast:id3->path); | ||
301 | break; | ||
302 | case 'b': /* File Bitrate */ | ||
303 | snprintf(tmpbuf, sizeof(tmpbuf), "%d", id3->bitrate); | ||
304 | break; | ||
305 | case 'f': /* File Frequency */ | ||
306 | snprintf(tmpbuf, sizeof(tmpbuf), "%d", id3->frequency); | ||
307 | break; | ||
308 | case 'p': /* File Path */ | ||
309 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", id3->path); | ||
310 | break; | ||
311 | case 'm': /* File Name */ | ||
312 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", | ||
313 | szLast?szLast:id3->path); | ||
314 | break; | ||
315 | case 's': /* File Size (In Kilobytes) */ | ||
316 | snprintf(tmpbuf, sizeof(tmpbuf), "%d", | ||
317 | id3->filesize / 1024); | ||
318 | break; | ||
319 | case 'i': /* Playlist Position */ | ||
320 | snprintf(tmpbuf, sizeof(tmpbuf), "%d", id3->index + 1); | ||
321 | break; | ||
322 | case 'l': /* Playlist Total Entries */ | ||
323 | snprintf(tmpbuf, sizeof(tmpbuf), "%d", playlist.amount); | ||
324 | break; | 312 | break; |
325 | case 'e': /* Elapsed Time */ | 313 | case 'f': /* File Information */ |
326 | snprintf(tmpbuf, sizeof(tmpbuf), "%d:%02d", | 314 | seek++; |
327 | id3->elapsed / 60000, | 315 | cchr3 = wps_string[seek]; |
328 | id3->elapsed % 60000 / 1000); | 316 | switch(cchr3) |
317 | { | ||
318 | case 'c': /* Conditional Filename \ ID3 Artist-Title */ | ||
319 | if(id3->artist && id3->title) | ||
320 | snprintf(tmpbuf, sizeof(tmpbuf), "%s - %s", | ||
321 | id3->artist?id3->artist:"<no artist>", | ||
322 | id3->title?id3->title:"<no title>"); | ||
323 | else | ||
324 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", | ||
325 | szLast?szLast:id3->path); | ||
326 | break; | ||
327 | case 'd': /* Conditional Filename \ ID3 Title-Artist */ | ||
328 | if(id3->artist && id3->title) | ||
329 | snprintf(tmpbuf, sizeof(tmpbuf), "%s - %s", | ||
330 | id3->title?id3->title:"<no title>", | ||
331 | id3->artist?id3->artist:"<no artist>"); | ||
332 | else | ||
333 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", | ||
334 | szLast?szLast:id3->path); | ||
335 | break; | ||
336 | case 'b': /* File Bitrate */ | ||
337 | snprintf(tmpbuf, sizeof(tmpbuf), "%d", id3->bitrate); | ||
338 | break; | ||
339 | case 'f': /* File Frequency */ | ||
340 | snprintf(tmpbuf, sizeof(tmpbuf), "%d", id3->frequency); | ||
341 | break; | ||
342 | case 'p': /* File Path */ | ||
343 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", id3->path); | ||
344 | break; | ||
345 | case 'n': /* File Name */ | ||
346 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", | ||
347 | szLast?szLast:id3->path); | ||
348 | break; | ||
349 | case 's': /* File Size (In Kilobytes) */ | ||
350 | snprintf(tmpbuf, sizeof(tmpbuf), "%d", | ||
351 | id3->filesize / 1024); | ||
352 | break; | ||
353 | } | ||
329 | break; | 354 | break; |
330 | case 'o': /* Total Time */ | 355 | case 'p': /* Playlist/Song Information */ |
331 | snprintf(tmpbuf, sizeof(tmpbuf), "%d:%02d", | 356 | seek++; |
332 | id3->elapsed / 60000, | 357 | cchr3 = wps_string[seek]; |
333 | id3->elapsed % 60000 / 1000); | 358 | switch(cchr3) |
359 | { | ||
360 | case 'p': /* Playlist Position */ | ||
361 | snprintf(tmpbuf, sizeof(tmpbuf), "%d", id3->index + 1); | ||
362 | break; | ||
363 | case 'e': /* Playlist Total Entries */ | ||
364 | snprintf(tmpbuf, sizeof(tmpbuf), "%d", playlist.amount); | ||
365 | break; | ||
366 | case 'c': /* Current Time in Song */ | ||
367 | snprintf(tmpbuf, sizeof(tmpbuf), "%d:%02d", | ||
368 | id3->elapsed / 60000, | ||
369 | id3->elapsed % 60000 / 1000); | ||
370 | break; | ||
371 | case 't': /* Total Time */ | ||
372 | snprintf(tmpbuf, sizeof(tmpbuf), "%d:%02d", | ||
373 | id3->elapsed / 60000, | ||
374 | id3->elapsed % 60000 / 1000); | ||
375 | break; | ||
376 | } | ||
334 | break; | 377 | break; |
335 | case '%': /* Displays % */ | 378 | case '%': /* Displays % */ |
336 | snprintf(tmpbuf, sizeof(tmpbuf), "%%"); | 379 | snprintf(tmpbuf, sizeof(tmpbuf), "%%"); |
337 | break; | 380 | break; |
338 | } | 381 | } |
382 | snprintf(buffer, sizeof(buffer), "%s%s", buffer, tmpbuf); | ||
339 | break; | 383 | break; |
340 | default: | 384 | default: |
341 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", cchr1); | 385 | snprintf(buffer, sizeof(buffer), "%s%c", buffer, cchr1); |
342 | break; | 386 | break; |
343 | } | 387 | } |
344 | snprintf(buffer, sizeof(buffer), "%s%s", buffer, tmpbuf); | 388 | if(seek >= strlen(wps_string)) |
389 | { | ||
390 | lcd_stop_scroll(); | ||
391 | if(do_scroll) | ||
392 | lcd_puts_scroll(x_val, y_val, buffer); | ||
393 | else | ||
394 | lcd_puts(x_val, y_val, buffer); | ||
395 | return(true); | ||
396 | } | ||
345 | } | 397 | } |
398 | return(true); | ||
346 | } | 399 | } |
347 | #endif | 400 | #endif |
348 | 401 | ||
@@ -606,7 +659,11 @@ int wps_show(void) | |||
606 | #endif | 659 | #endif |
607 | 660 | ||
608 | ff_rewind = false; | 661 | ff_rewind = false; |
609 | 662 | ||
663 | #ifdef CUSTOM_WPS | ||
664 | load_custom_wps(); /* Load the Custom WPS file, if there is one */ | ||
665 | #endif | ||
666 | |||
610 | if(mpeg_is_playing()) | 667 | if(mpeg_is_playing()) |
611 | { | 668 | { |
612 | id3 = mpeg_current_track(); | 669 | id3 = mpeg_current_track(); |
diff --git a/apps/wps.h b/apps/wps.h index a65a9fda6a..01744216ad 100644 --- a/apps/wps.h +++ b/apps/wps.h | |||
@@ -28,7 +28,8 @@ extern bool keys_locked; | |||
28 | int wps_show(void); | 28 | int wps_show(void); |
29 | 29 | ||
30 | #ifdef CUSTOM_WPS | 30 | #ifdef CUSTOM_WPS |
31 | int wps_load_custom_config(void); | 31 | bool load_custom_wps(void); |
32 | bool display_custom_wps(int x_val, int y_val, bool do_scroll, char *wps_string); | ||
32 | #endif | 33 | #endif |
33 | 34 | ||
34 | #endif | 35 | #endif |