]> git.earman.xyz Git - sensor-watch.git/commitdiff
faces/clock: simplify LAP indication function
authorMatheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Sun, 25 Feb 2024 01:38:28 +0000 (22:38 -0300)
committerMatheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Sun, 25 Feb 2024 18:24:14 +0000 (15:24 -0300)
Simplifies the code by adding a dedicated function for this.
Also documents the meaning of the LAP indicator: Low Available Power.

movement/watch_faces/clock/clock_face.c

index 537104a44201bebee8429984a07cdea9da045a0a..08007a89a254991be8e11ad76487578d8b51d3a9 100644 (file)
@@ -94,6 +94,11 @@ static void clock_check_battery_periodically(clock_state_t *clock, watch_date_ti
     clock->battery_low = voltage < CLOCK_FACE_LOW_BATTERY_VOLTAGE_THRESHOLD;
 }
 
+static void clock_indicate_low_available_power(clock_state_t *clock) {
+    // Set the LAP indicator if battery power is low
+    clock_indicate(WATCH_INDICATOR_LAP, clock->battery_low);
+}
+
 void clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
     (void) settings;
     (void) watch_face_index;
@@ -137,9 +142,7 @@ bool clock_face_loop(movement_event_t event, movement_settings_t *settings, void
             state->previous_date_time = date_time.reg;
 
             clock_check_battery_periodically(state, date_time);
-
-            // Set the LAP indicator if battery power is low
-            if (state->battery_low) watch_set_indicator(WATCH_INDICATOR_LAP);
+            clock_indicate_low_available_power(state);
 
             if ((date_time.reg >> 6) == (previous_date_time >> 6) && event.event_type != EVENT_LOW_ENERGY_UPDATE) {
                 // everything before seconds is the same, don't waste cycles setting those segments.