1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2003 Uwe Freese
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
39 #include "alarm_menu.h"
40 #include "backlight.h"
42 #include "statusbar.h"
45 static void speak_time(int hours
, int minutes
, bool speak_hours
)
47 if (talk_menus_enabled()){
49 talk_value(hours
, UNIT_HOUR
, false);
50 talk_value(minutes
, UNIT_MIN
, true);
52 talk_value(minutes
, UNIT_MIN
, false);
57 bool alarm_screen(void)
67 bool hour_wrapped
= false;
69 rtc_get_alarm(&h
, &m
);
71 /* After a battery change the RTC values are out of range */
72 if (m
> 60 || h
> 24) {
76 m
= m
/ 5 * 5; /* 5 min accuracy should be enough */
84 screens
[i
].setmargins(0, 0);
85 gui_textarea_clear(&screens
[i
]);
86 screens
[i
].puts(0, 3, str(LANG_ALARM_MOD_KEYS
));
88 /* Talk when entering the wakeup screen */
89 if (talk_menus_enabled())
91 talk_value(h
, UNIT_HOUR
, true);
92 talk_value(m
, UNIT_MIN
, true);
97 snprintf(buf
, 32, str(LANG_ALARM_MOD_TIME
), h
, m
);
100 screens
[i
].puts(0, 1, buf
);
101 gui_textarea_update(&screens
[i
]);
103 button
= get_action(CONTEXT_SETTINGS
,HZ
);
107 /* prevent that an alarm occurs in the shutdown procedure */
108 /* accept alarms only if they are in 2 minutes or more */
110 togo
= (m
+ h
* 60 - tm
->tm_min
- tm
->tm_hour
* 60 + 1440) % 1440;
115 rtc_enable_alarm(true);
116 if (talk_menus_enabled())
118 talk_id(LANG_ALARM_MOD_TIME_TO_GO
, true);
119 talk_value(togo
/ 60, UNIT_HOUR
, true);
120 talk_value(togo
% 60, UNIT_MIN
, true);
121 talk_force_enqueue_next();
123 gui_syncsplash(HZ
*2, str(LANG_ALARM_MOD_TIME_TO_GO
),
124 togo
/ 60, togo
% 60);
127 gui_syncsplash(HZ
, ID2P(LANG_ALARM_MOD_ERROR
));
133 case ACTION_SETTINGS_INC
:
134 case ACTION_SETTINGS_INCREPEAT
:
144 speak_time(h
, m
, hour_wrapped
);
148 case ACTION_SETTINGS_DEC
:
149 case ACTION_SETTINGS_DECREPEAT
:
159 speak_time(h
, m
, hour_wrapped
);
163 case ACTION_STD_NEXT
:
164 case ACTION_STD_NEXTREPEAT
:
167 if (talk_menus_enabled())
168 talk_value(h
, UNIT_HOUR
, false);
172 case ACTION_STD_PREV
:
173 case ACTION_STD_PREVREPEAT
:
176 if (talk_menus_enabled())
177 talk_value(h
, UNIT_HOUR
, false);
180 case ACTION_STD_CANCEL
:
181 rtc_enable_alarm(false);
182 gui_syncsplash(HZ
*2, ID2P(LANG_ALARM_MOD_DISABLE
));
187 gui_syncstatusbar_draw(&statusbars
, false);
188 hour_wrapped
= false;
192 if(default_event_handler(button
) == SYS_USB_CONNECTED
)
194 rtc_enable_alarm(false);
203 #endif /* HAVE_RTC_ALARM */