]> git.earman.xyz Git - sensor-watch.git/commitdiff
faces/clock: refactor time signal toggling code
authorMatheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Sun, 25 Feb 2024 17:10:04 +0000 (14:10 -0300)
committerMatheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Sun, 25 Feb 2024 18:24:15 +0000 (15:24 -0300)
Simplifies the code by defining dedicated functions for this.

movement/watch_faces/clock/clock_face.c

index 7e4ec8162eec9092131461a7e75dc72e714d1e40..f6c3f3f46763f5b29b9658baedd43462d0cc6569 100644 (file)
@@ -101,6 +101,11 @@ static void clock_indicate_low_available_power(clock_state_t *clock) {
     clock_indicate(WATCH_INDICATOR_LAP, clock->battery_low);
 }
 
+static void clock_toggle_time_signal(clock_state_t *clock) {
+    clock->time_signal_enabled = !clock->time_signal_enabled;
+    clock_indicate_time_signal(clock);
+}
+
 static void clock_display_all(watch_date_time date_time) {
     char buf[10 + 1];
 
@@ -240,8 +245,7 @@ bool clock_face_loop(movement_event_t event, movement_settings_t *settings, void
 
             break;
         case EVENT_ALARM_LONG_PRESS:
-            state->time_signal_enabled = !state->time_signal_enabled;
-            clock_indicate_time_signal(state);
+            clock_toggle_time_signal(state);
             break;
         case EVENT_BACKGROUND_TASK:
             // uncomment this line to snap back to the clock face when the hour signal sounds: