summaryrefslogtreecommitdiffstats
path: root/firmware/powermgmt.c
diff options
context:
space:
mode:
authorNick Peskett <rockbox@peskett.co.uk>2011-12-26 09:30:25 +0000
committerNick Peskett <rockbox@peskett.co.uk>2011-12-26 09:30:25 +0000
commit5dba771d63b26195b24fc5bbd098aff733da2599 (patch)
tree42311b171a28178d3a55d4cab887e3a0216988cc /firmware/powermgmt.c
parent57a0ebb1645a9c28aba467ea331da0ccce173270 (diff)
downloadrockbox-5dba771d63b26195b24fc5bbd098aff733da2599.tar.gz
rockbox-5dba771d63b26195b24fc5bbd098aff733da2599.tar.bz2
rockbox-5dba771d63b26195b24fc5bbd098aff733da2599.zip
Option to restart running sleep timer on keypress.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31437 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/powermgmt.c')
-rw-r--r--firmware/powermgmt.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 76322d65a3..4d554d6d3c 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -64,6 +64,10 @@ void send_battery_level_event(void);
static bool sleeptimer_active = false;
static long sleeptimer_endtick;
+/* Whether an active sleep timer should be restarted when a key is pressed */
+static bool sleeptimer_key_restarts = false;
+/* The number of seconds the sleep timer was last set to */
+static unsigned int sleeptimer_duration = 0;
#if CONFIG_CHARGING
/* State of the charger input as seen by the power thread */
@@ -707,6 +711,8 @@ void set_poweroff_timeout(int timeout)
void reset_poweroff_timer(void)
{
last_event_tick = current_tick;
+ if (sleeptimer_active && sleeptimer_key_restarts)
+ set_sleep_timer(sleeptimer_duration);
}
void sys_poweroff(void)
@@ -777,6 +783,7 @@ void set_sleep_timer(int seconds)
sleeptimer_active = false;
sleeptimer_endtick = 0;
}
+ sleeptimer_duration = seconds;
}
int get_sleep_timer(void)
@@ -787,6 +794,11 @@ int get_sleep_timer(void)
return 0;
}
+void set_keypress_restarts_sleep_timer(bool enable)
+{
+ sleeptimer_key_restarts = enable;
+}
+
static void handle_sleep_timer(void)
{
#ifndef BOOTLOADER