From 53bdf866e749647918debe6a720198441d5239a6 Mon Sep 17 00:00:00 2001 From: kugel Date: Thu, 9 Apr 2009 08:30:05 +0000 Subject: [PATCH] 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 --- apps/gui/gwps.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c index 68f0ba2cf..1ff5410cf 100644 --- a/apps/gui/gwps.c +++ b/apps/gui/gwps.c @@ -208,6 +208,20 @@ static void gwps_fix_statusbars(void) #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) { @@ -225,6 +239,10 @@ static void gwps_leave_wps(void) show_remote_main_backdrop(); #endif 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) @@ -663,8 +681,17 @@ long gui_wps_show(void) if (wps_state.do_full_update || update) { 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]); } wps_state.do_full_update = false; update = false; @@ -677,6 +704,9 @@ long gui_wps_show(void) restore = false; restoretimer = RESTORE_WPS_INSTANTLY; 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) { screens[i].stop_scroll(); -- 2.11.4.GIT