summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
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 a691b61822..88e3e858cb 100644
--- a/apps/plugins/alarmclock.c
+++ b/apps/plugins/alarmclock.c
@@ -28,7 +28,8 @@ const struct button_mapping *plugin_contexts[] = {generic_directions,
28 generic_actions}; 28 generic_actions};
29 29
30static int current = 0; 30static int current = 0;
31static int alarm[2] = {0, 0}, maxval[2] = {24, 60}; 31static bool tomorrow = false;
32static int alarm[2] = {0, 0}, maxval[2] = {24, 60}, prev_tick = 3600 * 24;
32static bool quit = false, usb = false, waiting = false, done = false; 33static bool quit = false, usb = false, waiting = false, done = false;
33 34
34static inline int get_button(void) { 35static inline int get_button(void) {
@@ -36,9 +37,15 @@ static inline int get_button(void) {
36} 37}
37 38
38int rem_seconds(void) { 39int rem_seconds(void) {
39 return (((alarm[0] - rb->get_time()->tm_hour) * 3600) 40 int seconds = (((alarm[0] - rb->get_time()->tm_hour) * 3600)
40 +((alarm[1] - rb->get_time()->tm_min) * 60) 41 +((alarm[1] - rb->get_time()->tm_min) * 60)
41 -(rb->get_time()->tm_sec)); 42 -(rb->get_time()->tm_sec));
43
44 /* The tomorrow flag means that the alarm should ring on the next day */
45 if (seconds > prev_tick) tomorrow = false;
46 prev_tick = seconds;
47
48 return seconds + (tomorrow ? 24 * 3600 : 0);
42} 49}
43 50
44void draw_centered_string(struct screen * display, char * string) { 51void draw_centered_string(struct screen * display, char * string) {
@@ -87,7 +94,7 @@ bool can_play(void) {
87 else if (audio_status & AUDIO_STATUS_PAUSE) 94 else if (audio_status & AUDIO_STATUS_PAUSE)
88 return true; 95 return true;
89 96
90 return false; 97 return false;
91} 98}
92 99
93void play(void) { 100void play(void) {
@@ -152,7 +159,7 @@ enum plugin_status plugin_start(const void* parameter)
152 159
153 case PLA_FIRE: { 160 case PLA_FIRE: {
154 if (rem_seconds() < 0) 161 if (rem_seconds() < 0)
155 alarm[0] += 24; 162 tomorrow = true;
156 163
157 waiting = true; 164 waiting = true;
158 break; 165 break;