]> git.earman.xyz Git - sensor-watch.git/commitdiff
avoid delta overflow in countdown draw
authorJoseph Bryant <jb@dreamcountry.org>
Sun, 18 Aug 2024 20:50:41 +0000 (21:50 +0100)
committerJoseph Bryant <jb@dreamcountry.org>
Sun, 18 Aug 2024 21:09:17 +0000 (22:09 +0100)
movement/watch_faces/complication/countdown_face.c

index be04040e33b7584a3079652ec08bf17249294274..6ae3d935b2e1f2992a28d44772e792d8e06a2fcf 100644 (file)
@@ -87,7 +87,10 @@ static void draw(countdown_state_t *state, uint8_t subsecond) {
 
     switch (state->mode) {
         case cd_running:
-            delta = state->target_ts - state->now_ts;
+            if (state->target_ts <= state->now_ts)
+                delta = 0;
+            else
+                delta = state->target_ts - state->now_ts;
             result = div(delta, 60);
             state->seconds = result.rem;
             result = div(result.quot, 60);