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"
43 #include "statusbar.h"
46 bool alarm_screen(void)
58 rtc_get_alarm(&h
, &m
);
60 /* After a battery change the RTC values are out of range */
61 if (m
> 60 || h
> 24) {
65 m
= m
/ 5 * 5; /* 5 min accuracy should be enough */
73 screens
[i
].setmargins(0, 0);
74 gui_textarea_clear(&screens
[i
]);
75 screens
[i
].puts(0, 3, str(LANG_ALARM_MOD_KEYS
));
80 snprintf(buf
, 32, str(LANG_ALARM_MOD_TIME
), h
, m
);
83 screens
[i
].puts(0, 1, buf
);
84 gui_textarea_update(&screens
[i
]);
86 button
= get_action(CONTEXT_SETTINGS
,HZ
);
90 /* prevent that an alarm occurs in the shutdown procedure */
91 /* accept alarms only if they are in 2 minutes or more */
93 togo
= (m
+ h
* 60 - tm
->tm_min
- tm
->tm_hour
* 60 + 1440) % 1440;
97 rtc_enable_alarm(true);
98 gui_syncsplash(HZ
*2, str(LANG_ALARM_MOD_TIME_TO_GO
),
99 togo
/ 60, togo
% 60);
102 gui_syncsplash(HZ
, str(LANG_ALARM_MOD_ERROR
));
108 case ACTION_SETTINGS_INC
:
109 case ACTION_SETTINGS_INCREPEAT
:
120 case ACTION_SETTINGS_DEC
:
121 case ACTION_SETTINGS_DECREPEAT
:
132 case ACTION_STD_NEXT
:
133 case ACTION_STD_NEXTREPEAT
:
138 case ACTION_STD_PREV
:
139 case ACTION_STD_PREVREPEAT
:
143 case ACTION_STD_CANCEL
:
144 rtc_enable_alarm(false);
145 gui_syncsplash(HZ
*2, str(LANG_ALARM_MOD_DISABLE
));
150 gui_syncstatusbar_draw(&statusbars
, false);
154 if(default_event_handler(button
) == SYS_USB_CONNECTED
)
156 rtc_enable_alarm(false);
162 action_signalscreenchange();
166 #endif /* HAVE_RTC_ALARM */