Index: apps/action.h =================================================================== --- apps/action.h (Revision 20172) +++ apps/action.h (Arbeitskopie) @@ -119,6 +119,9 @@ ACTION_WPS_QUICKSCREEN,/* optional */ ACTION_WPS_MENU, /*this should be the same as ACTION_STD_MENU */ ACTION_WPS_REC, +#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) + ACTION_WPS_UPDATE, +#endif #if 0 ACTION_WPSAB_SINGLE, /* This needs to be #defined in the config-.h to one of the ACTION_WPS_ actions Index: apps/gui/gwps-common.c =================================================================== --- apps/gui/gwps-common.c (Revision 20172) +++ apps/gui/gwps-common.c (Arbeitskopie) @@ -1960,7 +1960,6 @@ align.left = NULL; align.center = NULL; align.right = NULL; - bool update_line, new_subline_refresh; #ifdef HAVE_LCD_BITMAP @@ -1976,16 +1975,76 @@ #endif +#ifdef HAVE_BACKLIGHT + bool track_changed = state->id3->elapsed < 1000; + if (global_settings.caption_backlight && state->id3) + { + /* turn on backlight n seconds before track ends, and turn it off n + seconds into the new track. n == backlight_timeout, or 5s */ + int n = global_settings.backlight_timeout * 1000; + + if ( n < 1000 ) + n = 5000; /* use 5s if backlight is always on or off */ + + if (((track_changed) || + ((state->id3->length - state->id3->elapsed) < (unsigned)n)) && + (state->paused == false)) + backlight_on(); + } +#endif +#ifdef HAVE_REMOTE_LCD + if (global_settings.remote_caption_backlight && state->id3) + { + /* turn on remote backlight n seconds before track ends, and turn it + off n seconds into the new track. n == remote_backlight_timeout, + or 5s */ + int n = global_settings.remote_backlight_timeout * 1000; + + if ( n < 1000 ) + n = 5000; /* use 5s if backlight is always on or off */ + + if (((track_changed) || + ((state->id3->length - state->id3->elapsed) < (unsigned)n)) && + (state->paused == false)) + remote_backlight_on(); + } +#endif +/* disable wps updating if lcd is disabled */ +#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) + bool exit = false; + if ( +#ifdef HAVE_LCD_ENABLE + !lcd_enabled() +#elif defined(HAVE_LCD_SLEEP) /* e.g. ipod video */ + lcd_asleep() +#endif +#ifdef HAVE_REMOTE_LCD + && !is_remote_backlight_on() +#endif + ) + { + exit = true; + /* reset sublines to avoid fast subline changing when backlight is + * on again */ + goto reset_sublines; + } +#endif /* reset to first subline if refresh all flag is set */ if (refresh_mode == WPS_REFRESH_ALL) { display->set_viewport(&data->viewports[0].vp); display->clear_viewport(); - +#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) +reset_sublines: +#endif for (i = 0; i <= data->num_lines; i++) { data->lines[i].curr_subline = SUBLINE_RESET; } +#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) + if (exit) + return true; +#endif } #ifdef HAVE_LCD_CHARCELLS @@ -2150,39 +2209,6 @@ display->update(); -#ifdef HAVE_BACKLIGHT - if (global_settings.caption_backlight && state->id3) - { - /* turn on backlight n seconds before track ends, and turn it off n - seconds into the new track. n == backlight_timeout, or 5s */ - int n = global_settings.backlight_timeout * 1000; - - if ( n < 1000 ) - n = 5000; /* use 5s if backlight is always on or off */ - - if (((state->id3->elapsed < 1000) || - ((state->id3->length - state->id3->elapsed) < (unsigned)n)) && - (state->paused == false)) - backlight_on(); - } -#endif -#ifdef HAVE_REMOTE_LCD - if (global_settings.remote_caption_backlight && state->id3) - { - /* turn on remote backlight n seconds before track ends, and turn it - off n seconds into the new track. n == remote_backlight_timeout, - or 5s */ - int n = global_settings.remote_backlight_timeout * 1000; - - if ( n < 1000 ) - n = 5000; /* use 5s if backlight is always on or off */ - - if (((state->id3->elapsed < 1000) || - ((state->id3->length - state->id3->elapsed) < (unsigned)n)) && - (state->paused == false)) - remote_backlight_on(); - } -#endif /* force a bars update if they are being displayed */ viewportmanager_draw_statusbars(NULL); return true; Index: apps/gui/gwps.c =================================================================== --- apps/gui/gwps.c (Revision 20172) +++ apps/gui/gwps.c (Arbeitskopie) @@ -134,6 +134,13 @@ #endif } +#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) +static void wps_lcd_enable_hook(void) +{ + queue_post(&button_queue, ACTION_WPS_UPDATE, 0); +} +#endif + long gui_wps_show(void) { long button = 0; @@ -145,9 +152,13 @@ int i; long last_left = 0, last_right = 0; int wpsbars, oldbars; + int ret; wps_state_init(); +#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) + lcd_set_enable_hook(wps_lcd_enable_hook); +#endif #ifdef HAVE_LCD_CHARCELLS status_set_audio(true); status_set_param(false); @@ -173,7 +184,10 @@ wps_state.nid3 = audio_next_track(); if (wps_state.id3) { if (gui_wps_display()) - return 0; + { + ret = 0; + goto exit_wps; + } } restore = true; @@ -276,8 +290,19 @@ #endif switch(button) { +#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) + case ACTION_WPS_UPDATE: + { + FOR_NB_SCREENS(i) + gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_ALL); + } + break; +#endif case ACTION_WPS_CONTEXT: { +#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) + lcd_set_enable_hook(NULL); +#endif #if LCD_DEPTH > 1 show_main_backdrop(); #endif @@ -311,9 +336,8 @@ #endif FOR_NB_SCREENS(i) gui_wps[i].display->stop_scroll(); - return GO_TO_PREVIOUS_BROWSER; - break; - + ret = GO_TO_PREVIOUS_BROWSER; + goto exit_wps; /* play/pause */ case ACTION_WPS_PLAY: if (global_settings.party_mode) @@ -538,10 +562,8 @@ case ACTION_WPS_MENU: FOR_NB_SCREENS(i) gui_wps[i].display->stop_scroll(); - return GO_TO_ROOT; - break; - - + ret = GO_TO_ROOT; + goto exit_wps; #ifdef HAVE_QUICKSCREEN case ACTION_WPS_QUICKSCREEN: { @@ -552,6 +574,9 @@ #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 show_remote_main_backdrop(); #endif +#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) + lcd_set_enable_hook(NULL); +#endif if (quick_screen_quick(button)) return SYS_USB_CONNECTED; wpsbars = fix_wps_bars(); @@ -578,6 +603,10 @@ #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 show_remote_main_backdrop(); #endif + +#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) + lcd_set_enable_hook(NULL); +#endif if (quick_screen_f3(BUTTON_F3)) return SYS_USB_CONNECTED; restore = true; @@ -598,6 +627,9 @@ #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 show_remote_main_backdrop(); #endif +#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) + lcd_set_enable_hook(NULL); +#endif if (1 == gui_syncpitchscreen_run()) return SYS_USB_CONNECTED; #if LCD_DEPTH > 1 @@ -677,7 +709,10 @@ default: if(default_event_handler(button) == SYS_USB_CONNECTED) - return GO_TO_ROOT; + { + ret = GO_TO_ROOT; + goto exit_wps; + } update_track = true; break; } @@ -696,6 +731,9 @@ ((restoretimer == 0) || (restoretimer < current_tick))) { +#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) + lcd_set_enable_hook(wps_lcd_enable_hook); +#endif restore = false; restoretimer = 0; if (gui_wps_display()) { @@ -704,6 +742,9 @@ } if (exit) { +#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) + lcd_set_enable_hook(NULL); +#endif viewportmanager_set_statusbar(oldbars); #ifdef HAVE_LCD_CHARCELLS status_set_record(false); @@ -732,7 +773,11 @@ if (button && !IS_SYSEVENT(button) ) storage_spin(); } - return GO_TO_ROOT; /* unreachable - just to reduce compiler warnings */ +exit_wps: +#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) + lcd_set_enable_hook(NULL); +#endif + return ret; /* unreachable - just to reduce compiler warnings */ } /* needs checking if needed end*/ Index: firmware/export/lcd.h =================================================================== --- firmware/export/lcd.h (Revision 20172) +++ firmware/export/lcd.h (Arbeitskopie) @@ -338,25 +338,30 @@ void lcd_poweroff(void); #endif -#ifdef HAVE_LCD_ENABLE +#ifdef HAVE_LCD_ENABLE /* Enable/disable the main display. */ extern void lcd_enable(bool on); extern bool lcd_enabled(void); -#ifdef HAVE_LCD_COLOR -/* Register a hook that is called when the lcd is powered and after the - * framebuffer data is synchronized */ -void lcd_set_enable_hook(void (*enable_hook)(void)); -#endif /* HAVE_LCD_COLOR */ - #endif /* HAVE_LCD_ENABLE */ -void lcd_call_enable_hook(void); + #ifdef HAVE_LCD_SLEEP /* Put the LCD into a power saving state deeper than lcd_enable(false). */ extern void lcd_sleep(void); +#ifndef HAVE_LCD_ENABLE +/* lcd_asleep() is only implemented if lcd_enable is not available */ +extern bool lcd_asleep(void); +#endif #endif /* HAVE_LCD_SLEEP */ +#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) +/* Register a hook that is called when the lcd is powered and after the + * framebuffer data is synchronized */ +void lcd_set_enable_hook(void (*enable_hook)(void)); +void lcd_call_enable_hook(void); +#endif + #ifdef HAVE_LCD_SHUTDOWN void lcd_shutdown(void); #endif Index: firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c =================================================================== --- firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c (Revision 20172) +++ firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c (Arbeitskopie) @@ -165,7 +165,10 @@ return; if( (display_on = enable) ) /* simple '=' is not a typo ! */ + { lcd_write_command(LCD_SET_DISPLAY_ON); + lcd_call_enable_hook(); + } else lcd_write_command(LCD_SET_DISPLAY_OFF); } Index: firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c =================================================================== --- firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c (Revision 20172) +++ firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c (Arbeitskopie) @@ -203,6 +203,7 @@ lcd_write_reg(0x07, 0x11); lcd_write_reg(0x07, 0x17); display_on = true; + lcd_call_enable_hook(); /* a bit of delay before returning to * avoid irritating flash on backlight on */ while(delay--); Index: firmware/target/arm/ipod/video/lcd-video.c =================================================================== --- firmware/target/arm/ipod/video/lcd-video.c (Revision 20172) +++ firmware/target/arm/ipod/video/lcd-video.c (Arbeitskopie) @@ -581,6 +581,7 @@ */ } mutex_unlock(&lcdstate_lock); + lcd_call_enable_hook(void); } void lcd_sleep(void) @@ -600,6 +601,11 @@ mutex_unlock(&lcdstate_lock); } +bool lcd_asleep(void) +{ + return !(lcd_state.display_on); +} + #ifdef HAVE_LCD_SHUTDOWN void lcd_shutdown(void) { Index: firmware/scroll_engine.c =================================================================== --- firmware/scroll_engine.c (Revision 20172) +++ firmware/scroll_engine.c (Arbeitskopie) @@ -305,8 +305,10 @@ if (scroll & SCROLL_LCD) { -#ifdef HAVE_LCD_ENABLE +#if defined(HAVE_LCD_ENABLE) if (lcd_enabled()) +#elif defined(HAVE_LCD_SLEEP) + if (!lcd_asleep()) #endif lcd_scroll_fn(); lcd_scroll_info.last_scroll = current_tick; @@ -328,8 +330,10 @@ while (1) { sleep(lcd_scroll_info.ticks); -#ifdef HAVE_LCD_ENABLE +#if defined(HAVE_LCD_ENABLE) if (lcd_enabled()) +#elif defined(HAVE_LCD_SLEEP) + if (!lcd_asleep()) #endif lcd_scroll_fn(); } Index: firmware/drivers/lcd-16bit.c =================================================================== --- firmware/drivers/lcd-16bit.c (Revision 20172) +++ firmware/drivers/lcd-16bit.c (Arbeitskopie) @@ -89,7 +89,7 @@ } /*** Helpers - consolidate optional code ***/ -#ifdef HAVE_LCD_ENABLE +#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) void lcd_set_enable_hook(void (*enable_hook)(void)) { lcd_enable_hook = enable_hook;