FS#8523 - Disable WPS updating when the backlight is off.

Disables WPS updating when the lcd is inactive (sleep or disabled, backlight doesn't count in), which prevents a good deal of code from running uselessly.
According to tests, it can yield up to 1h more battery life in cases of heavy WPSes.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20666 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2009-04-09 08:30:05 +00:00
parent a7e112c8d9
commit 7ce12e62aa

View file

@ -208,6 +208,20 @@ static void gwps_fix_statusbars(void)
#endif #endif
} }
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
/*
* If the user is unable to see the wps, because the display is deactivated,
* we surpress updates until the wps gets actived again (the lcd driver will
* call this hook)
* */
static void wps_lcd_activation_hook(void)
{
/* issue an update */
wps_state.do_full_update = true;
/* force timeout in wps main loop, so that the update is instantly */
queue_post(&button_queue, BUTTON_NONE, 0);
}
#endif
static void gwps_leave_wps(void) static void gwps_leave_wps(void)
{ {
@ -225,6 +239,10 @@ static void gwps_leave_wps(void)
show_remote_main_backdrop(); show_remote_main_backdrop();
#endif #endif
viewportmanager_set_statusbar(oldbars); viewportmanager_set_statusbar(oldbars);
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
/* Play safe and unregister the hook */
lcd_activation_set_hook(NULL);
#endif
} }
void gwps_draw_statusbars(void) void gwps_draw_statusbars(void)
@ -663,6 +681,15 @@ long gui_wps_show(void)
if (wps_state.do_full_update || update) if (wps_state.do_full_update || update)
{ {
FOR_NB_SCREENS(i) FOR_NB_SCREENS(i)
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
if (lcd_active()
#ifdef HAVE_REMOTE_LCD
/* currently, all remotes are readable without backlight
* so still update those */
&& (i == SCREEN_MAIN)
#endif
)
#endif
{ {
gui_wps_update(&gui_wps[i]); gui_wps_update(&gui_wps[i]);
} }
@ -677,6 +704,9 @@ long gui_wps_show(void)
restore = false; restore = false;
restoretimer = RESTORE_WPS_INSTANTLY; restoretimer = RESTORE_WPS_INSTANTLY;
gwps_fix_statusbars(); gwps_fix_statusbars();
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
lcd_activation_set_hook(wps_lcd_activation_hook);
#endif
FOR_NB_SCREENS(i) FOR_NB_SCREENS(i)
{ {
screens[i].stop_scroll(); screens[i].stop_scroll();