summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/lang/english.lang28
-rw-r--r--apps/menus/main_menu.c12
-rw-r--r--apps/menus/time_menu.c5
-rw-r--r--apps/root_menu.c3
-rw-r--r--apps/settings.h3
-rw-r--r--apps/settings_list.c12
-rw-r--r--manual/appendix/config_file_options.tex3
-rw-r--r--manual/main_menu/main.tex13
8 files changed, 72 insertions, 7 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index eb3c963512..3fc2c72ec4 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -12861,3 +12861,31 @@
12861 *: "Automatic" 12861 *: "Automatic"
12862 </voice> 12862 </voice>
12863</phrase> 12863</phrase>
12864<phrase>
12865 id: LANG_SLEEP_TIMER_DURATION
12866 desc: default sleep timer duration in minutes
12867 user: core
12868 <source>
12869 *: "Default Sleep Timer Duration"
12870 </source>
12871 <dest>
12872 *: "Default Sleep Timer Duration"
12873 </dest>
12874 <voice>
12875 *: "Default Sleep Timer Duration"
12876 </voice>
12877</phrase>
12878<phrase>
12879 id: LANG_SLEEP_TIMER_ON_POWER_UP
12880 desc: whether sleep timer starts on power up
12881 user: core
12882 <source>
12883 *: "Start Sleep Timer On Boot"
12884 </source>
12885 <dest>
12886 *: "Start Sleep Timer On Boot"
12887 </dest>
12888 <voice>
12889 *: "Start Sleep Timer On Boot"
12890 </voice>
12891</phrase>
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c
index 394ee7c343..66d49a920e 100644
--- a/apps/menus/main_menu.c
+++ b/apps/menus/main_menu.c
@@ -412,12 +412,14 @@ static const char* sleep_timer_formatter(char* buffer, size_t buffer_size,
412 412
413static void sleep_timer_set(int minutes) 413static void sleep_timer_set(int minutes)
414{ 414{
415 if (minutes)
416 global_settings.sleeptimer_duration = minutes;
415 set_sleep_timer(minutes * 60); 417 set_sleep_timer(minutes * 60);
416} 418}
417 419
418static int sleep_timer(void) 420static int sleep_timer(void)
419{ 421{
420 int minutes = (get_sleep_timer() + 59) / 60; /* round up */ 422 int minutes = get_sleep_timer() ? 0 : global_settings.sleeptimer_duration;
421 return (int)set_int(str(LANG_SLEEP_TIMER), "", UNIT_MIN, &minutes, 423 return (int)set_int(str(LANG_SLEEP_TIMER), "", UNIT_MIN, &minutes,
422 &sleep_timer_set, 5, 0, 300, sleep_timer_formatter); 424 &sleep_timer_set, 5, 0, 300, sleep_timer_formatter);
423} 425}
@@ -428,10 +430,14 @@ int time_screen(void* ignored);
428MENUITEM_FUNCTION(timedate_item, MENU_FUNC_CHECK_RETVAL, ID2P(LANG_TIME_MENU), 430MENUITEM_FUNCTION(timedate_item, MENU_FUNC_CHECK_RETVAL, ID2P(LANG_TIME_MENU),
429 time_screen, NULL, NULL, Icon_Menu_setting ); 431 time_screen, NULL, NULL, Icon_Menu_setting );
430#endif 432#endif
431/* This item is in the time/date screen if there is a RTC */ 433/* Sleep timer items are in the time/date screen if there is a RTC */
432MENUITEM_FUNCTION(sleep_timer_call, 0, ID2P(LANG_SLEEP_TIMER), sleep_timer, 434MENUITEM_FUNCTION(sleep_timer_call, 0, ID2P(LANG_SLEEP_TIMER), sleep_timer,
433 NULL, NULL, Icon_Menu_setting); /* make it look like a 435 NULL, NULL, Icon_Menu_setting); /* make it look like a
434 setting to the user */ 436 setting to the user */
437#if CONFIG_RTC == 0
438MENUITEM_SETTING(sleeptimer_on_startup,
439 &global_settings.sleeptimer_on_startup, NULL);
440#endif
435 441
436MENUITEM_FUNCTION(show_credits_item, 0, ID2P(LANG_CREDITS), 442MENUITEM_FUNCTION(show_credits_item, 0, ID2P(LANG_CREDITS),
437 (menu_function)show_credits, NULL, NULL, Icon_NOICON); 443 (menu_function)show_credits, NULL, NULL, Icon_NOICON);
@@ -479,7 +485,7 @@ MAKE_MENU(main_menu_, ID2P(LANG_SETTINGS), mainmenu_callback,
479#if CONFIG_RTC 485#if CONFIG_RTC
480 &timedate_item, 486 &timedate_item,
481#else 487#else
482 &sleep_timer_call, 488 &sleep_timer_call, &sleeptimer_on_startup,
483#endif 489#endif
484 &manage_settings, 490 &manage_settings,
485 ); 491 );
diff --git a/apps/menus/time_menu.c b/apps/menus/time_menu.c
index 6631b46195..7059c5d92c 100644
--- a/apps/menus/time_menu.c
+++ b/apps/menus/time_menu.c
@@ -136,6 +136,9 @@ MENUITEM_FUNCTION(alarm_wake_up_screen, 0, ID2P(LANG_ALARM_WAKEUP_SCREEN),
136#endif /* CONFIG_TUNER || defined(HAVE_RECORDING) */ 136#endif /* CONFIG_TUNER || defined(HAVE_RECORDING) */
137 137
138#endif /* HAVE_RTC_ALARM */ 138#endif /* HAVE_RTC_ALARM */
139MENUITEM_SETTING(sleeptimer_on_startup,
140 &global_settings.sleeptimer_on_startup, NULL);
141
139static void talk_timedate(void) 142static void talk_timedate(void)
140{ 143{
141 struct tm *tm = get_time(); 144 struct tm *tm = get_time();
@@ -241,7 +244,7 @@ MAKE_MENU(time_menu, ID2P(LANG_TIME_MENU), time_menu_callback, Icon_NOICON,
241 &alarm_wake_up_screen, 244 &alarm_wake_up_screen,
242#endif 245#endif
243#endif 246#endif
244 &timeformat); 247 &sleeptimer_on_startup, &timeformat);
245 248
246int time_screen(void* ignored) 249int time_screen(void* ignored)
247{ 250{
diff --git a/apps/root_menu.c b/apps/root_menu.c
index 3b94d88751..1e9924fb44 100644
--- a/apps/root_menu.c
+++ b/apps/root_menu.c
@@ -660,6 +660,9 @@ void root_menu(void)
660 next_screen = GO_TO_ROOT; 660 next_screen = GO_TO_ROOT;
661#endif 661#endif
662 662
663 if (global_settings.sleeptimer_on_startup)
664 set_sleep_timer(global_settings.sleeptimer_duration * 60);
665
663 while (true) 666 while (true)
664 { 667 {
665 switch (next_screen) 668 switch (next_screen)
diff --git a/apps/settings.h b/apps/settings.h
index 927b17bf08..92ffaf9019 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -798,6 +798,9 @@ struct user_settings
798 int compressor_release_time; 798 int compressor_release_time;
799#endif 799#endif
800 800
801 int sleeptimer_duration;
802 bool sleeptimer_on_startup;
803
801#ifdef HAVE_MORSE_INPUT 804#ifdef HAVE_MORSE_INPUT
802 bool morse_input; /* text input method setting */ 805 bool morse_input; /* text input method setting */
803#endif 806#endif
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 7c5552a031..521d565f3b 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -549,6 +549,13 @@ static void tsc_set_default(void* setting, void* defaultval)
549 memcpy(setting, defaultval, sizeof(struct touchscreen_parameter)); 549 memcpy(setting, defaultval, sizeof(struct touchscreen_parameter));
550} 550}
551#endif 551#endif
552static const char* sleeptimer_formatter(char* buffer, size_t buffer_size,
553 int value, const char* unit)
554{
555 (void) unit;
556 snprintf(buffer, buffer_size, "%d:%02d", value / 60, value % 60);
557 return buffer;
558}
552#ifdef HAVE_HOTKEY 559#ifdef HAVE_HOTKEY
553static const char* hotkey_formatter(char* buffer, size_t buffer_size, int value, 560static const char* hotkey_formatter(char* buffer, size_t buffer_size, int value,
554 const char* unit) 561 const char* unit)
@@ -1759,6 +1766,11 @@ const struct settings_list settings[] = {
1759#endif /* CONFIG_CODEC == SWCODEC */ 1766#endif /* CONFIG_CODEC == SWCODEC */
1760 TEXT_SETTING(0, playlist_catalog_dir, "playlist catalog directory", 1767 TEXT_SETTING(0, playlist_catalog_dir, "playlist catalog directory",
1761 PLAYLIST_CATALOG_DEFAULT_DIR, NULL, NULL), 1768 PLAYLIST_CATALOG_DEFAULT_DIR, NULL, NULL),
1769 INT_SETTING(0, sleeptimer_duration, LANG_SLEEP_TIMER_DURATION, 30,
1770 "sleeptimer duration",
1771 UNIT_MIN, 5, 300, 5, sleeptimer_formatter, NULL, NULL),
1772 OFFON_SETTING(0, sleeptimer_on_startup, LANG_SLEEP_TIMER_ON_POWER_UP, false,
1773 "sleeptimer on startup", NULL),
1762#ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING 1774#ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING
1763 CHOICE_SETTING(0, touchpad_sensitivity, LANG_TOUCHPAD_SENSITIVITY, 0, 1775 CHOICE_SETTING(0, touchpad_sensitivity, LANG_TOUCHPAD_SENSITIVITY, 0,
1764 "touchpad sensitivity", "normal,high", touchpad_set_sensitivity, 2, 1776 "touchpad sensitivity", "normal,high", touchpad_set_sensitivity, 2,
diff --git a/manual/appendix/config_file_options.tex b/manual/appendix/config_file_options.tex
index a746198981..bfe314bb6f 100644
--- a/manual/appendix/config_file_options.tex
+++ b/manual/appendix/config_file_options.tex
@@ -104,6 +104,9 @@
104 104
105 idle poweroff & off, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 30, 45, 60 105 idle poweroff & off, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 30, 45, 60
106 & min\\ 106 & min\\
107 sleeptimer duration & 5 to 300 (in steps of 5)
108 & min\\
109 sleeptimer on startup & off, on & N/A\\
107 max files in playlist & 1000 - 32000 & N/A\\ 110 max files in playlist & 1000 - 32000 & N/A\\
108 max files in dir & 50 - 10000 & N/A\\ 111 max files in dir & 50 - 10000 & N/A\\
109 lang & /path/filename.lng & N/A\\ 112 lang & /path/filename.lng & N/A\\
diff --git a/manual/main_menu/main.tex b/manual/main_menu/main.tex
index 76063e8fd6..b43cfb1a8f 100644
--- a/manual/main_menu/main.tex
+++ b/manual/main_menu/main.tex
@@ -203,7 +203,9 @@ pages of information.}
203 \item[Sleep Timer:] 203 \item[Sleep Timer:]
204 The \setting{Sleep Timer} powers off your \dap{} after playing for a given 204 The \setting{Sleep Timer} powers off your \dap{} after playing for a given
205 time. It can be set from \setting{Off} to 5 hours in 5 minute steps. 205 time. It can be set from \setting{Off} to 5 hours in 5 minute steps.
206 The \setting{Sleep Timer} is reset on boot. 206 While the \setting{Sleep Timer} is reset on boot, the value selected is
207 retained and will be used as the default from then on.
208 If the sleep timer is currently active, \setting{Off} will be highlighted,
207 \opt{alarm}{ 209 \opt{alarm}{
208 \item[Wake-Up Alarm:] 210 \item[Wake-Up Alarm:]
209 This option will make the \dap{} start up at the specified time. 211 This option will make the \dap{} start up at the specified time.
@@ -212,12 +214,13 @@ pages of information.}
212 \ActionAlarmSet{} confirms the alarm, and \ActionAlarmCancel{} cancels setting 214 \ActionAlarmSet{} confirms the alarm, and \ActionAlarmCancel{} cancels setting
213 an alarm. If the \dap{} is turned on again before the alarm occurs, the alarm 215 an alarm. If the \dap{} is turned on again before the alarm occurs, the alarm
214 will be cancelled. 216 will be cancelled.
215
216 \opt{recording,radio}{ 217 \opt{recording,radio}{
217 \item[Alarm Wake Up Screen:] 218 \item[Alarm Wake Up Screen:]
218 This option controls what the \dap{} does when it is woken up by the alarm. 219 This option controls what the \dap{} does when it is woken up by the alarm.
219 }%\opt{recording,radio} 220 }%\opt{recording,radio}
220 }%\opt{alarm} 221 }%\opt{alarm}
222 \item[Start Sleep Timer On Boot:]
223 If set, a \setting{Sleep Timer} will be initiated when the device starts.
221 \item [Time Format:] Choose 12 or 24 hour clock. 224 \item [Time Format:] Choose 12 or 24 hour clock.
222 \end{description} 225 \end{description}
223}%\opt{rtc} 226}%\opt{rtc}
@@ -241,7 +244,11 @@ pages of information.}
241 \item[Sleep Timer:] 244 \item[Sleep Timer:]
242 The \setting{Sleep Timer} powers off your \dap{} after playing for a given 245 The \setting{Sleep Timer} powers off your \dap{} after playing for a given
243 time. It can be set from \setting{Off} to 5 hours in 5 minute steps. 246 time. It can be set from \setting{Off} to 5 hours in 5 minute steps.
244 The \setting{Sleep Timer} is reset on boot. 247 While the \setting{Sleep Timer} is reset on boot, the value selected is
248 retained and will be used as the default from then on.
249 If the sleep timer is currently active, \setting{Off} will be highlighted,
250 \item[Start Sleep Timer On Boot:]
251 If set, a \setting{Sleep Timer} will be initiated when the device starts.
245} 252}
246 253
247\item[Running Time:] 254\item[Running Time:]