summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/recorder/icons.c2
-rw-r--r--apps/recorder/icons.h2
-rw-r--r--apps/tree.c48
-rw-r--r--apps/wps-display.c240
-rw-r--r--apps/wps-display.h1
5 files changed, 163 insertions, 130 deletions
diff --git a/apps/recorder/icons.c b/apps/recorder/icons.c
index 22233b6c84..f1aa0aaab2 100644
--- a/apps/recorder/icons.c
+++ b/apps/recorder/icons.c
@@ -64,6 +64,8 @@ unsigned char bitmap_icons_6x8[LastIcon][6] =
64 { 0x00, 0x1c, 0x3e, 0x3e, 0x3e, 0x1c }, 64 { 0x00, 0x1c, 0x3e, 0x3e, 0x3e, 0x1c },
65 /* Cursor / Marker */ 65 /* Cursor / Marker */
66 { 0x3e, 0x1c, 0x08, 0x00, 0x00, 0x00 }, 66 { 0x3e, 0x1c, 0x08, 0x00, 0x00, 0x00 },
67 /* WPS file */
68 { 0x03, 0x3a, 0x9b, 0xe0, 0x20, 0x00 },
67}; 69};
68 70
69static unsigned char bitmap_icon_7x8[][7] = 71static unsigned char bitmap_icon_7x8[][7] =
diff --git a/apps/recorder/icons.h b/apps/recorder/icons.h
index 8f12528063..22589c8c29 100644
--- a/apps/recorder/icons.h
+++ b/apps/recorder/icons.h
@@ -27,7 +27,7 @@
27enum icons_6x8 { 27enum icons_6x8 {
28 Box_Filled, Box_Empty, Slider_Horizontal, File, 28 Box_Filled, Box_Empty, Slider_Horizontal, File,
29 Folder, Directory, Playlist, Repeat, 29 Folder, Directory, Playlist, Repeat,
30 Selected, Cursor, LastIcon 30 Selected, Cursor, Wps, LastIcon
31}; 31};
32 32
33extern unsigned char bitmap_icons_6x8[LastIcon][6]; 33extern unsigned char bitmap_icons_6x8[LastIcon][6];
diff --git a/apps/tree.c b/apps/tree.c
index 1d615101fe..639e522978 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -37,6 +37,7 @@
37#include "playlist.h" 37#include "playlist.h"
38#include "menu.h" 38#include "menu.h"
39#include "wps.h" 39#include "wps.h"
40#include "wps-display.h"
40#include "settings.h" 41#include "settings.h"
41#include "status.h" 42#include "status.h"
42#include "debug.h" 43#include "debug.h"
@@ -297,15 +298,17 @@ static int showdir(char *path, int start)
297 icon_type = Playlist; 298 icon_type = Playlist;
298 else if ( dircache[i].attr & TREE_ATTR_MPA ) 299 else if ( dircache[i].attr & TREE_ATTR_MPA )
299 icon_type = File; 300 icon_type = File;
301 else if (!strcasecmp(&dircache[i].name[len-4], ".wps"))
302 icon_type = Wps;
300 else 303 else
301 icon_type = 0; 304 icon_type = 0;
302 305
303 if (icon_type) 306 if (icon_type)
304 lcd_bitmap(bitmap_icons_6x8[icon_type], 307 lcd_bitmap(bitmap_icons_6x8[icon_type],
305 CURSOR_X * 6 + CURSOR_WIDTH, MARGIN_Y+(i-start)*line_height, 6, 8, true); 308 CURSOR_X * 6 + CURSOR_WIDTH,
309 MARGIN_Y+(i-start)*line_height, 6, 8, true);
306#endif 310#endif
307 311
308
309 /* if MP3 filter is on, cut off the extension */ 312 /* if MP3 filter is on, cut off the extension */
310 if (global_settings.mp3filter && 313 if (global_settings.mp3filter &&
311 (dircache[i].attr & (TREE_ATTR_M3U|TREE_ATTR_MPA))) 314 (dircache[i].attr & (TREE_ATTR_M3U|TREE_ATTR_MPA)))
@@ -466,6 +469,8 @@ bool dirbrowse(char *root)
466 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); 469 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
467 470
468 while(1) { 471 while(1) {
472 struct entry* file = &dircache[dircursor+start];
473
469 bool restore = false; 474 bool restore = false;
470 475
471 button = button_get_w_tmo(HZ/5); 476 button = button_get_w_tmo(HZ/5);
@@ -514,19 +519,17 @@ bool dirbrowse(char *root)
514 case TREE_ENTER | BUTTON_REPEAT: 519 case TREE_ENTER | BUTTON_REPEAT:
515#ifdef HAVE_RECORDER_KEYPAD 520#ifdef HAVE_RECORDER_KEYPAD
516 case BUTTON_PLAY: 521 case BUTTON_PLAY:
517 case BUTTON_PLAY | BUTTON_REPEAT: 522 case BUTTON_PLAY | BUTTON_REPEAT:
518#endif 523#endif
519 if ( !numentries ) 524 if ( !numentries )
520 break; 525 break;
521 if ((currdir[0]=='/') && (currdir[1]==0)) { 526 if ((currdir[0]=='/') && (currdir[1]==0)) {
522 snprintf(buf,sizeof(buf),"%s%s",currdir, 527 snprintf(buf,sizeof(buf),"%s%s",currdir, file->name);
523 dircache[dircursor+start].name);
524 } else { 528 } else {
525 snprintf(buf,sizeof(buf),"%s/%s",currdir, 529 snprintf(buf,sizeof(buf),"%s/%s",currdir, file->name);
526 dircache[dircursor+start].name);
527 } 530 }
528 531
529 if (dircache[dircursor+start].attr & ATTR_DIRECTORY) { 532 if (file->attr & ATTR_DIRECTORY) {
530 memcpy(currdir,buf,sizeof(currdir)); 533 memcpy(currdir,buf,sizeof(currdir));
531 if ( dirlevel < MAX_DIR_LEVELS ) { 534 if ( dirlevel < MAX_DIR_LEVELS ) {
532 dirpos[dirlevel] = start; 535 dirpos[dirlevel] = start;
@@ -538,21 +541,16 @@ bool dirbrowse(char *root)
538 } else { 541 } else {
539 int seed = current_tick; 542 int seed = current_tick;
540 lcd_stop_scroll(); 543 lcd_stop_scroll();
541 if(dircache[dircursor+start].attr & TREE_ATTR_M3U ) 544 if (file->attr & TREE_ATTR_M3U )
542 { 545 {
543 if ( global_settings.resume ) 546 if ( global_settings.resume )
544 snprintf(global_settings.resume_file, 547 snprintf(global_settings.resume_file,
545 MAX_PATH, "%s/%s", 548 MAX_PATH, "%s/%s",
546 currdir, 549 currdir, file->name);
547 dircache[dircursor+start].name); 550 play_list(currdir, file->name, 0, false, 0, seed );
548 play_list(currdir,
549 dircache[dircursor+start].name,
550 0,
551 false,
552 0, seed );
553 start_index = 0; 551 start_index = 0;
554 } 552 }
555 else if (dircache[dircursor+start].attr & TREE_ATTR_MPA ) { 553 else if (file->attr & TREE_ATTR_MPA ) {
556 if ( global_settings.resume ) 554 if ( global_settings.resume )
557 strncpy(global_settings.resume_file, 555 strncpy(global_settings.resume_file,
558 currdir, MAX_PATH); 556 currdir, MAX_PATH);
@@ -563,9 +561,19 @@ bool dirbrowse(char *root)
563 start_index = play_list(currdir, NULL, 561 start_index = play_list(currdir, NULL,
564 start_index, false, 0, seed); 562 start_index, false, 0, seed);
565 } 563 }
566 else 564 else {
567 break; 565 /* wps config file? */
568 566 int len = strlen(file->name);
567 if (!strcasecmp(&file->name[len-4], ".wps")) {
568 snprintf(buf, sizeof buf, "%s/%s",
569 currdir, file->name);
570 wps_load_custom(buf);
571 restore = true;
572 break;
573 }
574 else
575 break;
576 }
569 if ( global_settings.resume ) { 577 if ( global_settings.resume ) {
570 /* the resume_index must always be the index in the 578 /* the resume_index must always be the index in the
571 shuffled list in case shuffle is enabled */ 579 shuffled list in case shuffle is enabled */
diff --git a/apps/wps-display.c b/apps/wps-display.c
index c360b7cf70..18a85cdc0f 100644
--- a/apps/wps-display.c
+++ b/apps/wps-display.c
@@ -46,9 +46,14 @@
46#include "ajf.h" 46#include "ajf.h"
47#endif 47#endif
48 48
49#define WPS_CONFIG ROCKBOX_DIR "/wps.config" 49#define WPS_CONFIG ROCKBOX_DIR "/default.wps"
50 50
51#ifdef HAVE_LCD_BITMAP
51#define MAX_LINES 10 52#define MAX_LINES 10
53#else
54#define MAX_LINES 2
55#endif
56
52#define FORMAT_BUFFER_SIZE 300 57#define FORMAT_BUFFER_SIZE 300
53 58
54struct format_flags 59struct format_flags
@@ -103,12 +108,19 @@ static void wps_format(char* fmt)
103 } 108 }
104} 109}
105 110
106static bool load_custom_wps(void) 111bool wps_load_custom(char* file)
107{ 112{
108 char buffer[FORMAT_BUFFER_SIZE]; 113 char buffer[FORMAT_BUFFER_SIZE];
109 int fd; 114 int fd;
115 bool special = true;
116
117 /* default wps file? */
118 if (!file) {
119 file = WPS_CONFIG;
120 special = false;
121 }
110 122
111 fd = open(WPS_CONFIG, O_RDONLY); 123 fd = open(file, O_RDONLY);
112 124
113 if (-1 != fd) 125 if (-1 != fd)
114 { 126 {
@@ -121,6 +133,17 @@ static bool load_custom_wps(void)
121 } 133 }
122 134
123 close(fd); 135 close(fd);
136
137 if ( special ) {
138 int i;
139 lcd_clear_display();
140 lcd_setmargins(0,0);
141 for (i=0; i<MAX_LINES && format_lines[i]; i++)
142 lcd_puts(0,i,format_lines[i]);
143 lcd_update();
144 sleep(HZ);
145 }
146
124 return numread > 0; 147 return numread > 0;
125 } 148 }
126 149
@@ -195,8 +218,11 @@ static char* get_dir(char* buf, int buf_size, char* path, int level)
195 * 218 *
196 * Returns the tag. NULL indicates the tag wasn't available. 219 * Returns the tag. NULL indicates the tag wasn't available.
197 */ 220 */
198static char* get_tag(struct mp3entry* id3, char* tag, char* buf, int buf_size, 221static char* get_tag(struct mp3entry* id3,
199 struct format_flags* flags) 222 char* tag,
223 char* buf,
224 int buf_size,
225 struct format_flags* flags)
200{ 226{
201 if ((0 == tag[0]) || (0 == tag[1])) 227 if ((0 == tag[0]) || (0 == tag[1]))
202 { 228 {
@@ -205,122 +231,122 @@ static char* get_tag(struct mp3entry* id3, char* tag, char* buf, int buf_size,
205 231
206 switch (tag[0]) 232 switch (tag[0])
207 { 233 {
208 case 'i': /* ID3 Information */ 234 case 'i': /* ID3 Information */
209 switch (tag[1]) 235 switch (tag[1])
210 { 236 {
211 case 't': /* ID3 Title */ 237 case 't': /* ID3 Title */
212 return id3->title; 238 return id3->title;
213 239
214 case 'a': /* ID3 Artist */ 240 case 'a': /* ID3 Artist */
215 return id3->artist; 241 return id3->artist;
216 242
217 case 'n': /* ID3 Track Number */ 243 case 'n': /* ID3 Track Number */
218 if (id3->tracknum) 244 if (id3->tracknum)
219 { 245 {
220 snprintf(buf, buf_size, "%d", id3->tracknum); 246 snprintf(buf, buf_size, "%d", id3->tracknum);
221 return buf; 247 return buf;
248 }
249 else
250 {
251 return NULL;
252 }
253
254 case 'd': /* ID3 Album/Disc */
255 return id3->album;
222 } 256 }
223 else 257 break;
224 {
225 return NULL;
226 }
227
228 case 'd': /* ID3 Album/Disc */
229 return id3->album;
230 }
231 break;
232
233 case 'f': /* File Information */
234 switch(tag[1])
235 {
236 case 'v': /* VBR file? */
237 return id3->vbr ? "(avg)" : NULL;
238
239 case 'b': /* File Bitrate */
240 snprintf(buf, buf_size, "%d", id3->bitrate);
241 return buf;
242
243 case 'f': /* File Frequency */
244 snprintf(buf, buf_size, "%d", id3->frequency);
245 return buf;
246
247 case 'p': /* File Path */
248 return id3->path;
249
250 case 'm': /* File Name - With Extension */
251 return get_dir(buf, buf_size, id3->path, 0);
252
253 case 'n': /* File Name */
254 if (get_dir(buf, buf_size, id3->path, 0))
255 {
256 /* Remove extension */
257 char* sep = strrchr(buf, '.');
258
259 if (NULL != sep)
260 {
261 *sep = 0;
262 }
263 258
264 return buf; 259 case 'f': /* File Information */
265 } 260 switch(tag[1])
266 else
267 { 261 {
268 return NULL; 262 case 'v': /* VBR file? */
263 return id3->vbr ? "(avg)" : NULL;
264
265 case 'b': /* File Bitrate */
266 snprintf(buf, buf_size, "%d", id3->bitrate);
267 return buf;
268
269 case 'f': /* File Frequency */
270 snprintf(buf, buf_size, "%d", id3->frequency);
271 return buf;
272
273 case 'p': /* File Path */
274 return id3->path;
275
276 case 'm': /* File Name - With Extension */
277 return get_dir(buf, buf_size, id3->path, 0);
278
279 case 'n': /* File Name */
280 if (get_dir(buf, buf_size, id3->path, 0))
281 {
282 /* Remove extension */
283 char* sep = strrchr(buf, '.');
284
285 if (NULL != sep)
286 {
287 *sep = 0;
288 }
289
290 return buf;
291 }
292 else
293 {
294 return NULL;
295 }
296
297 case 's': /* File Size (in kilobytes) */
298 snprintf(buf, buf_size, "%d", id3->filesize / 1024);
299 return buf;
269 } 300 }
301 break;
270 302
271 case 's': /* File Size (in kilobytes) */ 303 case 'p': /* Playlist/Song Information */
272 snprintf(buf, buf_size, "%d", id3->filesize / 1024); 304 switch(tag[1])
273 return buf; 305 {
274 }
275 break;
276
277 case 'p': /* Playlist/Song Information */
278 switch(tag[1])
279 {
280#if defined(HAVE_LCD_CHARCELLS) && !defined(SIMULATOR) 306#if defined(HAVE_LCD_CHARCELLS) && !defined(SIMULATOR)
281 case 'b': /* Player progress bar */ 307 case 'b': /* Player progress bar */
282 flags->player_progress = true; 308 flags->player_progress = true;
283 flags->dynamic = true; 309 flags->dynamic = true;
284 return "\x01"; 310 return "\x01";
285#endif 311#endif
286 312
287 case 'p': /* Playlist Position */ 313 case 'p': /* Playlist Position */
288 snprintf(buf, buf_size, "%d", id3->index + 1); 314 snprintf(buf, buf_size, "%d", id3->index + 1);
289 return buf; 315 return buf;
290 316
291 case 'e': /* Playlist Total Entries */ 317 case 'e': /* Playlist Total Entries */
292 snprintf(buf, buf_size, "%d", playlist.amount); 318 snprintf(buf, buf_size, "%d", playlist.amount);
293 return buf; 319 return buf;
294 320
295 case 'c': /* Current Time in Song */ 321 case 'c': /* Current Time in Song */
296 flags->dynamic = true; 322 flags->dynamic = true;
297 format_time(buf, buf_size, id3->elapsed + ff_rewind_count); 323 format_time(buf, buf_size, id3->elapsed + ff_rewind_count);
298 return buf; 324 return buf;
299 325
300 case 'r': /* Remaining Time in Song */ 326 case 'r': /* Remaining Time in Song */
301 flags->dynamic = true; 327 flags->dynamic = true;
302 format_time(buf, buf_size, id3->length - id3->elapsed + ff_rewind_count); 328 format_time(buf, buf_size, id3->length - id3->elapsed + ff_rewind_count);
303 return buf; 329 return buf;
304 330
305 case 't': /* Total Time */ 331 case 't': /* Total Time */
306 format_time(buf, buf_size, id3->length); 332 format_time(buf, buf_size, id3->length);
307 return buf; 333 return buf;
308 } 334 }
309 break; 335 break;
310 336
311 case 'd': /* Directory path information */ 337 case 'd': /* Directory path information */
312 switch(tag[1]) 338 switch(tag[1])
313 { 339 {
314 case '1': /* Parent folder */ 340 case '1': /* Parent folder */
315 return get_dir(buf, buf_size, id3->path, 1); 341 return get_dir(buf, buf_size, id3->path, 1);
316 342
317 case '2': /* Parent of parent */ 343 case '2': /* Parent of parent */
318 return get_dir(buf, buf_size, id3->path, 2); 344 return get_dir(buf, buf_size, id3->path, 2);
319 345
320 case '3': /* Parent of parent of parent */ 346 case '3': /* Parent of parent of parent */
321 return get_dir(buf, buf_size, id3->path, 3); 347 return get_dir(buf, buf_size, id3->path, 3);
322 } 348 }
323 break; 349 break;
324 } 350 }
325 351
326 return NULL; 352 return NULL;
@@ -507,11 +533,7 @@ bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_all)
507 533
508 ff_rewind_count = ffwd_offset; 534 ff_rewind_count = ffwd_offset;
509 535
510#ifdef HAVE_LCD_CHARCELL
511 for (i = 0; i < 2; i++)
512#else
513 for (i = 0; i < MAX_LINES; i++) 536 for (i = 0; i < MAX_LINES; i++)
514#endif
515 { 537 {
516 if ( !format_lines[i] ) 538 if ( !format_lines[i] )
517 break; 539 break;
@@ -586,7 +608,7 @@ void wps_display(struct mp3entry* id3)
586 static bool wps_loaded = false; 608 static bool wps_loaded = false;
587 609
588 if (!wps_loaded) { 610 if (!wps_loaded) {
589 load_custom_wps(); 611 wps_load_custom(NULL);
590 wps_loaded = true; 612 wps_loaded = true;
591 613
592 if ( !format_buffer[0] ) { 614 if ( !format_buffer[0] ) {
diff --git a/apps/wps-display.h b/apps/wps-display.h
index 932970d997..a62817edad 100644
--- a/apps/wps-display.h
+++ b/apps/wps-display.h
@@ -24,6 +24,7 @@
24 24
25bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_scroll); 25bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_scroll);
26void wps_display(struct mp3entry* id3); 26void wps_display(struct mp3entry* id3);
27bool wps_load_custom(char* file);
27 28
28#ifdef HAVE_LCD_CHARCELLS 29#ifdef HAVE_LCD_CHARCELLS
29bool draw_player_progress(struct mp3entry* id3, int ff_rewind_count); 30bool draw_player_progress(struct mp3entry* id3, int ff_rewind_count);