Index: settings.c =================================================================== RCS file: /cvsroot/rockbox/apps/settings.c,v retrieving revision 1.14 diff -u -w -b -r1.14 settings.c --- settings.c 30 Jul 2002 07:56:16 -0000 1.14 +++ settings.c 2 Aug 2002 06:35:47 -0000 @@ -272,6 +272,7 @@ (global_settings.wps_display & 7)); rtc_config_block[0x11] = (unsigned char)global_settings.avc; + rtc_config_block[0x12] = (unsigned char)global_settings.time_display; memcpy(&rtc_config_block[0x24], &global_settings.total_uptime, 4); @@ -345,6 +346,9 @@ if (rtc_config_block[0x11] != 0xFF) global_settings.avc = rtc_config_block[0x11]; + if (rtc_config_block[0x12] != 0xFF) + global_settings.time_display = rtc_config_block[0x12]; + if (rtc_config_block[0x24] != 0xFF) memcpy(&global_settings.total_uptime, &rtc_config_block[0x24], 4); } @@ -370,6 +374,7 @@ global_settings.poweroff = DEFAULT_POWEROFF_SETTING; global_settings.backlight = DEFAULT_BACKLIGHT_SETTING; global_settings.wps_display = DEFAULT_WPS_DISPLAY; + global_settings.time_display = DEFAULT_TIME_DISPLAY; global_settings.mp3filter = true; global_settings.sort_case = false; global_settings.playlist_shuffle = false; Index: settings.h =================================================================== RCS file: /cvsroot/rockbox/apps/settings.h,v retrieving revision 1.9 diff -u -w -b -r1.9 settings.h --- settings.h 28 Jul 2002 16:09:44 -0000 1.9 +++ settings.h 2 Aug 2002 06:35:47 -0000 @@ -61,6 +61,8 @@ /* while playing screen settings */ int wps_display; /* 0=id3, 1=file, 2=parse */ + int time_display; /* 0=elapsed, 1=elapsed+total, 2=elapsed+remaining, */ + /* 3=progress bar, 4=elapsed+progress bar */ /* geeky persistent statistics */ unsigned int total_uptime; /* total uptime since rockbox was first booted */ @@ -99,5 +101,6 @@ #define DEFAULT_POWEROFF_SETTING 0 #define DEFAULT_BACKLIGHT_SETTING 5 #define DEFAULT_WPS_DISPLAY 0 +#define DEFAULT_TIME_DISPLAY 1 #endif /* __SETTINGS_H__ */ Index: settings_menu.c =================================================================== RCS file: /cvsroot/rockbox/apps/settings_menu.c,v retrieving revision 1.7 diff -u -w -b -r1.7 settings_menu.c --- settings_menu.c 22 Jul 2002 16:39:17 -0000 1.7 +++ settings_menu.c 2 Aug 2002 06:35:47 -0000 @@ -67,6 +67,18 @@ set_option("[WPS display]", &global_settings.wps_display, names, 3 ); } +static void time_set(void) +{ +#ifdef HAVE_LCD_BITMAP + char* names[] = { "Time only ", "Time+total ", "Time+remaining" }; + set_option("[Time display]", &global_settings.time_display, names, 3 ); +#else + char* names[] = { "Time only ", "Time+total ", "Time+remain", + "Progress ", "Time+prog " }; + set_option("[Time display]", &global_settings.time_display, names, 5 ); +#endif +} + void settings_menu(void) { int m; @@ -77,6 +89,7 @@ { "Backlight Timer", backlight_timer }, { "Scroll speed", scroll_speed }, { "While Playing", wps_set }, + { "Time Display", time_set }, }; m=menu_init( items, sizeof items / sizeof(struct menu_items) ); Index: wps.c =================================================================== RCS file: /cvsroot/rockbox/apps/wps.c,v retrieving revision 1.45 diff -u -w -b -r1.45 wps.c --- wps.c 1 Aug 2002 13:29:59 -0000 1.45 +++ wps.c 2 Aug 2002 06:35:47 -0000 @@ -41,6 +41,16 @@ #define PLAY_DISPLAY_FILENAME_SCROLL 1 #define PLAY_DISPLAY_TRACK_TITLE 2 +#define TIME_DISPLAY_ELAPSED 0 +#define TIME_DISPLAY_ELAPSED_AND_TRACK 1 +#define TIME_DISPLAY_ELAPSED_AND_REMAINING 2 +#ifdef HAVE_LCD_CHARCELLS +# define TIME_DISPLAY_PROG_BAR 3 +# define TIME_DISPLAY_ELAPSED_AND_PROG_BAR 4 +#endif + +#define LCD_COLUMNS 11 + #ifdef HAVE_RECORDER_KEYPAD #define RELEASE_MASK (BUTTON_F1 | BUTTON_DOWN) #else @@ -192,37 +202,139 @@ draw_screen(id3); } +#ifdef HAVE_LCD_BITMAP if (mpeg_is_playing() && id3) +#else + /* Display time with the filename scroll only because + the screen has room. */ + if (mpeg_is_playing() && id3 && + global_settings.wps_display == PLAY_DISPLAY_FILENAME_SCROLL) +#endif { + int elapsed_min; + int elapsed_sec; + int total_min; + int total_sec; + int remaining; + int remaining_min; + int remaining_sec; + + remaining = id3->length - id3->elapsed; + if (remaining < 0) remaining = 0; + + elapsed_min = id3->elapsed / 60000; + elapsed_sec = (id3->elapsed % 60000) / 1000; + total_min = id3->length / 60000; + total_sec = (id3->length % 60000) / 1000; + remaining_min = (remaining / 60000); + remaining_sec = (remaining % 60000) / 1000; + + switch ( global_settings.time_display ) { + case TIME_DISPLAY_ELAPSED: { +#ifdef HAVE_LCD_BITMAP + snprintf(buffer,sizeof(buffer), "Time: %d:%02d", + elapsed_min, elapsed_sec); +#else + // center the ':' + snprintf(buffer,sizeof(buffer), "%5d:%02d", + elapsed_min, elapsed_sec); +#endif + break; + } + case TIME_DISPLAY_ELAPSED_AND_TRACK: { #ifdef HAVE_LCD_BITMAP snprintf(buffer,sizeof(buffer), "Time: %d:%02d / %d:%02d", - id3->elapsed / 60000, - id3->elapsed % 60000 / 1000, - id3->length / 60000, - id3->length % 60000 / 1000 ); + elapsed_min, elapsed_sec, total_min, total_sec); +#else + snprintf(buffer,sizeof(buffer), "%02d:%02d/%02d:%02d", + elapsed_min % 100, elapsed_sec, + total_min % 100, total_sec); +#endif + break; + } + case TIME_DISPLAY_ELAPSED_AND_REMAINING: { +#ifdef HAVE_LCD_BITMAP + snprintf(buffer,sizeof(buffer), "Time: %d:%02d - %d:%02d", + elapsed_min, elapsed_sec, + remaining_min, remaining_sec); +#else + snprintf(buffer,sizeof(buffer), "%02d:%02d-%02d:%02d", + elapsed_min % 100, elapsed_sec, + remaining_min % 100, remaining_sec); +#endif + break; + } +#ifdef HAVE_LCD_CHARCELLS + case TIME_DISPLAY_PROG_BAR: + case TIME_DISPLAY_ELAPSED_AND_PROG_BAR: { + + /* Chars used to build the progress bar, ordered by + * increasing fraction of a char cell filled. + */ +#ifdef HAVE_NEW_CHARCELL_LCD + /* Cells are filled horizontally. + * + * These chars also work, but fill the cells vertically + * rather than horizontally: + * { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86 }; + */ + char glyphs[] = { 0x8b, 0x8c, 0x8d, 0x8e }; +#else + /* Cells are filled vertically, since the font set doesn't + * have the characters to fill horizontally. + * + * This also works: { 0xe1 }; + */ + char glyphs[] = { 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xec }; +#endif + unsigned int ratio; + int i; + + if (global_settings.time_display == TIME_DISPLAY_PROG_BAR) { + i = 0; + } + else { + snprintf(buffer, sizeof(buffer), "%02d:%02d", + elapsed_min, elapsed_sec); + i = 5; + } + + ratio = (id3->elapsed * (LCD_COLUMNS-i) * sizeof(glyphs)) + / id3->length; + + /* fill all but the last square */ + while (ratio >= sizeof(glyphs)) { + buffer[i++] = glyphs[sizeof(glyphs)-1]; + ratio -= sizeof(glyphs); + } + + /* fill the last square partially */ + if (ratio > 0) + buffer[i++] = glyphs[ratio]; + + /* fill the rest of the buffer with spaces */ + while (i < LCD_COLUMNS) { + buffer[i++] = ' '; + } + + buffer[i] = 0; + + break; + } +#endif + } + +#ifdef HAVE_LCD_BITMAP lcd_puts(0, 6, buffer); lcd_slidebar(1, LCD_HEIGHT-7, LCD_WIDTH-2, 5, id3->elapsed*100/id3->length, BAR_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) - { - snprintf(buffer,sizeof(buffer), "Time: %d:%02d / %d:%02d", - id3->elapsed / 60000, - id3->elapsed % 60000 / 1000, - id3->length / 60000, - id3->length % 60000 / 1000 ); - lcd_puts(0, 1, buffer); - lcd_update(); - } #endif + lcd_update(); } status_draw();