]> git.earman.xyz Git - sensor-watch.git/commitdiff
faces/tally: avoid resetting counters
authorMatheus Afonso Martins Moreira <matheus@matheusmoreira.com>
Sun, 8 Sep 2024 21:49:09 +0000 (18:49 -0300)
committerMatheus Afonso Martins Moreira <matheus@matheusmoreira.com>
Sun, 8 Sep 2024 21:49:09 +0000 (18:49 -0300)
Don't reset the counters unless there are multiple presets.
Move back to the first face directly if there are no presets
to cycle through.

movement/watch_faces/complication/tally_face.c

index 4da36cb2a58a0ca1c34b0a98c5aa0c2e2ca88851..b2c553f5868c5faf4557afec5489bff94b3a74f9 100644 (file)
@@ -105,10 +105,15 @@ static void tally_face_decrement(tally_state_t *state, bool sound_on) {
         }
 }
 
+static bool tally_face_should_move_back(tally_state_t *state) {
+    if (_tally_default_size <= 1) { return false; }
+    return state->tally_idx == _tally_default[state->tally_default_idx];
+}
+
 bool tally_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
     tally_state_t *state = (tally_state_t *)context;
     static bool using_led = false;
-    
+
     if (using_led) {
         if(!watch_get_pin_level(BTN_MODE) && !watch_get_pin_level(BTN_LIGHT) && !watch_get_pin_level(BTN_ALARM))
             using_led = false;
@@ -118,7 +123,7 @@ bool tally_face_loop(movement_event_t event, movement_settings_t *settings, void
             return true;
         }
     }
-    
+
     switch (event.event_type) {
         case EVENT_TICK:
             if (_quick_ticks_running) {
@@ -138,7 +143,7 @@ bool tally_face_loop(movement_event_t event, movement_settings_t *settings, void
             start_quick_cyc();
             break;
         case EVENT_MODE_LONG_PRESS:
-            if (state->tally_idx == _tally_default[state->tally_default_idx]) {
+            if (tally_face_should_move_back(state)) {
                 _init_val = true;
                 movement_move_to_face(0);
             }