Skip to content

Commit

Permalink
Merge PR #440 - fix countdown face issues
Browse files Browse the repository at this point in the history
Avoid potential underflow when evaluating x - y with y > x.
Evaluate it only when y <= x instead.

Avoid clearing indicators in background task
since another watch face is likely active.

Reviewed-by: Matheus Afonso Martins Moreira <[email protected]>
GitHub-Pull-Request: #440
  • Loading branch information
matheusmoreira committed Aug 30, 2024
2 parents 42dc151 + e2c5bab commit 657ff72
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions movement/watch_faces/complication/countdown_face.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -97,6 +100,7 @@ static void draw(countdown_state_t *state, uint8_t subsecond) {
break;
case cd_reset:
case cd_paused:
watch_clear_indicator(WATCH_INDICATOR_BELL);
sprintf(buf, "CD %2d%02d%02d", state->hours, state->minutes, state->seconds);
break;
case cd_setting:
Expand Down Expand Up @@ -130,7 +134,6 @@ static void pause(countdown_state_t *state) {
static void reset(countdown_state_t *state) {
state->mode = cd_reset;
movement_cancel_background_task();
watch_clear_indicator(WATCH_INDICATOR_BELL);
load_countdown(state);
}

Expand Down

0 comments on commit 657ff72

Please sign in to comment.