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 ****************************************************************************/
36 #include "alarm_menu.h"
37 #include "backlight.h"
41 bool alarm_screen(void)
43 /* get alarm time from RTC */
45 int h
, m
, hour
, minute
;
47 rtc_get_alarm(&h
, &m
);
49 if (m
> 60 || h
> 24) { /* after battery-change RTC-values are out of range */
53 m
= m
/ 5 * 5; /* 5 min accuracy should be enough */
60 lcd_setfont(FONT_SYSFIXED
);
62 lcd_puts(0,1, str(LANG_ALARM_MOD_KEYS
));
65 snprintf(buf
, 32, str(LANG_ALARM_MOD_TIME
), h
, m
);
69 switch(button_get(true)) {
71 /* prevent that an alarm occurs in the shutdown procedure */
72 /* accept alarms only if they are in 2 minutes or more */
73 hour
= rtc_read(0x03);
74 hour
= ((hour
& 0x30) >> 4) * 10 + (hour
& 0x0f);
75 minute
= rtc_read(0x02);
76 minute
= ((minute
& 0x70) >> 4) * 10 + (minute
& 0x0f);
77 int togo
= (m
+ h
* 60 - minute
- hour
* 60 + 1440) % 1440;
80 snprintf(buf
, 32, str(LANG_ALARM_MOD_TIME_TO_GO
), togo
/ 60, togo
% 60);
85 /* in some cases enabling the alarm results in an activated AF flag */
86 /* this should not happen, but it does */
87 /* if you know why, tell me! */
88 /* for now, we try again forever in this case */
89 while (rtc_enable_alarm(true)) { /* error occured */
95 lcd_puts(0,1,str(LANG_ALARM_MOD_SHUTDOWN
));
101 lcd_puts(0,0,str(LANG_ALARM_MOD_ERROR
));
105 lcd_puts(0,1,str(LANG_ALARM_MOD_KEYS
));
111 case BUTTON_RIGHT
| BUTTON_REPEAT
:
123 case BUTTON_LEFT
| BUTTON_REPEAT
:
133 #if CONFIG_KEYPAD == RECORDER_PAD
136 case BUTTON_UP
| BUTTON_REPEAT
:
142 case BUTTON_DOWN
| BUTTON_REPEAT
:
147 #if CONFIG_KEYPAD == RECORDER_PAD
161 #endif /* HAVE_ALARM_MOD */