From ef40d58afc73f8056c90eff68d01b3f3a89976cd Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Sun, 7 Nov 2021 00:29:27 -0400 Subject: movement: refactor timeout to tick first, then notify --- movement/movement.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'movement/movement.c') diff --git a/movement/movement.c b/movement/movement.c index 5622f17f..643fc672 100644 --- a/movement/movement.c +++ b/movement/movement.c @@ -143,11 +143,6 @@ bool app_loop() { } } - // if we have timed out of our timeout countdown, give the app a hint that they can resign. - if (movement_state.timeout_ticks == 0) { - event.event_type = EVENT_TIMEOUT; - } - // handle background tasks, if the alarm handler told us we need to if (movement_state.needs_background_tasks_handled) _movement_handle_background_tasks(); @@ -181,9 +176,18 @@ bool app_loop() { event.subsecond = movement_state.subsecond; can_sleep = watch_faces[movement_state.current_watch_face].loop(event, &movement_state.settings, watch_face_contexts[movement_state.current_watch_face]); event.event_type = EVENT_NONE; - event.subsecond = 0; } + // if we have timed out of our timeout countdown, give the app a hint that they can resign. + if (movement_state.timeout_ticks == 0) { + event.event_type = EVENT_TIMEOUT; + event.subsecond = movement_state.subsecond; + watch_faces[movement_state.current_watch_face].loop(event, &movement_state.settings, watch_face_contexts[movement_state.current_watch_face]); + event.event_type = EVENT_NONE; + } + + event.subsecond = 0; + return can_sleep && !movement_state.led_on; } -- cgit v1.2.3