From e7052fe4e27361dce45a3eff4ee1f7c21f69aca2 Mon Sep 17 00:00:00 2001 From: Matheus Afonso Martins Moreira Date: Sat, 24 Feb 2024 22:38:28 -0300 Subject: faces/clock: simplify LAP indication function 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 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'movement/watch_faces') diff --git a/movement/watch_faces/clock/clock_face.c b/movement/watch_faces/clock/clock_face.c index 537104a4..08007a89 100644 --- a/movement/watch_faces/clock/clock_face.c +++ b/movement/watch_faces/clock/clock_face.c @@ -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. -- cgit v1.2.3