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)
60 rtc_get_alarm(&h
, &m
);
62 /* After a battery change the RTC values are out of range */
63 if (m
> 60 || h
> 24) {
67 m
= m
/ 5 * 5; /* 5 min accuracy should be enough */
75 gui_textarea_clear(&screens
[i
]);
76 screens
[i
].puts(0, 3, str(LANG_ALARM_MOD_KEYS
));
81 snprintf(buf
, 32, str(LANG_ALARM_MOD_TIME
), h
, m
);
84 screens
[i
].puts(0, 1, buf
);
85 gui_textarea_update(&screens
[i
]);
87 button
= button_get_w_tmo(HZ
);
91 /* prevent that an alarm occurs in the shutdown procedure */
92 /* accept alarms only if they are in 2 minutes or more */
94 togo
= (m
+ h
* 60 - tm
->tm_min
- tm
->tm_hour
* 60 + 1440) % 1440;
98 rtc_enable_alarm(true);
99 gui_syncsplash(HZ
*2, true, str(LANG_ALARM_MOD_TIME_TO_GO
),
100 togo
/ 60, togo
% 60);
103 gui_syncsplash(HZ
, true, str(LANG_ALARM_MOD_ERROR
));
110 case BUTTON_RIGHT
| BUTTON_REPEAT
:
122 case BUTTON_LEFT
| BUTTON_REPEAT
:
132 #if CONFIG_KEYPAD == RECORDER_PAD
135 case BUTTON_UP
| BUTTON_REPEAT
:
141 case BUTTON_DOWN
| BUTTON_REPEAT
:
146 #if CONFIG_KEYPAD == RECORDER_PAD
152 rtc_enable_alarm(false);
153 gui_syncsplash(HZ
*2, true, str(LANG_ALARM_MOD_DISABLE
));
158 gui_syncstatusbar_draw(&statusbars
, false);
162 if(default_event_handler(button
) == SYS_USB_CONNECTED
)
164 rtc_enable_alarm(false);
174 #endif /* HAVE_ALARM_MOD */