diff options
-rw-r--r-- | apps/recorder/icons.c | 2 | ||||
-rw-r--r-- | apps/recorder/icons.h | 2 | ||||
-rw-r--r-- | apps/tree.c | 48 | ||||
-rw-r--r-- | apps/wps-display.c | 240 | ||||
-rw-r--r-- | apps/wps-display.h | 1 |
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] = { 0x00, 0x1c, 0x3e, 0x3e, 0x3e, 0x1c }, /* Cursor / Marker */ { 0x3e, 0x1c, 0x08, 0x00, 0x00, 0x00 }, + /* WPS file */ + { 0x03, 0x3a, 0x9b, 0xe0, 0x20, 0x00 }, }; static 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 @@ enum icons_6x8 { Box_Filled, Box_Empty, Slider_Horizontal, File, Folder, Directory, Playlist, Repeat, - Selected, Cursor, LastIcon + Selected, Cursor, Wps, LastIcon }; extern 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 @@ #include "playlist.h" #include "menu.h" #include "wps.h" +#include "wps-display.h" #include "settings.h" #include "status.h" #include "debug.h" @@ -297,15 +298,17 @@ static int showdir(char *path, int start) icon_type = Playlist; else if ( dircache[i].attr & TREE_ATTR_MPA ) icon_type = File; + else if (!strcasecmp(&dircache[i].name[len-4], ".wps")) + icon_type = Wps; else icon_type = 0; if (icon_type) lcd_bitmap(bitmap_icons_6x8[icon_type], - CURSOR_X * 6 + CURSOR_WIDTH, MARGIN_Y+(i-start)*line_height, 6, 8, true); + CURSOR_X * 6 + CURSOR_WIDTH, + MARGIN_Y+(i-start)*line_height, 6, 8, true); #endif - /* if MP3 filter is on, cut off the extension */ if (global_settings.mp3filter && (dircache[i].attr & (TREE_ATTR_M3U|TREE_ATTR_MPA))) @@ -466,6 +469,8 @@ bool dirbrowse(char *root) put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); while(1) { + struct entry* file = &dircache[dircursor+start]; + bool restore = false; button = button_get_w_tmo(HZ/5); @@ -514,19 +519,17 @@ bool dirbrowse(char *root) case TREE_ENTER | BUTTON_REPEAT: #ifdef HAVE_RECORDER_KEYPAD case BUTTON_PLAY: - case BUTTON_PLAY | BUTTON_REPEAT: + case BUTTON_PLAY | BUTTON_REPEAT: #endif if ( !numentries ) break; if ((currdir[0]=='/') && (currdir[1]==0)) { - snprintf(buf,sizeof(buf),"%s%s",currdir, - dircache[dircursor+start].name); + snprintf(buf,sizeof(buf),"%s%s",currdir, file->name); } else { - snprintf(buf,sizeof(buf),"%s/%s",currdir, - dircache[dircursor+start].name); + snprintf(buf,sizeof(buf),"%s/%s",currdir, file->name); } - if (dircache[dircursor+start].attr & ATTR_DIRECTORY) { + if (file->attr & ATTR_DIRECTORY) { memcpy(currdir,buf,sizeof(currdir)); if ( dirlevel < MAX_DIR_LEVELS ) { dirpos[dirlevel] = start; @@ -538,21 +541,16 @@ bool dirbrowse(char *root) } else { int seed = current_tick; lcd_stop_scroll(); - if(dircache[dircursor+start].attr & TREE_ATTR_M3U ) + if (file->attr & TREE_ATTR_M3U ) { if ( global_settings.resume ) snprintf(global_settings.resume_file, MAX_PATH, "%s/%s", - currdir, - dircache[dircursor+start].name); - play_list(currdir, - dircache[dircursor+start].name, - 0, - false, - 0, seed ); + currdir, file->name); + play_list(currdir, file->name, 0, false, 0, seed ); start_index = 0; } - else if (dircache[dircursor+start].attr & TREE_ATTR_MPA ) { + else if (file->attr & TREE_ATTR_MPA ) { if ( global_settings.resume ) strncpy(global_settings.resume_file, currdir, MAX_PATH); @@ -563,9 +561,19 @@ bool dirbrowse(char *root) start_index = play_list(currdir, NULL, start_index, false, 0, seed); } - else - break; - + else { + /* wps config file? */ + int len = strlen(file->name); + if (!strcasecmp(&file->name[len-4], ".wps")) { + snprintf(buf, sizeof buf, "%s/%s", + currdir, file->name); + wps_load_custom(buf); + restore = true; + break; + } + else + break; + } if ( global_settings.resume ) { /* the resume_index must always be the index in the 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 @@ #include "ajf.h" #endif -#define WPS_CONFIG ROCKBOX_DIR "/wps.config" +#define WPS_CONFIG ROCKBOX_DIR "/default.wps" +#ifdef HAVE_LCD_BITMAP #define MAX_LINES 10 +#else +#define MAX_LINES 2 +#endif + #define FORMAT_BUFFER_SIZE 300 struct format_flags @@ -103,12 +108,19 @@ static void wps_format(char* fmt) } } -static bool load_custom_wps(void) +bool wps_load_custom(char* file) { char buffer[FORMAT_BUFFER_SIZE]; int fd; + bool special = true; + + /* default wps file? */ + if (!file) { + file = WPS_CONFIG; + special = false; + } - fd = open(WPS_CONFIG, O_RDONLY); + fd = open(file, O_RDONLY); if (-1 != fd) { @@ -121,6 +133,17 @@ static bool load_custom_wps(void) } close(fd); + + if ( special ) { + int i; + lcd_clear_display(); + lcd_setmargins(0,0); + for (i=0; i<MAX_LINES && format_lines[i]; i++) + lcd_puts(0,i,format_lines[i]); + lcd_update(); + sleep(HZ); + } + return numread > 0; } @@ -195,8 +218,11 @@ static char* get_dir(char* buf, int buf_size, char* path, int level) * * Returns the tag. NULL indicates the tag wasn't available. */ -static char* get_tag(struct mp3entry* id3, char* tag, char* buf, int buf_size, - struct format_flags* flags) +static char* get_tag(struct mp3entry* id3, + char* tag, + char* buf, + int buf_size, + struct format_flags* flags) { if ((0 == tag[0]) || (0 == tag[1])) { @@ -205,122 +231,122 @@ static char* get_tag(struct mp3entry* id3, char* tag, char* buf, int buf_size, switch (tag[0]) { - case 'i': /* ID3 Information */ - switch (tag[1]) - { - case 't': /* ID3 Title */ - return id3->title; + case 'i': /* ID3 Information */ + switch (tag[1]) + { + case 't': /* ID3 Title */ + return id3->title; - case 'a': /* ID3 Artist */ - return id3->artist; + case 'a': /* ID3 Artist */ + return id3->artist; - case 'n': /* ID3 Track Number */ - if (id3->tracknum) - { - snprintf(buf, buf_size, "%d", id3->tracknum); - return buf; + case 'n': /* ID3 Track Number */ + if (id3->tracknum) + { + snprintf(buf, buf_size, "%d", id3->tracknum); + return buf; + } + else + { + return NULL; + } + + case 'd': /* ID3 Album/Disc */ + return id3->album; } - else - { - return NULL; - } - - case 'd': /* ID3 Album/Disc */ - return id3->album; - } - break; - - case 'f': /* File Information */ - switch(tag[1]) - { - case 'v': /* VBR file? */ - return id3->vbr ? "(avg)" : NULL; - - case 'b': /* File Bitrate */ - snprintf(buf, buf_size, "%d", id3->bitrate); - return buf; - - case 'f': /* File Frequency */ - snprintf(buf, buf_size, "%d", id3->frequency); - return buf; - - case 'p': /* File Path */ - return id3->path; - - case 'm': /* File Name - With Extension */ - return get_dir(buf, buf_size, id3->path, 0); - - case 'n': /* File Name */ - if (get_dir(buf, buf_size, id3->path, 0)) - { - /* Remove extension */ - char* sep = strrchr(buf, '.'); - - if (NULL != sep) - { - *sep = 0; - } + break; - return buf; - } - else + case 'f': /* File Information */ + switch(tag[1]) { - return NULL; + case 'v': /* VBR file? */ + return id3->vbr ? "(avg)" : NULL; + + case 'b': /* File Bitrate */ + snprintf(buf, buf_size, "%d", id3->bitrate); + return buf; + + case 'f': /* File Frequency */ + snprintf(buf, buf_size, "%d", id3->frequency); + return buf; + + case 'p': /* File Path */ + return id3->path; + + case 'm': /* File Name - With Extension */ + return get_dir(buf, buf_size, id3->path, 0); + + case 'n': /* File Name */ + if (get_dir(buf, buf_size, id3->path, 0)) + { + /* Remove extension */ + char* sep = strrchr(buf, '.'); + + if (NULL != sep) + { + *sep = 0; + } + + return buf; + } + else + { + return NULL; + } + + case 's': /* File Size (in kilobytes) */ + snprintf(buf, buf_size, "%d", id3->filesize / 1024); + return buf; } + break; - case 's': /* File Size (in kilobytes) */ - snprintf(buf, buf_size, "%d", id3->filesize / 1024); - return buf; - } - break; - - case 'p': /* Playlist/Song Information */ - switch(tag[1]) - { + case 'p': /* Playlist/Song Information */ + switch(tag[1]) + { #if defined(HAVE_LCD_CHARCELLS) && !defined(SIMULATOR) - case 'b': /* Player progress bar */ - flags->player_progress = true; - flags->dynamic = true; - return "\x01"; + case 'b': /* Player progress bar */ + flags->player_progress = true; + flags->dynamic = true; + return "\x01"; #endif - case 'p': /* Playlist Position */ - snprintf(buf, buf_size, "%d", id3->index + 1); - return buf; + case 'p': /* Playlist Position */ + snprintf(buf, buf_size, "%d", id3->index + 1); + return buf; - case 'e': /* Playlist Total Entries */ - snprintf(buf, buf_size, "%d", playlist.amount); - return buf; + case 'e': /* Playlist Total Entries */ + snprintf(buf, buf_size, "%d", playlist.amount); + return buf; - case 'c': /* Current Time in Song */ - flags->dynamic = true; - format_time(buf, buf_size, id3->elapsed + ff_rewind_count); - return buf; + case 'c': /* Current Time in Song */ + flags->dynamic = true; + format_time(buf, buf_size, id3->elapsed + ff_rewind_count); + return buf; - case 'r': /* Remaining Time in Song */ - flags->dynamic = true; - format_time(buf, buf_size, id3->length - id3->elapsed + ff_rewind_count); - return buf; + case 'r': /* Remaining Time in Song */ + flags->dynamic = true; + format_time(buf, buf_size, id3->length - id3->elapsed + ff_rewind_count); + return buf; - case 't': /* Total Time */ - format_time(buf, buf_size, id3->length); - return buf; - } - break; + case 't': /* Total Time */ + format_time(buf, buf_size, id3->length); + return buf; + } + break; - case 'd': /* Directory path information */ - switch(tag[1]) - { - case '1': /* Parent folder */ - return get_dir(buf, buf_size, id3->path, 1); + case 'd': /* Directory path information */ + switch(tag[1]) + { + case '1': /* Parent folder */ + return get_dir(buf, buf_size, id3->path, 1); - case '2': /* Parent of parent */ - return get_dir(buf, buf_size, id3->path, 2); + case '2': /* Parent of parent */ + return get_dir(buf, buf_size, id3->path, 2); - case '3': /* Parent of parent of parent */ - return get_dir(buf, buf_size, id3->path, 3); - } - break; + case '3': /* Parent of parent of parent */ + return get_dir(buf, buf_size, id3->path, 3); + } + break; } return NULL; @@ -507,11 +533,7 @@ bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_all) ff_rewind_count = ffwd_offset; -#ifdef HAVE_LCD_CHARCELL - for (i = 0; i < 2; i++) -#else for (i = 0; i < MAX_LINES; i++) -#endif { if ( !format_lines[i] ) break; @@ -586,7 +608,7 @@ void wps_display(struct mp3entry* id3) static bool wps_loaded = false; if (!wps_loaded) { - load_custom_wps(); + wps_load_custom(NULL); wps_loaded = true; 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 @@ bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_scroll); void wps_display(struct mp3entry* id3); +bool wps_load_custom(char* file); #ifdef HAVE_LCD_CHARCELLS bool draw_player_progress(struct mp3entry* id3, int ff_rewind_count); |