Index: apps/lang/english.lang =================================================================== --- apps/lang/english.lang (revision 30355) +++ apps/lang/english.lang (working copy) @@ -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 30355) +++ 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 30355) +++ apps/menus/main_menu.c (working copy) @@ -412,12 +412,14 @@ static void sleep_timer_set(int minutes) { + if (minutes) + global_settings.sleeptimer_duration = minutes; set_sleep_timer(minutes * 60); } 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); } @@ -428,10 +430,14 @@ MENUITEM_FUNCTION(timedate_item, MENU_FUNC_CHECK_RETVAL, ID2P(LANG_TIME_MENU), time_screen, NULL, NULL, Icon_Menu_setting ); #endif -/* This item is in the time/date screen if there is a RTC */ +/* Sleep timer items are in the time/date screen if there is a RTC */ MENUITEM_FUNCTION(sleep_timer_call, 0, ID2P(LANG_SLEEP_TIMER), sleep_timer, NULL, NULL, Icon_Menu_setting); /* make it look like a setting to the user */ +#if CONFIG_RTC == 0 +MENUITEM_SETTING(sleeptimer_on_startup, + &global_settings.sleeptimer_on_startup, NULL); +#endif MENUITEM_FUNCTION(show_credits_item, 0, ID2P(LANG_CREDITS), (menu_function)show_credits, NULL, NULL, Icon_NOICON); @@ -446,7 +452,7 @@ #endif &show_info_item, &show_credits_item, &show_runtime_item, #if CONFIG_RTC == 0 - &sleep_timer_call, + &sleep_timer_call, &sleeptimer_on_startup, #endif &debug_menu_item); /* INFO MENU */ Index: apps/menus/time_menu.c =================================================================== --- apps/menus/time_menu.c (revision 30355) +++ apps/menus/time_menu.c (working copy) @@ -136,6 +136,9 @@ #endif /* CONFIG_TUNER || defined(HAVE_RECORDING) */ #endif /* HAVE_RTC_ALARM */ +MENUITEM_SETTING(sleeptimer_on_startup, + &global_settings.sleeptimer_on_startup, NULL); + static void talk_timedate(void) { struct tm *tm = get_time(); @@ -242,7 +245,7 @@ &alarm_wake_up_screen, #endif #endif - &timeformat); + &sleeptimer_on_startup, &timeformat); int time_screen(void* ignored) { Index: apps/settings_list.c =================================================================== --- apps/settings_list.c (revision 30355) +++ 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 30355) +++ 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 30355) +++ 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/main_menu/main.tex =================================================================== --- manual/main_menu/main.tex (revision 30355) +++ manual/main_menu/main.tex (working copy) @@ -203,7 +203,9 @@ \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} is reset on boot. + While the \setting{Sleep Timer} is reset on boot, the value selected is + retained and will be used as the default from then on. + If the sleep timer is currently active, \setting{Off} will be highlighted, \opt{alarm}{ \item[Wake-Up Alarm:] This option will make the \dap{} start up at the specified time. @@ -212,12 +214,13 @@ \ActionAlarmSet{} confirms the alarm, and \ActionAlarmCancel{} cancels setting an alarm. If the \dap{} is turned on again before the alarm occurs, the alarm will be cancelled. - \opt{recording,radio}{ \item[Alarm Wake Up Screen:] This option controls what the \dap{} does when it is woken up by the alarm. }%\opt{recording,radio} }%\opt{alarm} + \item[Start Sleep Timer On Boot:] + If set, a \setting{Sleep Timer} will be initiated when the device starts. \item [Time Format:] Choose 12 or 24 hour clock. \end{description} }%\opt{rtc} @@ -241,7 +244,11 @@ \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} is reset on boot. + While the \setting{Sleep Timer} is reset on boot, the value selected is + retained and will be used as the default from then on. + If the sleep timer is currently active, \setting{Off} will be highlighted, + \item[Start Sleep Timer On Boot:] + If set, a \setting{Sleep Timer} will be initiated when the device starts. } \item[Running Time:]