diff options
author | Justin Heiner <jheiner@rockbox.org> | 2002-08-22 02:24:14 +0000 |
---|---|---|
committer | Justin Heiner <jheiner@rockbox.org> | 2002-08-22 02:24:14 +0000 |
commit | b986a5c6b7cdb7d27bd81e11f2cbb6c40a125df2 (patch) | |
tree | 129fb629c1781b6e78b95ea2f67dafd1c7bf0761 /apps | |
parent | 7dcff6d98c4a7cc75a67f4134014deac2150724c (diff) | |
download | rockbox-b986a5c6b7cdb7d27bd81e11f2cbb6c40a125df2.tar.gz rockbox-b986a5c6b7cdb7d27bd81e11f2cbb6c40a125df2.zip |
Added ability to have a Custom WPS Display on the Player. See the commited doc for the tag specification
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1903 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/settings_menu.c | 5 | ||||
-rw-r--r-- | apps/wps.c | 131 |
2 files changed, 126 insertions, 10 deletions
diff --git a/apps/settings_menu.c b/apps/settings_menu.c index 334d55dabf..4d3a0ed6c5 100644 --- a/apps/settings_menu.c +++ b/apps/settings_menu.c | |||
@@ -86,8 +86,9 @@ static void wps_set(void) | |||
86 | char* names[] = { "ID3 Tags", "File ", "Parse " }; | 86 | char* names[] = { "ID3 Tags", "File ", "Parse " }; |
87 | set_option("[WPS display]", &global_settings.wps_display, names, 3 ); | 87 | set_option("[WPS display]", &global_settings.wps_display, names, 3 ); |
88 | #else | 88 | #else |
89 | char* names[] = { "1 Line ID3", "2 Line ID3", "File ", "Parse " }; | 89 | char* names[] = { "1 Line ID3", "2 Line ID3", "File ", |
90 | set_option("[WPS display]", &global_settings.wps_display, names, 4 ); | 90 | "Parse ", "Custom WPS " }; |
91 | set_option("[WPS display]", &global_settings.wps_display, names, 5 ); | ||
91 | #endif | 92 | #endif |
92 | } | 93 | } |
93 | 94 | ||
diff --git a/apps/wps.c b/apps/wps.c index 7e3e626297..dc588a56da 100644 --- a/apps/wps.c +++ b/apps/wps.c | |||
@@ -53,6 +53,7 @@ | |||
53 | #define PLAY_DISPLAY_2LINEID3 1 | 53 | #define PLAY_DISPLAY_2LINEID3 1 |
54 | #define PLAY_DISPLAY_FILENAME_SCROLL 2 | 54 | #define PLAY_DISPLAY_FILENAME_SCROLL 2 |
55 | #define PLAY_DISPLAY_TRACK_TITLE 3 | 55 | #define PLAY_DISPLAY_TRACK_TITLE 3 |
56 | #define PLAY_DISPLAY_CUSTOM_WPS 4 | ||
56 | #endif | 57 | #endif |
57 | 58 | ||
58 | #ifdef HAVE_RECORDER_KEYPAD | 59 | #ifdef HAVE_RECORDER_KEYPAD |
@@ -189,23 +190,21 @@ static void draw_screen(struct mp3entry* id3) | |||
189 | char* szLast = strrchr(id3->path, ch); | 190 | char* szLast = strrchr(id3->path, ch); |
190 | 191 | ||
191 | if(id3->artist && id3->title) | 192 | if(id3->artist && id3->title) |
192 | { | ||
193 | snprintf(buffer, sizeof(buffer), "%d/%d: %s - %s", | 193 | snprintf(buffer, sizeof(buffer), "%d/%d: %s - %s", |
194 | id3->index + 1, | 194 | id3->index + 1, playlist.amount, |
195 | playlist.amount, | ||
196 | id3->artist?id3->artist:"<no artist>", | 195 | id3->artist?id3->artist:"<no artist>", |
197 | id3->title?id3->title:"<no title>"); | 196 | id3->title?id3->title:"<no title>"); |
198 | } | ||
199 | else | 197 | else |
200 | { | ||
201 | snprintf(buffer, sizeof(buffer), "%d/%d: %s", | 198 | snprintf(buffer, sizeof(buffer), "%d/%d: %s", |
202 | id3->index + 1, | 199 | id3->index + 1, playlist.amount, |
203 | playlist.amount, | ||
204 | szLast?++szLast:id3->path); | 200 | szLast?++szLast:id3->path); |
205 | } | ||
206 | lcd_puts_scroll(0, 0, buffer); | 201 | lcd_puts_scroll(0, 0, buffer); |
207 | break; | 202 | break; |
208 | } | 203 | } |
204 | case PLAY_DISPLAY_CUSTOM_WPS: | ||
205 | { | ||
206 | wps_load_custom_config(); | ||
207 | } | ||
209 | #endif | 208 | #endif |
210 | } | 209 | } |
211 | } | 210 | } |
@@ -213,6 +212,121 @@ static void draw_screen(struct mp3entry* id3) | |||
213 | lcd_update(); | 212 | lcd_update(); |
214 | } | 213 | } |
215 | 214 | ||
215 | int wps_load_custom_config(void) | ||
216 | { | ||
217 | char buffer[128]; | ||
218 | char tmpbuf[64]; | ||
219 | char cchr1[0] = ""; | ||
220 | char cchr2[0] = ""; | ||
221 | int i; | ||
222 | int fd; | ||
223 | struct mp3entry* id3 = NULL; | ||
224 | |||
225 | id3 = mpeg_current_track(); | ||
226 | char ch = '/'; | ||
227 | char* szLast = strrchr(id3->path, ch); | ||
228 | |||
229 | snprintf(buffer, sizeof(buffer), ""); | ||
230 | lcd_stop_scroll(); | ||
231 | fd = open("/wps.config", O_RDONLY); | ||
232 | if(-1 == fd) | ||
233 | { | ||
234 | lcd_puts(0, 0, " *Error* "); | ||
235 | sleep(HZ); | ||
236 | lcd_puts_scroll(0, 1, "--Couldn't Load wps.config--"); | ||
237 | sleep(HZ*5); | ||
238 | global_settings.wps_display = 0; | ||
239 | settings_save(); | ||
240 | draw_screen(id3); | ||
241 | return(-1); | ||
242 | } | ||
243 | while(1) | ||
244 | { | ||
245 | i = read(fd, cchr1, 1); | ||
246 | if(i <= 0) | ||
247 | { | ||
248 | close(fd); | ||
249 | lcd_puts_scroll(0, 0, buffer); | ||
250 | return(1); | ||
251 | } | ||
252 | switch(cchr1[0]) | ||
253 | { | ||
254 | case '%': | ||
255 | i = read(fd, cchr2, 1); | ||
256 | if(i <= 0) | ||
257 | { | ||
258 | close(fd); | ||
259 | lcd_puts_scroll(0, 0, buffer); | ||
260 | return(1); | ||
261 | } | ||
262 | switch(cchr2[0]) | ||
263 | { | ||
264 | case 't': /* ID3 Title */ | ||
265 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", id3->title); | ||
266 | break; | ||
267 | case 'a': /* ID3 Artist */ | ||
268 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", id3->artist); | ||
269 | break; | ||
270 | case 'n': /* ID3 Track Number */ | ||
271 | snprintf(tmpbuf, sizeof(tmpbuf), "%d", id3->tracknum); | ||
272 | break; | ||
273 | case 'u': /* ID3 Album */ | ||
274 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", id3->album); | ||
275 | break; | ||
276 | case 'c': /* Conditional Filename \ ID3 Artist-Title */ | ||
277 | if(id3->artist && id3->title) | ||
278 | snprintf(tmpbuf, sizeof(tmpbuf), "%s - %s", | ||
279 | id3->artist?id3->artist:"<no artist>", | ||
280 | id3->title?id3->title:"<no title>"); | ||
281 | else | ||
282 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", | ||
283 | szLast?++szLast:id3->path); | ||
284 | break; | ||
285 | case 'b': /* File Bitrate */ | ||
286 | snprintf(tmpbuf, sizeof(tmpbuf), "%d", id3->bitrate); | ||
287 | break; | ||
288 | case 'f': /* File Frequency */ | ||
289 | snprintf(tmpbuf, sizeof(tmpbuf), "%d", id3->frequency); | ||
290 | break; | ||
291 | case 'p': /* File Path */ | ||
292 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", id3->path); | ||
293 | break; | ||
294 | case 'm': /* File Name */ | ||
295 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", | ||
296 | szLast?++szLast:id3->path); | ||
297 | break; | ||
298 | case 's': /* File Size (In Kilobytes) */ | ||
299 | snprintf(tmpbuf, sizeof(tmpbuf), "%d", | ||
300 | id3->filesize / 1024); | ||
301 | break; | ||
302 | case 'i': /* Playlist Position */ | ||
303 | snprintf(tmpbuf, sizeof(tmpbuf), "%d", id3->index + 1); | ||
304 | break; | ||
305 | case 'l': /* Playlist Total Entries */ | ||
306 | snprintf(tmpbuf, sizeof(tmpbuf), "%d", playlist.amount); | ||
307 | break; | ||
308 | case 'e': /* Elapsed Time */ | ||
309 | snprintf(tmpbuf, sizeof(tmpbuf), "%d:%02d", | ||
310 | id3->elapsed / 60000, | ||
311 | id3->elapsed % 60000 / 1000); | ||
312 | break; | ||
313 | case 'o': /* Total Time */ | ||
314 | snprintf(tmpbuf, sizeof(tmpbuf), "%d:%02d", | ||
315 | id3->elapsed / 60000, | ||
316 | id3->elapsed % 60000 / 1000); | ||
317 | break; | ||
318 | |||
319 | } | ||
320 | break; | ||
321 | default: | ||
322 | snprintf(tmpbuf, sizeof(tmpbuf), "%s", cchr1); | ||
323 | break; | ||
324 | } | ||
325 | snprintf(buffer, sizeof(buffer), "%s%s", buffer, tmpbuf); | ||
326 | } | ||
327 | } | ||
328 | |||
329 | |||
216 | int player_id3_show(void) | 330 | int player_id3_show(void) |
217 | { | 331 | { |
218 | #ifdef HAVE_PLAYER_KEYPAD | 332 | #ifdef HAVE_PLAYER_KEYPAD |
@@ -358,6 +472,7 @@ static void display_file_time(unsigned int elapsed, unsigned int length) | |||
358 | the screen has room. */ | 472 | the screen has room. */ |
359 | if ((global_settings.wps_display == PLAY_DISPLAY_FILENAME_SCROLL) || | 473 | if ((global_settings.wps_display == PLAY_DISPLAY_FILENAME_SCROLL) || |
360 | global_settings.wps_display == PLAY_DISPLAY_1LINEID3 || | 474 | global_settings.wps_display == PLAY_DISPLAY_1LINEID3 || |
475 | global_settings.wps_display == PLAY_DISPLAY_CUSTOM_WPS || | ||
361 | ff_rewind) | 476 | ff_rewind) |
362 | { | 477 | { |
363 | snprintf(buffer,sizeof(buffer), "%d:%02d/%d:%02d ", | 478 | snprintf(buffer,sizeof(buffer), "%d:%02d/%d:%02d ", |