Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+13 -6
+13 -6
apps/plugins/alarmclock.c
··· 28 28 generic_actions}; 29 29 30 30 static int current = 0; 31 - static int alarm[2] = {0, 0}, maxval[2] = {24, 60}; 31 + static bool tomorrow = false; 32 + static int alarm[2] = {0, 0}, maxval[2] = {24, 60}, prev_tick = 3600 * 24; 32 33 static bool quit = false, usb = false, waiting = false, done = false; 33 34 34 35 static inline int get_button(void) { ··· 36 37 } 37 38 38 39 int rem_seconds(void) { 39 - return (((alarm[0] - rb->get_time()->tm_hour) * 3600) 40 - +((alarm[1] - rb->get_time()->tm_min) * 60) 41 - -(rb->get_time()->tm_sec)); 40 + int seconds = (((alarm[0] - rb->get_time()->tm_hour) * 3600) 41 + +((alarm[1] - rb->get_time()->tm_min) * 60) 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 44 51 void draw_centered_string(struct screen * display, char * string) { ··· 87 94 else if (audio_status & AUDIO_STATUS_PAUSE) 88 95 return true; 89 96 90 - return false; 97 + return false; 91 98 } 92 99 93 100 void play(void) { ··· 152 159 153 160 case PLA_FIRE: { 154 161 if (rem_seconds() < 0) 155 - alarm[0] += 24; 162 + tomorrow = true; 156 163 157 164 waiting = true; 158 165 break;