summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorUwe Freese <thebreaker@rockbox.org>2003-01-22 12:50:34 +0000
committerUwe Freese <thebreaker@rockbox.org>2003-01-22 12:50:34 +0000
commit86352ccc3f47bc0f6bdcdcdc7b752f0836900fcd (patch)
tree6bb892fcae88e04a3a45239236cd3dde97d8d7ce /apps
parentfa2229559802f7066b55cc2ab0761c9e742658f7 (diff)
downloadrockbox-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.c154
-rw-r--r--apps/alarm_menu.h24
-rw-r--r--apps/lang/deutsch.lang80
-rw-r--r--apps/lang/english.lang30
-rw-r--r--apps/main_menu.c13
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
41bool 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
22bool 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
1208desc: number of queued tracks %d 1208desc: number of queued tracks %d
1209eng: "Total queued: %d" 1209eng: "Total queued: %d"
1210new: "Anzahl: %d" 1210new: "Anzahl: %d"
1211
1212id: LANG_ALARM_MOD_ALARM_MENU
1213desc: The name of the additional entry in the main menu for the RTC alarm mod.
1214eng: "Wake-Up Alarm"
1215new: "Wecker"
1216
1217id: LANG_ALARM_MOD_ERROR
1218desc: The text that tells that the time is incorrect (for the RTC alarm mod).
1219eng: "Alarm time is too soon!"
1220new: "Weckzeit ist zu früh!"
1221
1222id: LANG_ALARM_MOD_KEYS
1223desc: Shown key functions in alarm menu (for the RTC alarm mod).
1224eng: "PLAY=Set OFF=Cancel"
1225new: "PLAY=OK OFF=Abbruch"
1226
1227id: LANG_ALARM_MOD_SHUTDOWN
1228desc: The text that tells the user that the alarm time is ok and the device shuts off (for the RTC alarm mod).
1229eng: "Shutting down..."
1230new: "Schalte aus..."
1231
1232id: LANG_ALARM_MOD_TIME
1233desc: The current alarm time shown in the alarm menu for the RTC alarm mod.
1234eng: "Alarm time: %02d:%02d"
1235new: "Weckzeit: %02d:%02d"
1236
1237id: LANG_ALARM_MOD_TIME_TO_GO
1238desc: The time until the alarm will go off shown in the alarm menu for the RTC alarm mod.
1239eng: "Waking up in %d:%02d"
1240new: "Einschalten in %d:%02d"
1241
1242id: LANG_DELETE
1243desc: The verb/action Delete
1244eng: "Delete"
1245new: "Löschen"
1246
1247id: LANG_DELETED
1248desc: A file has beed deleted
1249eng: "Deleted"
1250new: "Gelöscht"
1251
1252id: LANG_FAILED
1253desc: Something failed. To be appended after above actions
1254eng: "failed"
1255new: "fehlgeschlagen"
1256
1257id: LANG_MENU_SETTING_CANCEL
1258desc: Visual confirmation of canceling a changed setting
1259eng: "Canceled"
1260new: "Abgebrochen"
1261
1262id: LANG_MENU_SETTING_OK
1263desc: Visual confirmation of changing a setting
1264eng: "OK"
1265new: "OK"
1266
1267id: LANG_PLAYER_ONPLAY_1
1268desc:
1269eng: "\x81 Queue"
1270new: "\x81 Warteschlange"
1271
1272id: LANG_PLAYER_ONPLAY_2
1273desc:
1274eng: "- Ren + Del"
1275new: "- Umb + Ent"
1276
1277id: LANG_QUEUE
1278desc: The verb/action Queue
1279eng: "Queue"
1280new: "in Warteschlange stellen"
1281
1282id: LANG_REALLY_DELETE
1283desc: Really Delete?
1284eng: "Delete?"
1285new: "Löschen?"
1286
1287id: LANG_RENAME
1288desc: The verb/action Rename
1289eng: "Rename"
1290new: "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
1286desc: Something failed. To be appended after above actions 1286desc: Something failed. To be appended after above actions
1287eng: "failed" 1287eng: "failed"
1288new: 1288new:
1289
1290id: LANG_ALARM_MOD_ALARM_MENU
1291desc: The name of the additional entry in the main menu for the RTC alarm mod.
1292eng: "Wake-Up Alarm"
1293new:
1294
1295id: LANG_ALARM_MOD_TIME
1296desc: The current alarm time shown in the alarm menu for the RTC alarm mod.
1297eng: "Alarm time: %02d:%02d"
1298new:
1299
1300id: LANG_ALARM_MOD_TIME_TO_GO
1301desc: The time until the alarm will go off shown in the alarm menu for the RTC alarm mod.
1302eng: "Waking up in %d:%02d"
1303new:
1304
1305id: LANG_ALARM_MOD_SHUTDOWN
1306desc: The text that tells the user that the alarm time is ok and the device shuts off (for the RTC alarm mod).
1307eng: "Shutting down..."
1308new:
1309
1310id: LANG_ALARM_MOD_ERROR
1311desc: The text that tells that the time is incorrect (for the RTC alarm mod).
1312eng: "Alarm time is too soon!"
1313new:
1314
1315id: LANG_ALARM_MOD_KEYS
1316desc: Shown key functions in alarm menu (for the RTC alarm mod).
1317eng: "PLAY=Set OFF=Cancel"
1318new:
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