]> git.earman.xyz Git - sensor-watch.git/commitdiff
faces/clock: refactor full time display code
authorMatheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Sun, 25 Feb 2024 16:00:50 +0000 (13:00 -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 defining dedicated functions for this.

movement/watch_faces/clock/clock_face.c

index 82052133f90054ce767cbf8bf237a913a852036f..5b698341212be0fac34503b1aa87bda8a7c9a224 100644 (file)
@@ -99,6 +99,23 @@ static void clock_indicate_low_available_power(clock_state_t *clock) {
     clock_indicate(WATCH_INDICATOR_LAP, clock->battery_low);
 }
 
+static void clock_display_all(watch_date_time date_time) {
+    char buf[10 + 1];
+
+    snprintf(
+        buf,
+        sizeof(buf),
+        "%s%2d%2d%02d%02d",
+        watch_utility_get_weekday(date_time),
+        date_time.unit.day,
+        date_time.unit.hour,
+        date_time.unit.minute,
+        date_time.unit.second
+    );
+
+    watch_display_string(buf, 0);
+}
+
 static void clock_display_low_energy(watch_date_time date_time) {
     char buf[10 + 1];
 
@@ -191,7 +208,8 @@ bool clock_face_loop(movement_event_t event, movement_settings_t *settings, void
                     clock_indicate_pm(settings, date_time);
                     date_time = clock_24h_to_12h(date_time);
                 }
-                sprintf(buf, "%s%2d%2d%02d%02d", watch_utility_get_weekday(date_time), date_time.unit.day, date_time.unit.hour, date_time.unit.minute, date_time.unit.second);
+                clock_display_all(date_time);
+                break;
             }
 
             watch_display_string(buf, 0);