Index: apps/gui/wps.c =================================================================== --- apps/gui/wps.c (revision 23543) +++ apps/gui/wps.c (working copy) @@ -838,6 +838,12 @@ fade(true, true); else audio_resume(); + + /* If we're currently cycling with the sleep timeout, reset the timeout period */ + if (sleep_timer_is_cycling() == true) + { + restart_sleep_timer(); + } } else { Index: firmware/export/powermgmt.h =================================================================== --- firmware/export/powermgmt.h (revision 23543) +++ firmware/export/powermgmt.h (working copy) @@ -167,6 +167,10 @@ void set_sleep_timer(int seconds); int get_sleep_timer(void); + +bool sleep_timer_is_cycling(void); +void restart_sleep_timer(void); + void set_car_adapter_mode(bool setting); void reset_poweroff_timer(void); void cancel_shutdown(void); Index: firmware/powermgmt.c =================================================================== --- firmware/powermgmt.c (revision 23543) +++ firmware/powermgmt.c (working copy) @@ -109,6 +109,10 @@ static bool sleeptimer_active = false; static long sleeptimer_endtick; +/* Record the sleeptimer interval and indicate if it has been activated since last boot */ +static int sleeptimer_period; +static bool sleeptimer_cycling; + static long last_event_tick; static int voltage_to_battery_level(int battery_millivolts); @@ -204,15 +208,28 @@ void set_sleep_timer(int seconds) { if (seconds) { + sleeptimer_cycling = true; sleeptimer_active = true; - sleeptimer_endtick = current_tick + seconds * HZ; + sleeptimer_period = seconds; + sleeptimer_endtick = current_tick + sleeptimer_period * HZ; } else { + sleeptimer_cycling = false; sleeptimer_active = false; sleeptimer_endtick = 0; } } +bool sleep_timer_is_cycling(void) +{ + return sleeptimer_cycling; +} + +void restart_sleep_timer(void) +{ + set_sleep_timer(sleeptimer_period); +} + int get_sleep_timer(void) { if (sleeptimer_active) @@ -348,7 +365,8 @@ else if (sleeptimer_active) { /* Handle sleeptimer */ if (TIME_AFTER(tick, sleeptimer_endtick)) { - audio_stop(); + /* Pause playback and let idle timeout subsequently power off */ + audio_pause(); if (usb_inserted() #if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING) @@ -360,8 +378,8 @@ backlight_off(); /* Nighty, nighty... */ } else { - DEBUGF("Sleep timer timeout. Shutting off...\n"); - sys_poweroff(); + DEBUGF("Sleep timer timeout. Pausing...\n"); + sleeptimer_active = false; } } } Index: manual/main_menu/main.tex =================================================================== --- manual/main_menu/main.tex (revision 23543) +++ manual/main_menu/main.tex (working copy) @@ -191,8 +191,10 @@ \begin{description} \item [Set Time/Date: ] Set current time and date. \item[Sleep Timer:] - The \setting{Sleep Timer} powers off your \dap{} after playing for a given - time. It can be set from \setting{Off} to 5 hours in 5 minute steps. + The \setting{Sleep Timer} pauses playback on your \dap{} after playing for a given + time. Your \dap{} will subsequently power off if play is not resumed before any idle timeout takes effect. + If you resume play before the idle timeout takes effect, the \setting{Sleep Timer} will restart. + It can be set from \setting{Off} to 5 hours in 5 minute steps. The \setting{Sleep Timer} is reset on boot. \opt{alarm}{Using this option disables the \setting{Wake up alarm}.} \item [Time Format: ] Choose 12 or 24 hour clock. @@ -233,8 +235,10 @@ \nopt{rtc}{ \item[Sleep Timer:] - The \setting{Sleep Timer} powers off your \dap{} after playing for a given - time. It can be set from \setting{Off} to 5 hours in 5 minute steps. + The \setting{Sleep Timer} pauses playback on your \dap{} after playing for a given + time. Your \dap{} will subsequently power off if play is not resumed before any idle timeout takes effect. + If you resume play before the idle timeout takes effect, the \setting{Sleep Timer} will restart. + It can be set from \setting{Off} to 5 hours in 5 minute steps. The \setting{Sleep Timer} is reset on boot. \opt{alarm}{Using this option disables the \setting{Wake up alarm}.} } Index: uisimulator/common/stubs.c =================================================================== --- uisimulator/common/stubs.c (revision 23543) +++ uisimulator/common/stubs.c (working copy) @@ -287,6 +287,18 @@ return sleeptime; } + +static bool sleeptimer_cycling = false; +bool sleep_timer_is_cycling() +{ + return sleeptimer_cycling; +} + +void restart_sleep_timer(void) +{ +} + + #ifdef HAVE_LCD_CHARCELLS void lcd_clearrect (int x, int y, int nx, int ny) {