summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/menus/main_menu.c2
-rw-r--r--apps/menus/time_menu.c2
-rw-r--r--apps/shortcuts.c54
-rw-r--r--apps/shortcuts.h1
-rw-r--r--manual/main_menu/main.tex5
5 files changed, 55 insertions, 9 deletions
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c
index b6ce9e75c6..130d0bc2d5 100644
--- a/apps/menus/main_menu.c
+++ b/apps/menus/main_menu.c
@@ -376,7 +376,7 @@ MENUITEM_FUNCTION(show_info_item, 0, ID2P(LANG_ROCKBOX_INFO),
376 376
377 377
378/* sleep Menu */ 378/* sleep Menu */
379static const char* sleep_timer_formatter(char* buffer, size_t buffer_size, 379const char* sleep_timer_formatter(char* buffer, size_t buffer_size,
380 int value, const char* unit) 380 int value, const char* unit)
381{ 381{
382 (void) unit; 382 (void) unit;
diff --git a/apps/menus/time_menu.c b/apps/menus/time_menu.c
index 9be335c8ee..a793809800 100644
--- a/apps/menus/time_menu.c
+++ b/apps/menus/time_menu.c
@@ -139,7 +139,7 @@ MENUITEM_FUNCTION(alarm_wake_up_screen, 0, ID2P(LANG_ALARM_WAKEUP_SCREEN),
139MENUITEM_SETTING(sleeptimer_on_startup, 139MENUITEM_SETTING(sleeptimer_on_startup,
140 &global_settings.sleeptimer_on_startup, NULL); 140 &global_settings.sleeptimer_on_startup, NULL);
141 141
142static void talk_timedate(void) 142void talk_timedate(void)
143{ 143{
144 struct tm *tm = get_time(); 144 struct tm *tm = get_time();
145 if (!global_settings.talk_menu) 145 if (!global_settings.talk_menu)
diff --git a/apps/shortcuts.c b/apps/shortcuts.c
index 10c090f3eb..6997491424 100644
--- a/apps/shortcuts.c
+++ b/apps/shortcuts.c
@@ -55,6 +55,7 @@ static const char * const type_strings[SHORTCUT_TYPE_COUNT] = {
55 [SHORTCUT_PLAYLISTMENU] = "playlist menu", 55 [SHORTCUT_PLAYLISTMENU] = "playlist menu",
56 [SHORTCUT_SEPARATOR] = "separator", 56 [SHORTCUT_SEPARATOR] = "separator",
57 [SHORTCUT_SHUTDOWN] = "shutdown", 57 [SHORTCUT_SHUTDOWN] = "shutdown",
58 [SHORTCUT_TIME] = "time",
58}; 59};
59 60
60struct shortcut { 61struct shortcut {
@@ -64,6 +65,12 @@ struct shortcut {
64 union { 65 union {
65 char path[MAX_PATH]; 66 char path[MAX_PATH];
66 const struct settings_list *setting; 67 const struct settings_list *setting;
68 struct {
69#if CONFIG_RTC
70 bool talktime;
71#endif
72 int sleep_timeout;
73 } timedata;
67 } u; 74 } u;
68}; 75};
69#define SHORTCUTS_PER_HANDLE 32 76#define SHORTCUTS_PER_HANDLE 32
@@ -135,11 +142,11 @@ static bool verify_shortcut(struct shortcut* sc)
135 case SHORTCUT_BROWSER: 142 case SHORTCUT_BROWSER:
136 case SHORTCUT_FILE: 143 case SHORTCUT_FILE:
137 case SHORTCUT_PLAYLISTMENU: 144 case SHORTCUT_PLAYLISTMENU:
138 if (sc->u.path[0] == '\0') 145 return sc->u.path[0] != '0';
139 return false;
140 break;
141 case SHORTCUT_SETTING: 146 case SHORTCUT_SETTING:
142 return sc->u.setting != NULL; 147 return sc->u.setting != NULL;
148 case SHORTCUT_TIME:
149 return sc->name[0] != '0';
143 case SHORTCUT_DEBUGITEM: 150 case SHORTCUT_DEBUGITEM:
144 case SHORTCUT_SEPARATOR: 151 case SHORTCUT_SEPARATOR:
145 case SHORTCUT_SHUTDOWN: 152 case SHORTCUT_SHUTDOWN:
@@ -193,7 +200,7 @@ void shortcuts_ata_idle_callback(void* data)
193 */ 200 */
194 reset_shortcuts(); 201 reset_shortcuts();
195 shortcuts_init(); 202 shortcuts_init();
196 } 203 }
197 first_idx_to_writeback = -1; 204 first_idx_to_writeback = -1;
198} 205}
199 206
@@ -212,7 +219,6 @@ void shortcuts_add(enum shortcut_type type, const char* value)
212 first_idx_to_writeback = shortcut_count - 1; 219 first_idx_to_writeback = shortcut_count - 1;
213 register_storage_idle_func(shortcuts_ata_idle_callback); 220 register_storage_idle_func(shortcuts_ata_idle_callback);
214} 221}
215
216 222
217int readline_cb(int n, char *buf, void *parameters) 223int readline_cb(int n, char *buf, void *parameters)
218{ 224{
@@ -262,6 +268,20 @@ int readline_cb(int n, char *buf, void *parameters)
262 case SHORTCUT_SETTING: 268 case SHORTCUT_SETTING:
263 sc->u.setting = find_setting_by_cfgname(value, NULL); 269 sc->u.setting = find_setting_by_cfgname(value, NULL);
264 break; 270 break;
271 case SHORTCUT_TIME:
272#if CONFIG_RTC
273 if (!strcasecmp(value, "talk"))
274 sc->u.timedata.talktime = true;
275 else
276#endif
277 if (!strncasecmp(value, "sleep ", strlen("sleep ")))
278 {
279 sc->u.timedata.talktime = false;
280 sc->u.timedata.sleep_timeout = atoi(&value[strlen("sleep ")]);
281 }
282 else
283 sc->type = SHORTCUT_UNDEFINED; /* error */
284 break;
265 case SHORTCUT_SEPARATOR: 285 case SHORTCUT_SEPARATOR:
266 case SHORTCUT_SHUTDOWN: 286 case SHORTCUT_SHUTDOWN:
267 break; 287 break;
@@ -314,7 +334,7 @@ static const char * shortcut_menu_get_name(int selected_item, void * data,
314 return ""; 334 return "";
315 if (sc->type == SHORTCUT_SETTING) 335 if (sc->type == SHORTCUT_SETTING)
316 return sc->name[0] ? sc->name : P2STR(ID2P(sc->u.setting->lang_id)); 336 return sc->name[0] ? sc->name : P2STR(ID2P(sc->u.setting->lang_id));
317 else if (sc->type == SHORTCUT_SEPARATOR) 337 else if (sc->type == SHORTCUT_SEPARATOR || sc->type == SHORTCUT_TIME)
318 return sc->name; 338 return sc->name;
319 else if (sc->type == SHORTCUT_SHUTDOWN && sc->name[0] == '\0') 339 else if (sc->type == SHORTCUT_SHUTDOWN && sc->name[0] == '\0')
320 { 340 {
@@ -354,6 +374,8 @@ static enum themable_icons shortcut_menu_get_icon(int selected_item, void * data
354 return Icon_Playlist; 374 return Icon_Playlist;
355 case SHORTCUT_SHUTDOWN: 375 case SHORTCUT_SHUTDOWN:
356 return Icon_System_menu; 376 return Icon_System_menu;
377 case SHORTCUT_TIME:
378 return Icon_Menu_functioncall;
357 default: 379 default:
358 break; 380 break;
359 } 381 }
@@ -361,6 +383,10 @@ static enum themable_icons shortcut_menu_get_icon(int selected_item, void * data
361 return sc->icon; 383 return sc->icon;
362} 384}
363 385
386void talk_timedate(void);
387const char* sleep_timer_formatter(char* buffer, size_t buffer_size,
388 int value, const char* unit);
389
364int do_shortcut_menu(void *ignored) 390int do_shortcut_menu(void *ignored)
365{ 391{
366 (void)ignored; 392 (void)ignored;
@@ -377,7 +403,7 @@ int do_shortcut_menu(void *ignored)
377 list.title_icon = Icon_Bookmark; 403 list.title_icon = Icon_Bookmark;
378 404
379 push_current_activity(ACTIVITY_SHORTCUTSMENU); 405 push_current_activity(ACTIVITY_SHORTCUTSMENU);
380 406
381 while (done == GO_TO_PREVIOUS) 407 while (done == GO_TO_PREVIOUS)
382 { 408 {
383 if (simplelist_show_list(&list)) 409 if (simplelist_show_list(&list))
@@ -434,6 +460,20 @@ int do_shortcut_menu(void *ignored)
434#endif 460#endif
435 sys_poweroff(); 461 sys_poweroff();
436 break; 462 break;
463 case SHORTCUT_TIME:
464#if CONFIG_RTC
465 if (sc->u.timedata.talktime)
466 talk_timedate();
467 else
468#endif
469 {
470 char timer_buf[10];
471 set_sleep_timer(sc->u.timedata.sleep_timeout * 60);
472 splashf(HZ, "%s (%s)", str(LANG_SLEEP_TIMER),
473 sleep_timer_formatter(timer_buf, sizeof(timer_buf),
474 sc->u.timedata.sleep_timeout, NULL));
475 }
476 break;
437 case SHORTCUT_UNDEFINED: 477 case SHORTCUT_UNDEFINED:
438 default: 478 default:
439 break; 479 break;
diff --git a/apps/shortcuts.h b/apps/shortcuts.h
index c18834a66f..e5e05628bb 100644
--- a/apps/shortcuts.h
+++ b/apps/shortcuts.h
@@ -33,6 +33,7 @@ enum shortcut_type {
33 SHORTCUT_PLAYLISTMENU, 33 SHORTCUT_PLAYLISTMENU,
34 SHORTCUT_SEPARATOR, 34 SHORTCUT_SEPARATOR,
35 SHORTCUT_SHUTDOWN, 35 SHORTCUT_SHUTDOWN,
36 SHORTCUT_TIME,
36 37
37 SHORTCUT_TYPE_COUNT 38 SHORTCUT_TYPE_COUNT
38}; 39};
diff --git a/manual/main_menu/main.tex b/manual/main_menu/main.tex
index 4d3e223e0f..15da738e1b 100644
--- a/manual/main_menu/main.tex
+++ b/manual/main_menu/main.tex
@@ -281,6 +281,8 @@ settings. With a shortcut,
281 \setting{Quick Screen}) 281 \setting{Quick Screen})
282 \item A debug menu item can be displayed (useful for developers mostly) 282 \item A debug menu item can be displayed (useful for developers mostly)
283 \item The \dap{} can be turned off 283 \item The \dap{} can be turned off
284 \item A shortcut to have the time spoken
285 \item A shortcut to confgure the sleep timer
284\end{itemize} 286\end{itemize}
285 287
286\note{Shortcuts into the database are not possible} 288\note{Shortcuts into the database are not possible}
@@ -311,6 +313,9 @@ Available types are:
311\item[separator] \config{data} is ignored; \config{name} can be used to display text, 313\item[separator] \config{data} is ignored; \config{name} can be used to display text,
312 or left blank to make the list more accessible with visual gaps 314 or left blank to make the list more accessible with visual gaps
313\item[shutdown] \config{data} is ignored; \config{name} can be used to display text 315\item[shutdown] \config{data} is ignored; \config{name} can be used to display text
316\item[time] \config{data} needs to be either ``talk`` to talk the time, or ``sleep X``
317 where X is the number of minutes to run the sleep timer for (0 to disable). \config{name}
318 is required for this shortcut type.
314\end{description} 319\end{description}
315 320
316If the name/icon items are not specified, a sensible default will be used. 321If the name/icon items are not specified, a sensible default will be used.