]> git.earman.xyz Git - sensor-watch.git/commitdiff
faces/clock: add 24h only feature
authorMatheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Sun, 25 Feb 2024 18:18:45 +0000 (15:18 -0300)
committerMatheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tue, 5 Mar 2024 03:46:27 +0000 (00:46 -0300)
The clock watch face can now be configured at build time
to only display the time in 24h mode. Also enabled in forced 24h mode.

This should result in smaller code size due to dead code elimination.

make.mk
movement/watch_faces/clock/clock_face.c

diff --git a/make.mk b/make.mk
index 955ea3102004b2e2c6207452b6ca378517082dcd..995acfb62067a8a7ae0ce0fc3c5249b9f6ac1450 100644 (file)
--- a/make.mk
+++ b/make.mk
@@ -229,3 +229,9 @@ endif
 ifeq ($(BOARD), OSO-FEAL-A1-00)
 CFLAGS += -DCRYSTALLESS
 endif
+
+# Build options to customize movement and faces
+
+ifdef CLOCK_FACE_24H_ONLY
+CFLAGS += -DCLOCK_FACE_24H_ONLY
+endif
index 6d40fe15d9719434518e122386a7abb4c86cdc4b..eab5cd8d3f9f9d9b160d40cb9c5e24f79fc18b35 100644 (file)
 #define CLOCK_FACE_LOW_BATTERY_VOLTAGE_THRESHOLD 2200
 #endif
 
+#ifndef CLOCK_FACE_24H_ONLY
+#define CLOCK_FACE_24H_ONLY 0
+#endif
+
 typedef struct {
     struct {
         watch_date_time previous;
@@ -52,6 +56,11 @@ typedef struct {
     bool battery_low;
 } clock_state_t;
 
+static bool clock_is_in_24h_mode(movement_settings_t *settings) {
+    if (CLOCK_FACE_24H_ONLY) { return true; }
+    return settings->bit.clock_mode_24h;
+}
+
 static void clock_indicate(WatchIndicatorSegment indicator, bool on) {
     if (on) {
         watch_set_indicator(indicator);
@@ -69,7 +78,7 @@ static void clock_indicate_time_signal(clock_state_t *clock) {
 }
 
 static void clock_indicate_24h(movement_settings_t *settings) {
-    clock_indicate(WATCH_INDICATOR_24H, settings->bit.clock_mode_24h);
+    clock_indicate(WATCH_INDICATOR_24H, clock_is_in_24h_mode(settings));
 }
 
 static bool clock_is_pm(watch_date_time date_time) {
@@ -167,7 +176,7 @@ static bool clock_display_some(watch_date_time current, watch_date_time previous
 
 static void clock_display_clock(movement_settings_t *settings, clock_state_t *clock, watch_date_time current) {
     if (!clock_display_some(current, clock->date_time.previous)) {
-        if (!settings->bit.clock_mode_24h) {
+        if (!clock_is_in_24h_mode(settings)) {
             // if we are in 12 hour mode, do some cleanup.
             clock_indicate_pm(settings, current);
             current = clock_24h_to_12h(current);