Index: firmware/powermgmt.c =================================================================== --- firmware/powermgmt.c (revision 31320) +++ firmware/powermgmt.c (working copy) @@ -64,6 +64,8 @@ static bool sleeptimer_active = false; static long sleeptimer_endtick; +/* 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 +709,8 @@ void reset_poweroff_timer(void) { last_event_tick = current_tick; + if (sleeptimer_active) + set_sleep_timer(sleeptimer_duration); } void sys_poweroff(void) @@ -777,6 +781,7 @@ sleeptimer_active = false; sleeptimer_endtick = 0; } + sleeptimer_duration = seconds; } int get_sleep_timer(void)