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
This commit is contained in:
parent
414dad42c5
commit
46a9c5e089
1 changed files with 13 additions and 6 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue