Index: apps/lang/english.lang =================================================================== --- apps/lang/english.lang (revision 30324) +++ apps/lang/english.lang (working copy) @@ -4427,7 +4427,7 @@ id: LANG_SLEEP_TIMER - desc: sleep timer setting + desc: sleep timer menu item user: core *: "Sleep Timer" @@ -12813,3 +12813,31 @@ *: "Save Changes?" + + id: LANG_SLEEP_TIMER_DURATION + desc: default sleep timer duration in minutes + user: core + + *: "Default Sleep Timer Duration" + + + *: "Default Sleep Timer Duration" + + + *: "Default Sleep Timer Duration" + + + + id: LANG_SLEEP_TIMER_ON_POWER_UP + desc: whether sleep timer starts on power up + user: core + + *: "Start Sleep Timer On Boot" + + + *: "Start Sleep Timer On Boot" + + + *: "Start Sleep Timer On Boot" + + Index: apps/settings.h =================================================================== --- apps/settings.h (revision 30324) +++ apps/settings.h (working copy) @@ -786,6 +786,9 @@ int compressor_release_time; #endif + int sleeptimer_duration; + bool sleeptimer_on_startup; + #ifdef HAVE_MORSE_INPUT bool morse_input; /* text input method setting */ #endif Index: apps/menus/main_menu.c =================================================================== --- apps/menus/main_menu.c (revision 30324) +++ apps/menus/main_menu.c (working copy) @@ -417,7 +417,7 @@ static int sleep_timer(void) { - int minutes = (get_sleep_timer() + 59) / 60; /* round up */ + int minutes = get_sleep_timer() ? 0 : global_settings.sleeptimer_duration; return (int)set_int(str(LANG_SLEEP_TIMER), "", UNIT_MIN, &minutes, &sleep_timer_set, 5, 0, 300, sleep_timer_formatter); } Index: apps/menus/settings_menu.c =================================================================== --- apps/menus/settings_menu.c (revision 30324) +++ apps/menus/settings_menu.c (working copy) @@ -220,6 +220,33 @@ /* System menu */ MENUITEM_SETTING(poweroff, &global_settings.poweroff, NULL); +/* Sleep timer menu */ +static int initial_duration; +static int sleeptimer_duration_cb(int action, + const struct menu_item_ex *this_item) +{ + (void)this_item; + switch (action) + { + case ACTION_ENTER_MENUITEM: + initial_duration = global_settings.sleeptimer_duration; + break; + case ACTION_EXIT_MENUITEM: + if (initial_duration != global_settings.sleeptimer_duration && get_sleep_timer()) + set_sleep_timer(global_settings.sleeptimer_duration * 60); + } + return action; +} + +MENUITEM_SETTING(menu_sleeptimer_duration, &global_settings.sleeptimer_duration, + sleeptimer_duration_cb); + +MENUITEM_SETTING(menu_sleeptimer_on_startup, + &global_settings.sleeptimer_on_startup, NULL); + +MAKE_MENU(sleeptimer_menu, ID2P(LANG_SLEEP_TIMER), NULL, Icon_NOICON, + &menu_sleeptimer_duration, &menu_sleeptimer_on_startup); + /* Limits menu */ MENUITEM_SETTING(max_files_in_dir, &global_settings.max_files_in_dir, NULL); MENUITEM_SETTING(max_files_in_playlist, &global_settings.max_files_in_playlist, NULL); @@ -297,6 +324,7 @@ &disk_menu, #endif &poweroff, + &sleeptimer_menu, &limits_menu, #ifdef HAVE_MORSE_INPUT &morse_input, Index: apps/settings_list.c =================================================================== --- apps/settings_list.c (revision 30324) +++ apps/settings_list.c (working copy) @@ -519,6 +519,13 @@ memcpy(setting, defaultval, sizeof(struct touchscreen_parameter)); } #endif +static const char* sleeptimer_formatter(char* buffer, size_t buffer_size, + int value, const char* unit) +{ + (void) unit; + snprintf(buffer, buffer_size, "%d:%02d", value / 60, value % 60); + return buffer; +} #ifdef HAVE_HOTKEY static const char* hotkey_formatter(char* buffer, size_t buffer_size, int value, const char* unit) @@ -1723,6 +1730,11 @@ #endif /* CONFIG_CODEC == SWCODEC */ TEXT_SETTING(0, playlist_catalog_dir, "playlist catalog directory", PLAYLIST_CATALOG_DEFAULT_DIR, NULL, NULL), + INT_SETTING(0, sleeptimer_duration, LANG_SLEEP_TIMER_DURATION, 30, + "sleeptimer duration", + UNIT_MIN, 5, 300, 5, sleeptimer_formatter, NULL, NULL), + OFFON_SETTING(0, sleeptimer_on_startup, LANG_SLEEP_TIMER_ON_POWER_UP, false, + "sleeptimer on startup", NULL), #ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING CHOICE_SETTING(0, touchpad_sensitivity, LANG_TOUCHPAD_SENSITIVITY, 0, "touchpad sensitivity", "normal,high", touchpad_set_sensitivity, 2, Index: apps/root_menu.c =================================================================== --- apps/root_menu.c (revision 30324) +++ apps/root_menu.c (working copy) @@ -661,6 +661,9 @@ next_screen = GO_TO_ROOT; #endif + if (global_settings.sleeptimer_on_startup) + set_sleep_timer(global_settings.sleeptimer_duration * 60); + while (true) { switch (next_screen) Index: manual/appendix/config_file_options.tex =================================================================== --- manual/appendix/config_file_options.tex (revision 30324) +++ manual/appendix/config_file_options.tex (working copy) @@ -100,6 +100,9 @@ } idle poweroff & off, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 30, 45, 60 & min\\ + sleeptimer duration & 5 to 300 (in steps of 5) + & min\\ + sleeptimer on startup & off, on & N/A\\ max files in playlist & 1000 - 32000 & N/A\\ max files in dir & 50 - 10000 & N/A\\ lang & /path/filename.lng & N/A\\ Index: manual/configure_rockbox/system_options.tex =================================================================== --- manual/configure_rockbox/system_options.tex (revision 30324) +++ manual/configure_rockbox/system_options.tex (working copy) @@ -120,6 +120,21 @@ Settings are either \setting{Off} or 1 to 10 minutes in 1 minute steps. Then 15, 30, 45 or 60 minutes are available. +\subsection{\label{ref:sleep_timer_submenu}Sleep Timer} +\setting{Sleep Timer} related menu options. +The \setting{Sleep Timer} powers off your \dap{} after a given time +and is triggered from \setting{System + \opt{rtc}{ $\rightarrow$ \setting{Time and Date} }%\opt{rtc} +} (See \reference{ref:Info}). + \begin{description} + \item[Default Sleep Timer Duration.] + The default number of minutes from when new timers are initiated to + their completion. The values range from 5 minutes to 5 hours in + 5 minute steps. If a timer is currently active, the timer's + duration will be set to the newly entered value. + \item[Start Sleep Timer On Boot.] If set, a timer will be + initiated when the device starts. + \end{description} \subsection{Limits} This sub menu relates to limits in the Rockbox operating system. Index: manual/main_menu/main.tex =================================================================== --- manual/main_menu/main.tex (revision 30324) +++ manual/main_menu/main.tex (working copy) @@ -204,6 +204,8 @@ 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} is reset on boot. + If the sleep timer is currently active, \setting{Off} will be highlighted, + otherwise the current \setting{Default Sleep Timer Duration} set \reference{ref:sleep_timer_submenu}). \opt{alarm}{ \item[Wake-Up Alarm:] This option will make the \dap{} start up at the specified time. @@ -242,6 +244,8 @@ 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} is reset on boot. + If the sleep timer is currently active, \setting{Off} will be highlighted, + otherwise the current \setting{Default Sleep Timer Duration} from \reference{ref:sleep_timer_submenu}). } \item[Running Time:]