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 ****************************************************************************/
43 #include "alarm_menu.h"
44 #include "backlight.h"
46 #define MARGIN_Y (global_settings.statusbar ? STATUSBAR_HEIGHT : 0)
48 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 lcd_setfont(FONT_SYSFIXED
);
74 lcd_setmargins(0, MARGIN_Y
);
75 lcd_puts(0, 3, str(LANG_ALARM_MOD_KEYS
));
79 snprintf(buf
, 32, str(LANG_ALARM_MOD_TIME
), h
, m
);
83 button
= button_get_w_tmo(HZ
);
87 /* prevent that an alarm occurs in the shutdown procedure */
88 /* accept alarms only if they are in 2 minutes or more */
90 togo
= (m
+ h
* 60 - tm
->tm_min
- tm
->tm_hour
* 60 + 1440) % 1440;
94 rtc_enable_alarm(true);
95 splash(HZ
*2, true, str(LANG_ALARM_MOD_TIME_TO_GO
),
96 togo
/ 60, togo
% 60);
99 splash(HZ
, true, str(LANG_ALARM_MOD_ERROR
));
106 case BUTTON_RIGHT
| BUTTON_REPEAT
:
118 case BUTTON_LEFT
| BUTTON_REPEAT
:
128 #if CONFIG_KEYPAD == RECORDER_PAD
131 case BUTTON_UP
| BUTTON_REPEAT
:
137 case BUTTON_DOWN
| BUTTON_REPEAT
:
142 #if CONFIG_KEYPAD == RECORDER_PAD
148 rtc_enable_alarm(false);
149 splash(HZ
*2, true, str(LANG_ALARM_MOD_DISABLE
));
158 if(default_event_handler(button
) == SYS_USB_CONNECTED
)
160 rtc_enable_alarm(false);
170 #endif /* HAVE_ALARM_MOD */