diff options
| author | Thomas Martitz <kugel@rockbox.org> | 2011-10-17 18:57:38 +0000 |
|---|---|---|
| committer | Thomas Martitz <kugel@rockbox.org> | 2011-10-17 18:57:38 +0000 |
| commit | e347146b6268ece5b90bb6cf6fcb5c4e8f9b6a1e (patch) | |
| tree | 4b59a351430c3a5d2c51fc36c76c0b3711bf0d2a /apps | |
| parent | e44af440c50e2d87fcb57a91a8036e108a3b7362 (diff) | |
| download | rockbox-e347146b6268ece5b90bb6cf6fcb5c4e8f9b6a1e.zip rockbox-e347146b6268ece5b90bb6cf6fcb5c4e8f9b6a1e.tar.gz rockbox-e347146b6268ece5b90bb6cf6fcb5c4e8f9b6a1e.tar.bz2 rockbox-e347146b6268ece5b90bb6cf6fcb5c4e8f9b6a1e.tar.xz | |
Sleep timer options: persistent duration and start on boot.
This makes the sleep timer persistent, so that the duration is remembered
across reboots. Additionally, it adds a setting to automatically apply
it at boot.
Flyspray: FS#10849
Author: Nick Peskett
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30777 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/lang/english.lang | 28 | ||||
| -rw-r--r-- | apps/menus/main_menu.c | 12 | ||||
| -rw-r--r-- | apps/menus/time_menu.c | 5 | ||||
| -rw-r--r-- | apps/root_menu.c | 3 | ||||
| -rw-r--r-- | apps/settings.h | 3 | ||||
| -rw-r--r-- | apps/settings_list.c | 12 |
6 files changed, 59 insertions, 4 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang index eb3c963..3fc2c72 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -12861,3 +12861,31 @@ *: "Automatic" </voice> </phrase> +<phrase> + id: LANG_SLEEP_TIMER_DURATION + desc: default sleep timer duration in minutes + user: core + <source> + *: "Default Sleep Timer Duration" + </source> + <dest> + *: "Default Sleep Timer Duration" + </dest> + <voice> + *: "Default Sleep Timer Duration" + </voice> +</phrase> +<phrase> + id: LANG_SLEEP_TIMER_ON_POWER_UP + desc: whether sleep timer starts on power up + user: core + <source> + *: "Start Sleep Timer On Boot" + </source> + <dest> + *: "Start Sleep Timer On Boot" + </dest> + <voice> + *: "Start Sleep Timer On Boot" + </voice> +</phrase> diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c index 394ee7c..66d49a9 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, 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 @@ int time_screen(void* ignored); 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); @@ -479,7 +485,7 @@ MAKE_MENU(main_menu_, ID2P(LANG_SETTINGS), mainmenu_callback, #if CONFIG_RTC &timedate_item, #else - &sleep_timer_call, + &sleep_timer_call, &sleeptimer_on_startup, #endif &manage_settings, ); diff --git a/apps/menus/time_menu.c b/apps/menus/time_menu.c index 6631b46..7059c5d 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), #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(); @@ -241,7 +244,7 @@ MAKE_MENU(time_menu, ID2P(LANG_TIME_MENU), time_menu_callback, Icon_NOICON, &alarm_wake_up_screen, #endif #endif - &timeformat); + &sleeptimer_on_startup, &timeformat); int time_screen(void* ignored) { diff --git a/apps/root_menu.c b/apps/root_menu.c index 3b94d88..1e9924f 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c @@ -660,6 +660,9 @@ void root_menu(void) 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) diff --git a/apps/settings.h b/apps/settings.h index 927b17b..92ffaf9 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -798,6 +798,9 @@ struct user_settings int compressor_release_time; #endif + int sleeptimer_duration; + bool sleeptimer_on_startup; + #ifdef HAVE_MORSE_INPUT bool morse_input; /* text input method setting */ #endif diff --git a/apps/settings_list.c b/apps/settings_list.c index 7c5552a..521d565 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -549,6 +549,13 @@ static void tsc_set_default(void* setting, void* defaultval) 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) @@ -1759,6 +1766,11 @@ const struct settings_list settings[] = { #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, |