diff options
author | Nick Peskett <rockbox@peskett.co.uk> | 2011-12-26 09:30:25 +0000 |
---|---|---|
committer | Nick Peskett <rockbox@peskett.co.uk> | 2011-12-26 09:30:25 +0000 |
commit | 5dba771d63b26195b24fc5bbd098aff733da2599 (patch) | |
tree | 42311b171a28178d3a55d4cab887e3a0216988cc /firmware/powermgmt.c | |
parent | 57a0ebb1645a9c28aba467ea331da0ccce173270 (diff) | |
download | rockbox-5dba771d63b26195b24fc5bbd098aff733da2599.tar.gz 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.c | 12 |
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); | |||
64 | 64 | ||
65 | static bool sleeptimer_active = false; | 65 | static bool sleeptimer_active = false; |
66 | static long sleeptimer_endtick; | 66 | static long sleeptimer_endtick; |
67 | /* Whether an active sleep timer should be restarted when a key is pressed */ | ||
68 | static bool sleeptimer_key_restarts = false; | ||
69 | /* The number of seconds the sleep timer was last set to */ | ||
70 | static unsigned int sleeptimer_duration = 0; | ||
67 | 71 | ||
68 | #if CONFIG_CHARGING | 72 | #if CONFIG_CHARGING |
69 | /* State of the charger input as seen by the power thread */ | 73 | /* State of the charger input as seen by the power thread */ |
@@ -707,6 +711,8 @@ void set_poweroff_timeout(int timeout) | |||
707 | void reset_poweroff_timer(void) | 711 | void reset_poweroff_timer(void) |
708 | { | 712 | { |
709 | last_event_tick = current_tick; | 713 | last_event_tick = current_tick; |
714 | if (sleeptimer_active && sleeptimer_key_restarts) | ||
715 | set_sleep_timer(sleeptimer_duration); | ||
710 | } | 716 | } |
711 | 717 | ||
712 | void sys_poweroff(void) | 718 | void sys_poweroff(void) |
@@ -777,6 +783,7 @@ void set_sleep_timer(int seconds) | |||
777 | sleeptimer_active = false; | 783 | sleeptimer_active = false; |
778 | sleeptimer_endtick = 0; | 784 | sleeptimer_endtick = 0; |
779 | } | 785 | } |
786 | sleeptimer_duration = seconds; | ||
780 | } | 787 | } |
781 | 788 | ||
782 | int get_sleep_timer(void) | 789 | int get_sleep_timer(void) |
@@ -787,6 +794,11 @@ int get_sleep_timer(void) | |||
787 | return 0; | 794 | return 0; |
788 | } | 795 | } |
789 | 796 | ||
797 | void set_keypress_restarts_sleep_timer(bool enable) | ||
798 | { | ||
799 | sleeptimer_key_restarts = enable; | ||
800 | } | ||
801 | |||
790 | static void handle_sleep_timer(void) | 802 | static void handle_sleep_timer(void) |
791 | { | 803 | { |
792 | #ifndef BOOTLOADER | 804 | #ifndef BOOTLOADER |