diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2005-07-06 08:24:24 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2005-07-06 08:24:24 +0000 |
commit | 50d9e3fba9cf1136fdf49293632aac7be00c795d (patch) | |
tree | 9131fc815e22568a0b205e79f5b85e1039088866 /apps | |
parent | 2023b4729304d4dce37e0b2222f27ab2012f5e25 (diff) | |
download | rockbox-50d9e3fba9cf1136fdf49293632aac7be00c795d.tar.gz rockbox-50d9e3fba9cf1136fdf49293632aac7be00c795d.zip |
Some interface updates and code policing in the alarm setting screen
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7037 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/alarm_menu.c | 89 |
1 files changed, 58 insertions, 31 deletions
diff --git a/apps/alarm_menu.c b/apps/alarm_menu.c index a3ddbeea79..a1b9947439 100644 --- a/apps/alarm_menu.c +++ b/apps/alarm_menu.c | |||
@@ -17,6 +17,11 @@ | |||
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include "config.h" | 19 | #include "config.h" |
20 | |||
21 | #ifdef HAVE_ALARM_MOD | ||
22 | |||
23 | #include <stdbool.h> | ||
24 | |||
20 | #include "options.h" | 25 | #include "options.h" |
21 | 26 | ||
22 | #include "lcd.h" | 27 | #include "lcd.h" |
@@ -28,72 +33,78 @@ | |||
28 | #include "settings.h" | 33 | #include "settings.h" |
29 | #include "power.h" | 34 | #include "power.h" |
30 | #include "status.h" | 35 | #include "status.h" |
36 | #include "icons.h" | ||
31 | #include "rtc.h" | 37 | #include "rtc.h" |
32 | #include <stdbool.h> | 38 | #include "misc.h" |
39 | #include "screens.h" | ||
33 | 40 | ||
34 | #include "lang.h" | 41 | #include "lang.h" |
35 | #include "power.h" | 42 | #include "power.h" |
36 | #include "alarm_menu.h" | 43 | #include "alarm_menu.h" |
37 | #include "backlight.h" | 44 | #include "backlight.h" |
38 | 45 | ||
39 | #ifdef HAVE_ALARM_MOD | 46 | #define MARGIN_Y (global_settings.statusbar ? STATUSBAR_HEIGHT : 0) |
40 | 47 | ||
41 | bool alarm_screen(void) | 48 | bool alarm_screen(void) |
42 | { | 49 | { |
43 | /* get alarm time from RTC */ | 50 | int h, m; |
44 | 51 | bool done=false; | |
45 | int h, m, hour, minute; | 52 | char buf[32]; |
53 | struct tm *tm; | ||
54 | int togo; | ||
55 | int button; | ||
56 | bool update = true; | ||
46 | 57 | ||
47 | rtc_get_alarm(&h, &m); | 58 | rtc_get_alarm(&h, &m); |
48 | 59 | ||
49 | if (m > 60 || h > 24) { /* after battery-change RTC-values are out of range */ | 60 | /* After a battery change the RTC values are out of range */ |
61 | if (m > 60 || h > 24) { | ||
50 | m = 0; | 62 | m = 0; |
51 | h = 12; | 63 | h = 12; |
52 | } else { | 64 | } else { |
53 | m = m / 5 * 5; /* 5 min accuracy should be enough */ | 65 | m = m / 5 * 5; /* 5 min accuracy should be enough */ |
54 | } | 66 | } |
55 | 67 | ||
56 | bool done=false; | ||
57 | char buf[32]; | ||
58 | |||
59 | lcd_clear_display(); | ||
60 | lcd_setfont(FONT_SYSFIXED); | ||
61 | lcd_setmargins(0, 0); | ||
62 | lcd_puts(0,1, str(LANG_ALARM_MOD_KEYS)); | ||
63 | |||
64 | while(!done) { | 68 | while(!done) { |
69 | if(update) | ||
70 | { | ||
71 | lcd_clear_display(); | ||
72 | status_draw(true); | ||
73 | lcd_setfont(FONT_SYSFIXED); | ||
74 | lcd_setmargins(0, MARGIN_Y); | ||
75 | lcd_puts(0, 3, str(LANG_ALARM_MOD_KEYS)); | ||
76 | update = false; | ||
77 | } | ||
78 | |||
65 | snprintf(buf, 32, str(LANG_ALARM_MOD_TIME), h, m); | 79 | snprintf(buf, 32, str(LANG_ALARM_MOD_TIME), h, m); |
66 | lcd_puts(0,0, buf); | 80 | lcd_puts(0, 1, buf); |
67 | lcd_update(); | 81 | lcd_update(); |
82 | |||
83 | button = button_get_w_tmo(HZ); | ||
68 | 84 | ||
69 | switch(button_get(true)) { | 85 | switch(button) { |
70 | case BUTTON_PLAY: | 86 | case BUTTON_PLAY: |
71 | /* prevent that an alarm occurs in the shutdown procedure */ | 87 | /* prevent that an alarm occurs in the shutdown procedure */ |
72 | /* accept alarms only if they are in 2 minutes or more */ | 88 | /* accept alarms only if they are in 2 minutes or more */ |
73 | hour = rtc_read(0x03); | 89 | tm = get_time(); |
74 | hour = ((hour & 0x30) >> 4) * 10 + (hour & 0x0f); | 90 | togo = (m + h * 60 - tm->tm_min - tm->tm_hour * 60 + 1440) % 1440; |
75 | minute = rtc_read(0x02); | ||
76 | minute = ((minute & 0x70) >> 4) * 10 + (minute & 0x0f); | ||
77 | int togo = (m + h * 60 - minute - hour * 60 + 1440) % 1440; | ||
78 | if (togo > 1) { | 91 | if (togo > 1) { |
79 | lcd_clear_display(); | ||
80 | snprintf(buf, 32, str(LANG_ALARM_MOD_TIME_TO_GO), togo / 60, togo % 60); | ||
81 | lcd_puts(0,0, buf); | ||
82 | lcd_update(); | ||
83 | rtc_init(); | 92 | rtc_init(); |
84 | rtc_set_alarm(h,m); | 93 | rtc_set_alarm(h,m); |
85 | rtc_enable_alarm(true); | 94 | rtc_enable_alarm(true); |
95 | <<<<<<< alarm_menu.c | ||
96 | splash(HZ*2, true, str(LANG_ALARM_MOD_TIME_TO_GO), | ||
97 | togo / 60, togo % 60); | ||
98 | done = true; | ||
99 | ======= | ||
86 | lcd_puts(0,1,str(LANG_ALARM_MOD_SHUTDOWN)); | 100 | lcd_puts(0,1,str(LANG_ALARM_MOD_SHUTDOWN)); |
87 | lcd_update(); | 101 | lcd_update(); |
88 | sleep(HZ); | 102 | sleep(HZ); |
89 | done = true; | 103 | done = true; |
104 | >>>>>>> 1.7 | ||
90 | } else { | 105 | } else { |
91 | lcd_clear_display(); | 106 | splash(HZ, true, str(LANG_ALARM_MOD_ERROR)); |
92 | lcd_puts(0,0,str(LANG_ALARM_MOD_ERROR)); | 107 | update = true; |
93 | lcd_update(); | ||
94 | sleep(HZ); | ||
95 | lcd_clear_display(); | ||
96 | lcd_puts(0,1,str(LANG_ALARM_MOD_KEYS)); | ||
97 | } | 108 | } |
98 | break; | 109 | break; |
99 | 110 | ||
@@ -141,13 +152,29 @@ bool alarm_screen(void) | |||
141 | case BUTTON_STOP: | 152 | case BUTTON_STOP: |
142 | case BUTTON_MENU: | 153 | case BUTTON_MENU: |
143 | #endif | 154 | #endif |
155 | <<<<<<< alarm_menu.c | ||
156 | ======= | ||
144 | lcd_clear_display(); | 157 | lcd_clear_display(); |
145 | lcd_puts(0,0,str(LANG_ALARM_MOD_DISABLE)); | 158 | lcd_puts(0,0,str(LANG_ALARM_MOD_DISABLE)); |
146 | lcd_update(); | 159 | lcd_update(); |
147 | sleep(HZ); | 160 | sleep(HZ); |
161 | >>>>>>> 1.7 | ||
148 | rtc_enable_alarm(false); | 162 | rtc_enable_alarm(false); |
163 | splash(HZ*2, true, str(LANG_ALARM_MOD_DISABLE)); | ||
149 | done = true; | 164 | done = true; |
150 | break; | 165 | break; |
166 | |||
167 | case BUTTON_NONE: | ||
168 | status_draw(false); | ||
169 | break; | ||
170 | |||
171 | default: | ||
172 | if(default_event_handler(button) == SYS_USB_CONNECTED) | ||
173 | { | ||
174 | rtc_enable_alarm(false); | ||
175 | return true; | ||
176 | } | ||
177 | break; | ||
151 | } | 178 | } |
152 | } | 179 | } |
153 | 180 | ||