diff options
author | Uwe Freese <thebreaker@rockbox.org> | 2003-01-22 12:50:34 +0000 |
---|---|---|
committer | Uwe Freese <thebreaker@rockbox.org> | 2003-01-22 12:50:34 +0000 |
commit | 86352ccc3f47bc0f6bdcdcdc7b752f0836900fcd (patch) | |
tree | 6bb892fcae88e04a3a45239236cd3dde97d8d7ce /apps | |
parent | fa2229559802f7066b55cc2ab0761c9e742658f7 (diff) | |
download | rockbox-86352ccc3f47bc0f6bdcdcdc7b752f0836900fcd.tar.gz rockbox-86352ccc3f47bc0f6bdcdcdc7b752f0836900fcd.zip |
Code for alarm mod. Enable with adding -DHAVE_ALARM_MOD in Makefile (EXTRA_DEFINES).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3150 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/alarm_menu.c | 154 | ||||
-rw-r--r-- | apps/alarm_menu.h | 24 | ||||
-rw-r--r-- | apps/lang/deutsch.lang | 80 | ||||
-rw-r--r-- | apps/lang/english.lang | 30 | ||||
-rw-r--r-- | apps/main_menu.c | 13 |
5 files changed, 298 insertions, 3 deletions
diff --git a/apps/alarm_menu.c b/apps/alarm_menu.c new file mode 100644 index 0000000000..ba16743c82 --- /dev/null +++ b/apps/alarm_menu.c | |||
@@ -0,0 +1,154 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2003 Uwe Freese | ||
11 | * | ||
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. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include "options.h" | ||
21 | |||
22 | #include "lcd.h" | ||
23 | #include "font.h" | ||
24 | #include "button.h" | ||
25 | #include "kernel.h" | ||
26 | #include "sprintf.h" | ||
27 | #include <string.h> | ||
28 | #include "settings.h" | ||
29 | #include "power.h" | ||
30 | #include "status.h" | ||
31 | #include "rtc.h" | ||
32 | #include <stdbool.h> | ||
33 | |||
34 | #include "lang.h" | ||
35 | #include "power.h" | ||
36 | #include "alarm_menu.h" | ||
37 | #include "backlight.h" | ||
38 | |||
39 | #ifdef HAVE_ALARM_MOD | ||
40 | |||
41 | bool alarm_screen(void) | ||
42 | { | ||
43 | /* get alarm time from RTC */ | ||
44 | |||
45 | int h, m, hour, minute; | ||
46 | |||
47 | rtc_get_alarm(&h, &m); | ||
48 | |||
49 | m = m / 5 * 5; /* 5 min accuracy should be enough */ | ||
50 | |||
51 | bool done=false; | ||
52 | char buf[32]; | ||
53 | |||
54 | lcd_clear_display(); | ||
55 | lcd_puts(0,1, str(LANG_ALARM_MOD_KEYS)); | ||
56 | |||
57 | while(!done) { | ||
58 | snprintf(buf, 32, str(LANG_ALARM_MOD_TIME), h, m); | ||
59 | lcd_puts(0,0, buf); | ||
60 | lcd_update(); | ||
61 | |||
62 | switch(button_get(true)) { | ||
63 | case BUTTON_PLAY: | ||
64 | /* prevent that an alarm occurs in the shutdown procedure */ | ||
65 | /* accept alarms only if they are in 2 minutes or more */ | ||
66 | hour = rtc_read(0x03); | ||
67 | hour = ((hour & 0x30) >> 4) * 10 + (hour & 0x0f); | ||
68 | minute = rtc_read(0x02); | ||
69 | minute = ((minute & 0x70) >> 4) * 10 + (minute & 0x0f); | ||
70 | int togo = (m + h * 60 - minute - hour * 60 + 1440) % 1440; | ||
71 | if (togo > 1) { | ||
72 | lcd_clear_display(); | ||
73 | snprintf(buf, 32, str(LANG_ALARM_MOD_TIME_TO_GO), togo / 60, togo % 60); | ||
74 | lcd_puts(0,0, buf); | ||
75 | lcd_update(); | ||
76 | rtc_init(); | ||
77 | rtc_set_alarm(h,m); | ||
78 | /* in some cases enabling the alarm results in an activated AF flag */ | ||
79 | /* this should not happen, but it does */ | ||
80 | /* if you know why, tell me! */ | ||
81 | /* for now, we try again forever in this case */ | ||
82 | while (rtc_enable_alarm(true)) { /* error occured */ | ||
83 | sleep(HZ / 10); | ||
84 | rtc_init(); | ||
85 | rtc_set_alarm(h,m); | ||
86 | } | ||
87 | sleep(HZ); | ||
88 | lcd_puts(0,1,str(LANG_ALARM_MOD_SHUTDOWN)); | ||
89 | lcd_update(); | ||
90 | sleep(HZ); | ||
91 | power_off(); | ||
92 | } else { | ||
93 | lcd_clear_display(); | ||
94 | lcd_puts(0,0,str(LANG_ALARM_MOD_ERROR)); | ||
95 | lcd_update(); | ||
96 | sleep(HZ); | ||
97 | lcd_clear_display(); | ||
98 | lcd_puts(0,1,str(LANG_ALARM_MOD_KEYS)); | ||
99 | } | ||
100 | break; | ||
101 | |||
102 | /* inc(m) */ | ||
103 | case BUTTON_RIGHT: | ||
104 | case BUTTON_RIGHT | BUTTON_REPEAT: | ||
105 | m += 5; | ||
106 | if (m == 60) { | ||
107 | h += 1; | ||
108 | m = 0; | ||
109 | } | ||
110 | if (h == 24) | ||
111 | h = 0; | ||
112 | break; | ||
113 | |||
114 | /* dec(m) */ | ||
115 | case BUTTON_LEFT: | ||
116 | case BUTTON_LEFT | BUTTON_REPEAT: | ||
117 | m -= 5; | ||
118 | if (m == -5) { | ||
119 | h -= 1; | ||
120 | m = 55; | ||
121 | } | ||
122 | if (h == -1) | ||
123 | h = 23; | ||
124 | break; | ||
125 | |||
126 | #ifdef HAVE_RECORDER_KEYPAD | ||
127 | /* inc(h) */ | ||
128 | case BUTTON_UP: | ||
129 | case BUTTON_UP | BUTTON_REPEAT: | ||
130 | h = (h+1) % 24; | ||
131 | break; | ||
132 | |||
133 | /* dec(h) */ | ||
134 | case BUTTON_DOWN: | ||
135 | case BUTTON_DOWN | BUTTON_REPEAT: | ||
136 | h = (h+23) % 24; | ||
137 | break; | ||
138 | #endif | ||
139 | |||
140 | #ifdef HAVE_RECORDER_KEYPAD | ||
141 | case BUTTON_OFF: | ||
142 | #else | ||
143 | case BUTTON_STOP: | ||
144 | case BUTTON_MENU: | ||
145 | #endif | ||
146 | done = true; | ||
147 | break; | ||
148 | } | ||
149 | } | ||
150 | |||
151 | return false; | ||
152 | } | ||
153 | |||
154 | #endif /* HAVE_ALARM_MOD */ \ No newline at end of file | ||
diff --git a/apps/alarm_menu.h b/apps/alarm_menu.h new file mode 100644 index 0000000000..8ad062e419 --- /dev/null +++ b/apps/alarm_menu.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2003 Uwe Freese | ||
11 | * | ||
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. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #ifndef _ALARM_MENU_H | ||
20 | #define _ALARM_MENU_H | ||
21 | |||
22 | bool alarm_screen(void); | ||
23 | |||
24 | #endif | ||
diff --git a/apps/lang/deutsch.lang b/apps/lang/deutsch.lang index e5914cff03..8607769132 100644 --- a/apps/lang/deutsch.lang +++ b/apps/lang/deutsch.lang | |||
@@ -1208,3 +1208,83 @@ id: LANG_QUEUE_TOTAL | |||
1208 | desc: number of queued tracks %d | 1208 | desc: number of queued tracks %d |
1209 | eng: "Total queued: %d" | 1209 | eng: "Total queued: %d" |
1210 | new: "Anzahl: %d" | 1210 | new: "Anzahl: %d" |
1211 | |||
1212 | id: LANG_ALARM_MOD_ALARM_MENU | ||
1213 | desc: The name of the additional entry in the main menu for the RTC alarm mod. | ||
1214 | eng: "Wake-Up Alarm" | ||
1215 | new: "Wecker" | ||
1216 | |||
1217 | id: LANG_ALARM_MOD_ERROR | ||
1218 | desc: The text that tells that the time is incorrect (for the RTC alarm mod). | ||
1219 | eng: "Alarm time is too soon!" | ||
1220 | new: "Weckzeit ist zu früh!" | ||
1221 | |||
1222 | id: LANG_ALARM_MOD_KEYS | ||
1223 | desc: Shown key functions in alarm menu (for the RTC alarm mod). | ||
1224 | eng: "PLAY=Set OFF=Cancel" | ||
1225 | new: "PLAY=OK OFF=Abbruch" | ||
1226 | |||
1227 | id: LANG_ALARM_MOD_SHUTDOWN | ||
1228 | desc: The text that tells the user that the alarm time is ok and the device shuts off (for the RTC alarm mod). | ||
1229 | eng: "Shutting down..." | ||
1230 | new: "Schalte aus..." | ||
1231 | |||
1232 | id: LANG_ALARM_MOD_TIME | ||
1233 | desc: The current alarm time shown in the alarm menu for the RTC alarm mod. | ||
1234 | eng: "Alarm time: %02d:%02d" | ||
1235 | new: "Weckzeit: %02d:%02d" | ||
1236 | |||
1237 | id: LANG_ALARM_MOD_TIME_TO_GO | ||
1238 | desc: The time until the alarm will go off shown in the alarm menu for the RTC alarm mod. | ||
1239 | eng: "Waking up in %d:%02d" | ||
1240 | new: "Einschalten in %d:%02d" | ||
1241 | |||
1242 | id: LANG_DELETE | ||
1243 | desc: The verb/action Delete | ||
1244 | eng: "Delete" | ||
1245 | new: "Löschen" | ||
1246 | |||
1247 | id: LANG_DELETED | ||
1248 | desc: A file has beed deleted | ||
1249 | eng: "Deleted" | ||
1250 | new: "Gelöscht" | ||
1251 | |||
1252 | id: LANG_FAILED | ||
1253 | desc: Something failed. To be appended after above actions | ||
1254 | eng: "failed" | ||
1255 | new: "fehlgeschlagen" | ||
1256 | |||
1257 | id: LANG_MENU_SETTING_CANCEL | ||
1258 | desc: Visual confirmation of canceling a changed setting | ||
1259 | eng: "Canceled" | ||
1260 | new: "Abgebrochen" | ||
1261 | |||
1262 | id: LANG_MENU_SETTING_OK | ||
1263 | desc: Visual confirmation of changing a setting | ||
1264 | eng: "OK" | ||
1265 | new: "OK" | ||
1266 | |||
1267 | id: LANG_PLAYER_ONPLAY_1 | ||
1268 | desc: | ||
1269 | eng: "\x81 Queue" | ||
1270 | new: "\x81 Warteschlange" | ||
1271 | |||
1272 | id: LANG_PLAYER_ONPLAY_2 | ||
1273 | desc: | ||
1274 | eng: "- Ren + Del" | ||
1275 | new: "- Umb + Ent" | ||
1276 | |||
1277 | id: LANG_QUEUE | ||
1278 | desc: The verb/action Queue | ||
1279 | eng: "Queue" | ||
1280 | new: "in Warteschlange stellen" | ||
1281 | |||
1282 | id: LANG_REALLY_DELETE | ||
1283 | desc: Really Delete? | ||
1284 | eng: "Delete?" | ||
1285 | new: "Löschen?" | ||
1286 | |||
1287 | id: LANG_RENAME | ||
1288 | desc: The verb/action Rename | ||
1289 | eng: "Rename" | ||
1290 | new: "Umbenennen" | ||
diff --git a/apps/lang/english.lang b/apps/lang/english.lang index aa47808805..9e80f95cd2 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang | |||
@@ -1286,3 +1286,33 @@ id: LANG_FAILED | |||
1286 | desc: Something failed. To be appended after above actions | 1286 | desc: Something failed. To be appended after above actions |
1287 | eng: "failed" | 1287 | eng: "failed" |
1288 | new: | 1288 | new: |
1289 | |||
1290 | id: LANG_ALARM_MOD_ALARM_MENU | ||
1291 | desc: The name of the additional entry in the main menu for the RTC alarm mod. | ||
1292 | eng: "Wake-Up Alarm" | ||
1293 | new: | ||
1294 | |||
1295 | id: LANG_ALARM_MOD_TIME | ||
1296 | desc: The current alarm time shown in the alarm menu for the RTC alarm mod. | ||
1297 | eng: "Alarm time: %02d:%02d" | ||
1298 | new: | ||
1299 | |||
1300 | id: LANG_ALARM_MOD_TIME_TO_GO | ||
1301 | desc: The time until the alarm will go off shown in the alarm menu for the RTC alarm mod. | ||
1302 | eng: "Waking up in %d:%02d" | ||
1303 | new: | ||
1304 | |||
1305 | id: LANG_ALARM_MOD_SHUTDOWN | ||
1306 | desc: The text that tells the user that the alarm time is ok and the device shuts off (for the RTC alarm mod). | ||
1307 | eng: "Shutting down..." | ||
1308 | new: | ||
1309 | |||
1310 | id: LANG_ALARM_MOD_ERROR | ||
1311 | desc: The text that tells that the time is incorrect (for the RTC alarm mod). | ||
1312 | eng: "Alarm time is too soon!" | ||
1313 | new: | ||
1314 | |||
1315 | id: LANG_ALARM_MOD_KEYS | ||
1316 | desc: Shown key functions in alarm menu (for the RTC alarm mod). | ||
1317 | eng: "PLAY=Set OFF=Cancel" | ||
1318 | new: | ||
diff --git a/apps/main_menu.c b/apps/main_menu.c index 0b51a798ab..9eb6643aef 100644 --- a/apps/main_menu.c +++ b/apps/main_menu.c | |||
@@ -47,6 +47,10 @@ | |||
47 | #include "recording.h" | 47 | #include "recording.h" |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | #ifdef HAVE_ALARM_MOD | ||
51 | #include "alarm_menu.h" | ||
52 | #endif | ||
53 | |||
50 | #ifdef HAVE_LCD_BITMAP | 54 | #ifdef HAVE_LCD_BITMAP |
51 | #include "bmp.h" | 55 | #include "bmp.h" |
52 | #include "icons.h" | 56 | #include "icons.h" |
@@ -253,10 +257,13 @@ bool main_menu(void) | |||
253 | struct menu_items items[] = { | 257 | struct menu_items items[] = { |
254 | { str(LANG_SOUND_SETTINGS), sound_menu }, | 258 | { str(LANG_SOUND_SETTINGS), sound_menu }, |
255 | { str(LANG_GENERAL_SETTINGS), settings_menu }, | 259 | { str(LANG_GENERAL_SETTINGS), settings_menu }, |
256 | { str(LANG_SLEEP_TIMER), sleeptimer_screen }, | 260 | { str(LANG_SLEEP_TIMER), sleeptimer_screen }, |
261 | #ifdef HAVE_ALARM_MOD | ||
262 | { str(LANG_ALARM_MOD_ALARM_MENU), alarm_screen }, | ||
263 | #endif | ||
257 | #ifdef HAVE_MAS3587F | 264 | #ifdef HAVE_MAS3587F |
258 | { str(LANG_RECORDING_SETTINGS), recording_menu }, | 265 | { str(LANG_RECORDING_SETTINGS), recording_menu }, |
259 | { str(LANG_RECORDING), recording_screen }, | 266 | { str(LANG_RECORDING), recording_screen }, |
260 | #endif | 267 | #endif |
261 | #ifdef HAVE_LCD_BITMAP | 268 | #ifdef HAVE_LCD_BITMAP |
262 | #ifdef USE_GAMES | 269 | #ifdef USE_GAMES |