summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2010-05-15 15:20:45 +0000
committerRafaël Carré <rafael.carre@gmail.com>2010-05-15 15:20:45 +0000
commit46a9c5e08952d75515612ee23567d4237f5298da (patch)
tree1a8509d642377b574374c482eb1b0a970201b7f8 /apps/plugins
parent414dad42c59f43919489f45236d57e1b345b8a65 (diff)
downloadrockbox-46a9c5e08952d75515612ee23567d4237f5298da.zip
rockbox-46a9c5e08952d75515612ee23567d4237f5298da.tar.gz
rockbox-46a9c5e08952d75515612ee23567d4237f5298da.tar.bz2
rockbox-46a9c5e08952d75515612ee23567d4237f5298da.tar.xz
Fix alarmclock plugin time miscalculation
Author: Clément Pit-Claudel (CFP) Flyspray: FS#11110 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26056 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/alarmclock.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/apps/plugins/alarmclock.c b/apps/plugins/alarmclock.c
index a691b61..88e3e85 100644
--- a/apps/plugins/alarmclock.c
+++ b/apps/plugins/alarmclock.c
@@ -28,7 +28,8 @@ const struct button_mapping *plugin_contexts[] = {generic_directions,
generic_actions};
static int current = 0;
-static int alarm[2] = {0, 0}, maxval[2] = {24, 60};
+static bool tomorrow = false;
+static int alarm[2] = {0, 0}, maxval[2] = {24, 60}, prev_tick = 3600 * 24;
static bool quit = false, usb = false, waiting = false, done = false;
static inline int get_button(void) {
@@ -36,9 +37,15 @@ static inline int get_button(void) {
}
int rem_seconds(void) {
- return (((alarm[0] - rb->get_time()->tm_hour) * 3600)
- +((alarm[1] - rb->get_time()->tm_min) * 60)
- -(rb->get_time()->tm_sec));
+ int seconds = (((alarm[0] - rb->get_time()->tm_hour) * 3600)
+ +((alarm[1] - rb->get_time()->tm_min) * 60)
+ -(rb->get_time()->tm_sec));
+
+ /* The tomorrow flag means that the alarm should ring on the next day */
+ if (seconds > prev_tick) tomorrow = false;
+ prev_tick = seconds;
+
+ return seconds + (tomorrow ? 24 * 3600 : 0);
}
void draw_centered_string(struct screen * display, char * string) {
@@ -87,7 +94,7 @@ bool can_play(void) {
else if (audio_status & AUDIO_STATUS_PAUSE)
return true;
- return false;
+ return false;
}
void play(void) {
@@ -152,7 +159,7 @@ enum plugin_status plugin_start(const void* parameter)
case PLA_FIRE: {
if (rem_seconds() < 0)
- alarm[0] += 24;
+ tomorrow = true;
waiting = true;
break;