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 ****************************************************************************/
41 #include "alarm_menu.h"
42 #include "backlight.h"
45 #include "statusbar.h"
47 #define MARGIN_Y (global_settings.statusbar ? STATUSBAR_HEIGHT : 0)
49 bool alarm_screen(void)
61 rtc_get_alarm(&h
, &m
);
63 /* After a battery change the RTC values are out of range */
64 if (m
> 60 || h
> 24) {
68 m
= m
/ 5 * 5; /* 5 min accuracy should be enough */
76 gui_textarea_clear(&screens
[i
]);
77 screens
[i
].puts(0, 3, str(LANG_ALARM_MOD_KEYS
));
82 snprintf(buf
, 32, str(LANG_ALARM_MOD_TIME
), h
, m
);
85 screens
[i
].puts(0, 1, buf
);
86 gui_textarea_update(&screens
[i
]);
88 button
= get_action(CONTEXT_SETTINGS
,HZ
);
92 /* prevent that an alarm occurs in the shutdown procedure */
93 /* accept alarms only if they are in 2 minutes or more */
95 togo
= (m
+ h
* 60 - tm
->tm_min
- tm
->tm_hour
* 60 + 1440) % 1440;
99 rtc_enable_alarm(true);
100 gui_syncsplash(HZ
*2, true, str(LANG_ALARM_MOD_TIME_TO_GO
),
101 togo
/ 60, togo
% 60);
104 gui_syncsplash(HZ
, true, str(LANG_ALARM_MOD_ERROR
));
110 case ACTION_SETTINGS_INC
:
111 case ACTION_SETTINGS_INCREPEAT
:
122 case ACTION_SETTINGS_DEC
:
123 case ACTION_SETTINGS_DECREPEAT
:
134 case ACTION_STD_NEXT
:
135 case ACTION_STD_NEXTREPEAT
:
140 case ACTION_STD_PREV
:
141 case ACTION_STD_PREVREPEAT
:
145 case ACTION_STD_CANCEL
:
146 rtc_enable_alarm(false);
147 gui_syncsplash(HZ
*2, true, str(LANG_ALARM_MOD_DISABLE
));
152 gui_syncstatusbar_draw(&statusbars
, false);
156 if(default_event_handler(button
) == SYS_USB_CONNECTED
)
158 rtc_enable_alarm(false);
164 action_signalscreenchange();
168 #endif /* HAVE_ALARM_MOD */