Index: firmware/powermgmt.c =================================================================== --- firmware/powermgmt.c (revision 31266) +++ firmware/powermgmt.c (working copy) @@ -64,6 +64,7 @@ static bool sleeptimer_active = false; static long sleeptimer_endtick; +static unsigned int sleeptimer_duration = 0; #if CONFIG_CHARGING /* State of the charger input as seen by the power thread */ @@ -707,6 +708,8 @@ void reset_poweroff_timer(void) { last_event_tick = current_tick; + if (sleeptimer_active) + set_sleep_timer(sleeptimer_duration); } void sys_poweroff(void) @@ -772,10 +775,12 @@ if (seconds) { sleeptimer_active = true; sleeptimer_endtick = current_tick + seconds * HZ; + sleeptimer_duration = seconds; } else { sleeptimer_active = false; sleeptimer_endtick = 0; + sleeptimer_duration = 0; } }