summaryrefslogtreecommitdiff
path: root/apps/menus
diff options
context:
space:
mode:
Diffstat (limited to 'apps/menus')
-rw-r--r--apps/menus/settings_menu.c62
-rw-r--r--apps/menus/time_menu.c17
2 files changed, 7 insertions, 72 deletions
diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c
index 03c17b24e5..1e1572f15e 100644
--- a/apps/menus/settings_menu.c
+++ b/apps/menus/settings_menu.c
@@ -57,6 +57,7 @@
57#endif 57#endif
58#include "plugin.h" 58#include "plugin.h"
59#include "onplay.h" 59#include "onplay.h"
60#include "misc.h"
60 61
61#ifndef HAS_BUTTON_HOLD 62#ifndef HAS_BUTTON_HOLD
62static int selectivesoftlock_callback(int action, 63static int selectivesoftlock_callback(int action,
@@ -496,69 +497,20 @@ MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
496/***********************************/ 497/***********************************/
497/* STARTUP/SHUTDOWN MENU */ 498/* STARTUP/SHUTDOWN MENU */
498 499
499/* sleep timer option */
500const char* sleep_timer_formatter(char* buffer, size_t buffer_size,
501 int value, const char* unit)
502{
503 (void) unit;
504 int minutes, hours;
505
506 if (value) {
507 hours = value / 60;
508 minutes = value - (hours * 60);
509 snprintf(buffer, buffer_size, "%d:%02d", hours, minutes);
510 return buffer;
511 } else {
512 return str(LANG_OFF);
513 }
514}
515
516static int seconds_to_min(int secs)
517{
518 return (secs + 10) / 60; /* round up for 50+ seconds */
519}
520 500
521/* A string representation of either whether a sleep timer will be started or 501char* sleeptimer_getname(int selected_item, void * data,
522 canceled, and how long it will be or how long is remaining in brackets */ 502 char *buffer, size_t buffer_len)
523char* sleep_timer_getname(int selected_item, void * data,
524 char *buffer, size_t buffer_len)
525{ 503{
526 (void)selected_item; 504 (void)selected_item;
527 (void)data; 505 (void)data;
528 int sec = get_sleep_timer(); 506 return string_sleeptimer(buffer, buffer_len);
529 char timer_buf[10];
530
531 snprintf(buffer, buffer_len, "%s (%s)",
532 str(sec ? LANG_SLEEP_TIMER_CANCEL_CURRENT
533 : LANG_SLEEP_TIMER_START_CURRENT),
534 sleep_timer_formatter(timer_buf, sizeof(timer_buf),
535 sec ? seconds_to_min(sec)
536 : global_settings.sleeptimer_duration, NULL));
537 return buffer;
538} 507}
539 508
540int sleep_timer_voice(int selected_item, void*data) 509int sleeptimer_voice(int selected_item, void*data)
541{ 510{
542 (void)selected_item; 511 (void)selected_item;
543 (void)data; 512 (void)data;
544 int seconds = get_sleep_timer(); 513 talk_sleeptimer();
545 long talk_ids[] = {
546 seconds ? LANG_SLEEP_TIMER_CANCEL_CURRENT
547 : LANG_SLEEP_TIMER_START_CURRENT,
548 VOICE_PAUSE,
549 (seconds ? seconds_to_min(seconds)
550 : global_settings.sleeptimer_duration) | UNIT_MIN << UNIT_SHIFT,
551 TALK_FINAL_ID
552 };
553 talk_idarray(talk_ids, true);
554 return 0;
555}
556
557/* If a sleep timer is running, cancel it, otherwise start one */
558int toggle_sleeptimer(void)
559{
560 set_sleeptimer_duration(get_sleep_timer() ? 0
561 : global_settings.sleeptimer_duration);
562 return 0; 514 return 0;
563} 515}
564 516
@@ -587,7 +539,7 @@ static int sleeptimer_duration_cb(int action,
587MENUITEM_SETTING(start_screen, &global_settings.start_in_screen, NULL); 539MENUITEM_SETTING(start_screen, &global_settings.start_in_screen, NULL);
588MENUITEM_SETTING(poweroff, &global_settings.poweroff, NULL); 540MENUITEM_SETTING(poweroff, &global_settings.poweroff, NULL);
589MENUITEM_FUNCTION_DYNTEXT(sleeptimer_toggle, 0, toggle_sleeptimer, 541MENUITEM_FUNCTION_DYNTEXT(sleeptimer_toggle, 0, toggle_sleeptimer,
590 sleep_timer_getname, sleep_timer_voice, NULL, 542 sleeptimer_getname, sleeptimer_voice, NULL,
591 NULL, Icon_NOICON); 543 NULL, Icon_NOICON);
592MENUITEM_SETTING(sleeptimer_duration, 544MENUITEM_SETTING(sleeptimer_duration,
593 &global_settings.sleeptimer_duration, 545 &global_settings.sleeptimer_duration,
diff --git a/apps/menus/time_menu.c b/apps/menus/time_menu.c
index e6b5637047..79a38a1a57 100644
--- a/apps/menus/time_menu.c
+++ b/apps/menus/time_menu.c
@@ -144,23 +144,6 @@ MENUITEM_FUNCTION(alarm_wake_up_screen, 0, ID2P(LANG_ALARM_WAKEUP_SCREEN),
144 144
145#endif /* HAVE_RTC_ALARM */ 145#endif /* HAVE_RTC_ALARM */
146 146
147void talk_timedate(void)
148{
149 struct tm *tm = get_time();
150 if (!global_settings.talk_menu)
151 return;
152 talk_id(VOICE_CURRENT_TIME, false);
153 if (valid_time(tm))
154 {
155 talk_time(tm, true);
156 talk_date(get_time(), true);
157 }
158 else
159 {
160 talk_id(LANG_UNKNOWN, true);
161 }
162}
163
164static void draw_timedate(struct viewport *vp, struct screen *display) 147static void draw_timedate(struct viewport *vp, struct screen *display)
165{ 148{
166 struct tm *tm = get_time(); 149 struct tm *tm = get_time();