From 9b62c23d8f59483961355fbd2841d3a2d4e0616b Mon Sep 17 00:00:00 2001 From: Justin Heiner Date: Fri, 30 Aug 2002 07:11:18 +0000 Subject: Got rid of the old WPS, and use Custom WPS as the method of WPS updating. Also working on a player progress bar (using a custom character). That is now able to be #included with -DPLAYER_PROGRESS in the apps/Makefile git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2074 a1c6a512-1295-4272-9138-f99709370657 --- apps/settings_menu.c | 12 --- apps/wps.c | 210 +++++++++++---------------------------------------- apps/wps.h | 4 +- 3 files changed, 45 insertions(+), 181 deletions(-) (limited to 'apps') diff --git a/apps/settings_menu.c b/apps/settings_menu.c index 33dee69aea..977c5cd2d0 100644 --- a/apps/settings_menu.c +++ b/apps/settings_menu.c @@ -97,24 +97,12 @@ static Menu scroll_speed(void) static Menu wps_set(void) { #ifdef HAVE_LCD_BITMAP -#ifdef CUSTOM_WPS char* names[] = { "ID3 Tags", "File ", "Parse ", "Custom WPS " }; set_option("[WPS display]", &global_settings.wps_display, names, 4 ); #else - char* names[] = { "ID3 Tags", "File ", "Parse " }; - set_option("[WPS display]", &global_settings.wps_display, names, 3 ); -#endif -#else -#ifdef CUSTOM_WPS char* names[] = { "1 Line ID3", "2 Line ID3", "File ", "Parse ", "Custom WPS " }; set_option("[WPS display]", &global_settings.wps_display, names, 5 ); -#else - char* names[] = { "1 Line ID3", "2 Line ID3", "File ", - "Parse " }; - set_option("[WPS display]", &global_settings.wps_display, names, 4 ); -#endif - #endif return MENU_OK; } 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; static struct mp3entry* id3 = NULL; static int old_release_mask; -#ifdef CUSTOM_WPS static char custom_wps[5][64]; static char wps_display[5][64]; static int scroll_line; static int scroll_line_custom; -#endif static void draw_screen(void) { @@ -105,7 +103,6 @@ static void draw_screen(void) } else { -#ifdef CUSTOM_WPS static int last_wps = -1; if ((last_wps != global_settings.wps_display && global_settings.wps_display == PLAY_DISPLAY_CUSTOM_WPS)) @@ -113,7 +110,7 @@ static void draw_screen(void) load_custom_wps(); last_wps = global_settings.wps_display; } -#endif + switch ( global_settings.wps_display ) { case PLAY_DISPLAY_TRACK_TITLE: { @@ -124,9 +121,7 @@ static void draw_screen(void) char* szPeriod; char szArtist[26]; char szBuff[257]; -#ifdef CUSTOM_WPS int tmpcnt = 0; -#endif szBuff[sizeof(szBuff)-1] = 0; strncpy(szBuff, id3->path, sizeof(szBuff)); @@ -144,7 +139,7 @@ static void draw_screen(void) szPeriod = strrchr(szDelimit, '.'); if (szPeriod != NULL) *szPeriod = 0; -#ifdef CUSTOM_WPS + snprintf(wps_display[0],sizeof(wps_display[0]),"%s", (++szDelimit)); #ifdef HAVE_LCD_CHARCELLS @@ -155,14 +150,10 @@ static void draw_screen(void) wps_display[tmpcnt][0] = 0; scroll_line = 0; refresh_wps(false); -#else - lcd_puts_scroll(0, 1, (++szDelimit)); -#endif break; } case PLAY_DISPLAY_FILENAME_SCROLL: { -#ifdef CUSTOM_WPS snprintf(wps_display[0],sizeof(wps_display[0]),"%s", "%pp/%pe: %fn"); #ifdef HAVE_LCD_CHARCELLS @@ -171,27 +162,6 @@ static void draw_screen(void) #endif scroll_line = 0; refresh_wps(false); -#else - char buffer[64]; - char ch = '/'; - char* szLast = strrchr(id3->path, ch); - - if (szLast) - { - snprintf(buffer, sizeof(buffer), "%d/%d: %s", - id3->index + 1, - playlist.amount, - ++szLast); - } - else - { - snprintf(buffer, sizeof(buffer), "%d/%d: %s", - id3->index + 1, - playlist.amount, - id3->path); - } - lcd_puts_scroll(0, 0, buffer); -#endif break; } case PLAY_DISPLAY_2LINEID3: @@ -199,7 +169,6 @@ static void draw_screen(void) #ifdef HAVE_LCD_BITMAP int l = 0; -#ifdef CUSTOM_WPS snprintf(wps_display[l],sizeof(wps_display[l]),"%s","%fn"); snprintf(wps_display[l++],sizeof(wps_display[l]),"%s","%it"); snprintf(wps_display[l++],sizeof(wps_display[l]),"%s","%id"); @@ -227,79 +196,25 @@ static void draw_screen(void) scroll_line = 0; refresh_wps(false); #else - char buffer[64]; - - lcd_puts_scroll(0, l++, id3->path); - lcd_puts(0, l++, id3->title?id3->title:""); - lcd_puts(0, l++, id3->album?id3->album:""); - lcd_puts(0, l++, id3->artist?id3->artist:""); - - if(!global_settings.statusbar && font_height <= 8) { - if(id3->vbr) - snprintf(buffer, sizeof(buffer), "%d kbit (avg)", - id3->bitrate); - else - snprintf(buffer, sizeof(buffer), "%d kbit", - id3->bitrate); - - lcd_puts(0, l++, buffer); - snprintf(buffer,sizeof(buffer), "%d Hz", id3->frequency); - lcd_puts(0, l++, buffer); - } - else { - if(id3->vbr) - snprintf(buffer, sizeof(buffer), "%dkbit(a) %dHz", - id3->bitrate, id3->frequency); - else - snprintf(buffer, sizeof(buffer), "%dkbit %dHz", - id3->bitrate, id3->frequency); - - lcd_puts(0, l++, buffer); - } -#endif -#else -#ifdef CUSTOM_WPS snprintf(wps_display[0],sizeof(wps_display[0]),"%s","%ia"); snprintf(wps_display[1],sizeof(wps_display[1]),"%s","%it"); scroll_line = 1; refresh_wps(false); -#else - lcd_puts(0, 0, id3->artist?id3->artist:""); - lcd_puts_scroll(0, 1, id3->title?id3->title:""); -#endif #endif break; } #ifdef HAVE_LCD_CHARCELLS case PLAY_DISPLAY_1LINEID3: { -#ifdef CUSTOM_WPS snprintf(wps_display[0],sizeof(wps_display[0]),"%s", "%pp/%pe: %fc"); snprintf(wps_display[1],sizeof(wps_display[1]),"%s", "%pc/%pt"); scroll_line = 0; refresh_wps(false); -#else - char buffer[64]; - char ch = '/'; - char* szLast = strrchr(id3->path, ch); - - if(id3->artist && id3->title) - snprintf(buffer, sizeof(buffer), "%d/%d: %s - %s", - id3->index + 1, playlist.amount, - id3->artist?id3->artist:"", - id3->title?id3->title:""); - else - snprintf(buffer, sizeof(buffer), "%d/%d: %s", - id3->index + 1, playlist.amount, - szLast?++szLast:id3->path); - lcd_puts_scroll(0, 0, buffer); -#endif break; } #endif -#ifdef CUSTOM_WPS case PLAY_DISPLAY_CUSTOM_WPS: { if(custom_wps[0] == 0) @@ -312,21 +227,29 @@ static void draw_screen(void) refresh_wps(false); break; } -#endif } } status_draw(); lcd_update(); } -#ifdef CUSTOM_WPS +#ifdef PLAYER_PROGRESS +int bin2int(char *input, int size) +{ + int result=0; + while(size--) { + result <<= 1; + result += (*input++ - '0'); + } + return result; +} +#endif + bool refresh_wps(bool refresh_scroll) { int l; -#ifdef CUSTOM_WPS #ifdef HAVE_LCD_BITMAP int bmp_time_line; -#endif #endif if(!id3) @@ -369,10 +292,38 @@ bool refresh_wps(bool refresh_scroll) slidebar(0, LCD_HEIGHT-6, LCD_WIDTH, 6, id3->elapsed*100/id3->length, Grow_Right); lcd_update(); +#endif +#ifdef PLAYER_PROGRESS +#ifdef HAVE_LCD_CHARCELLS + draw_player_progress(10,1); +#endif #endif return(true); } +#ifdef PLAYER_PROGRESS +#ifdef HAVE_LCD_CHARCELLS +void draw_player_progress(int x, int y) +{ + char player_progressbar[8]; + char binline[35]; + char charline[5]; + int songpos = 0; + int tmpcnt; + + memset(binline, 0, sizeof(binline)); + memset(charline, 0, sizeof(charline)); + songpos = (id3->elapsed * 35) / id3->length; + for(tmpcnt=0;tmpcnt<=songpos;tmpcnt++) + binline[tmpcnt] = 1; + for(tmpcnt=0;tmpcnt<=6;tmpcnt++) + player_progressbar[tmpcnt] = bin2int(binline+(tmpcnt*5),4); + lcd_define_pattern(8,player_progressbar,7); + lcd_puts(x,y,"\01"); +} +#endif +#endif + bool load_custom_wps(void) { #ifdef SIMULATOR @@ -625,7 +576,6 @@ bool display_custom_wps(int x_val, int y_val, bool do_scroll, char *wps_string) } return(true); } -#endif int player_id3_show(void) { @@ -745,50 +695,6 @@ int player_id3_show(void) return(0); } -#ifndef CUSTOM_WPS -static void display_file_time(void) -{ - char buffer[32]; - int elapsed = id3->elapsed + ff_rewind_count; - -#ifdef HAVE_LCD_BITMAP - int line; - if(global_settings.statusbar) - line = 5; - else - line = 6; - snprintf(buffer,sizeof(buffer), - "Time:%3d:%02d/%d:%02d", - elapsed / 60000, - elapsed % 60000 / 1000, - id3->length / 60000, - id3->length % 60000 / 1000 ); - - lcd_puts(0, line, buffer); - slidebar(0, LCD_HEIGHT-6, LCD_WIDTH, 6, - elapsed*100/id3->length, Grow_Right); - lcd_update(); -#else - /* Display time with the filename scroll only because - the screen has room. */ - if ((global_settings.wps_display == PLAY_DISPLAY_FILENAME_SCROLL) || - global_settings.wps_display == PLAY_DISPLAY_1LINEID3 || - global_settings.wps_display == PLAY_DISPLAY_CUSTOM_WPS || - ff_rewind) - { - snprintf(buffer,sizeof(buffer), "%d:%02d/%d:%02d ", - elapsed / 60000, - elapsed % 60000 / 1000, - id3->length / 60000, - id3->length % 60000 / 1000 ); - - lcd_puts(0, 1, buffer); - lcd_update(); - } -#endif -} -#endif - void display_volume_level(int vol_level) { char buffer[32]; @@ -926,11 +832,7 @@ static bool ffwd_rew(int button) if ((int)(id3->elapsed + ff_rewind_count) < 0) ff_rewind_count = -id3->elapsed; -#ifdef CUSTOM_WPS refresh_wps(false); -#else - display_file_time(); -#endif break; case BUTTON_RIGHT | BUTTON_REPEAT: @@ -974,11 +876,7 @@ static bool ffwd_rew(int button) if ((id3->elapsed + ff_rewind_count) > id3->length) ff_rewind_count = id3->length - id3->elapsed; -#ifdef CUSTOM_WPS refresh_wps(false); -#else - display_file_time(); -#endif break; case BUTTON_LEFT | BUTTON_REL: @@ -1024,9 +922,7 @@ static bool ffwd_rew(int button) if (!exit) button = button_get(true); } -#ifdef CUSTOM_WPS refresh_wps(true); -#endif return usb; } @@ -1037,17 +933,11 @@ static void update(void) lcd_stop_scroll(); id3 = mpeg_current_track(); draw_screen(); -#ifdef CUSTOM_WPS refresh_wps(true); -#endif } if (id3) { -#ifdef CUSTOM_WPS refresh_wps(false); -#else - display_file_time(); -#endif } status_draw(); @@ -1075,9 +965,7 @@ static bool keylock(void) #endif display_keylock_text(true); keys_locked = true; -#ifdef CUSTOM_WPS refresh_wps(true); -#endif draw_screen(); status_draw(); while (button_get(false)); /* clear button queue */ @@ -1118,9 +1006,7 @@ static bool keylock(void) default: display_keylock_text(true); while (button_get(false)); /* clear button queue */ -#ifdef CUSTOM_WPS refresh_wps(true); -#endif draw_screen(); break; } @@ -1238,9 +1124,7 @@ static bool menu(void) #endif draw_screen(); -#ifdef CUSTOM_WPS refresh_wps(true); -#endif return false; } @@ -1268,20 +1152,14 @@ int wps_show(void) ff_rewind = false; ff_rewind_count = 0; -#ifdef CUSTOM_WPS load_custom_wps(); /* Load the Custom WPS file, if there is one */ -#endif if(mpeg_is_playing()) { id3 = mpeg_current_track(); if (id3) { draw_screen(); -#ifdef CUSTOM_WPS refresh_wps(true); -#else - display_file_time(); -#endif } restore = true; } @@ -1443,11 +1321,7 @@ int wps_show(void) restore = false; draw_screen(); if (id3) -#ifdef CUSTOM_WPS refresh_wps(false); -#else - display_file_time(); -#endif } } } diff --git a/apps/wps.h b/apps/wps.h index d181273408..a1feacd1e6 100644 --- a/apps/wps.h +++ b/apps/wps.h @@ -25,10 +25,12 @@ extern bool keys_locked; int wps_show(void); -#ifdef CUSTOM_WPS bool load_custom_wps(void); bool display_custom_wps(int x_val, int y_val, bool do_scroll, char *wps_string); bool refresh_wps(bool refresh_scroll); + +#ifdef PLAYER_PROGRESS +void draw_player_progress(int x, int y); #endif #endif -- cgit v1.2.3