From b3ed4df0a1f1d04f7b4df3593171cbe36df2a1c1 Mon Sep 17 00:00:00 2001 From: joeycastillo Date: Sun, 29 Sep 2024 09:50:44 -0400 Subject: [PATCH] bring in clock face, add 024h mode, refactor out last raw access of settings->bit --- movement.h | 5 ++-- movement_config.h | 1 + movement_faces.h | 1 + watch-faces.mk | 1 + .../clock/clock_face.c | 24 +++++++------------ .../clock/clock_face.h | 0 6 files changed, 14 insertions(+), 18 deletions(-) rename {movement/watch_faces => watch-faces}/clock/clock_face.c (92%) rename {movement/watch_faces => watch-faces}/clock/clock_face.h (100%) diff --git a/movement.h b/movement.h index 8c7f19a6..a9fa4da8 100644 --- a/movement.h +++ b/movement.h @@ -42,8 +42,9 @@ // This allows these preferences to be stored before entering BACKUP mode and and restored after waking from reset. typedef enum { - MOVEMENT_CLOCK_MODE_12H = 0, - MOVEMENT_CLOCK_MODE_24H, + MOVEMENT_CLOCK_MODE_12H = 0, /// use 12 hour clock + MOVEMENT_CLOCK_MODE_24H, /// use 24 hour clock + MOVEMENT_CLOCK_MODE_024H, /// use 24 hour clock with leading zero MOVEMENT_NUM_CLOCK_MODES } movement_clock_mode_t; diff --git a/movement_config.h b/movement_config.h index 2ad4cdba..b877ee0e 100644 --- a/movement_config.h +++ b/movement_config.h @@ -28,6 +28,7 @@ #include "movement_faces.h" const watch_face_t watch_faces[] = { + clock_face, simple_clock_face, beats_face, world_clock_face, diff --git a/movement_faces.h b/movement_faces.h index 5ea739a4..20e1f1b0 100644 --- a/movement_faces.h +++ b/movement_faces.h @@ -25,6 +25,7 @@ #pragma once #include "simple_clock_face.h" +#include "clock_face.h" #include "beats_face.h" #include "world_clock_face.h" #include "countdown_face.h" diff --git a/watch-faces.mk b/watch-faces.mk index 734560da..b981ab94 100644 --- a/watch-faces.mk +++ b/watch-faces.mk @@ -1,5 +1,6 @@ SRCS += \ ./watch-faces/clock/simple_clock_face.c \ + ./watch-faces/clock/clock_face.c \ ./watch-faces/clock/beats_face.c \ ./watch-faces/clock/world_clock_face.c \ ./watch-faces/complication/countdown_face.c \ diff --git a/movement/watch_faces/clock/clock_face.c b/watch-faces/clock/clock_face.c similarity index 92% rename from movement/watch_faces/clock/clock_face.c rename to watch-faces/clock/clock_face.c index e2f492b1..79bcd9be 100644 --- a/movement/watch_faces/clock/clock_face.c +++ b/watch-faces/clock/clock_face.c @@ -34,7 +34,7 @@ #include "clock_face.h" #include "watch.h" #include "watch_utility.h" -#include "watch_private_display.h" +#include "watch_common_display.h" // 2.2 volts will happen when the battery has maybe 5-10% remaining? // we can refine this later. @@ -52,14 +52,6 @@ typedef struct { bool battery_low; } clock_state_t; -static bool clock_is_in_24h_mode(movement_settings_t *settings) { - return movement_clock_mode_24h(); -} - -static bool clock_should_set_leading_zero(movement_settings_t *settings) { - return clock_is_in_24h_mode(settings) && settings->bit.clock_24h_leading_zero; -} - static void clock_indicate(watch_indicator_t indicator, bool on) { if (on) { watch_set_indicator(indicator); @@ -77,7 +69,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, clock_is_in_24h_mode(settings)); + clock_indicate(WATCH_INDICATOR_24H, !!movement_clock_mode_24h()); } static bool clock_is_pm(watch_date_time date_time) { @@ -138,7 +130,7 @@ static void clock_display_all(watch_date_time date_time, bool leading_zero) { date_time.unit.second ); - watch_display_string(buf, 0); + watch_display_text(WATCH_POSITION_FULL, buf); } static bool clock_display_some(watch_date_time current, watch_date_time previous) { @@ -163,7 +155,8 @@ static bool clock_display_some(watch_date_time current, watch_date_time previous current.unit.second ); - watch_display_string(buf, 6); + watch_display_text(WATCH_POSITION_MINUTES, buf); + watch_display_text(WATCH_POSITION_SECONDS, buf + 2); return true; @@ -175,12 +168,11 @@ 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 (!clock_is_in_24h_mode(settings)) { - // if we are in 12 hour mode, do some cleanup. + if (movement_clock_mode_24h() == MOVEMENT_CLOCK_MODE_12H) { clock_indicate_pm(settings, current); current = clock_24h_to_12h(current); } - clock_display_all(current, clock_should_set_leading_zero(settings)); + clock_display_all(current, movement_clock_mode_24h() == MOVEMENT_CLOCK_MODE_024H); } } @@ -197,7 +189,7 @@ static void clock_display_low_energy(watch_date_time date_time) { date_time.unit.minute ); - watch_display_string(buf, 0); + watch_display_text(WATCH_POSITION_FULL, buf); } static void clock_start_tick_tock_animation(void) { diff --git a/movement/watch_faces/clock/clock_face.h b/watch-faces/clock/clock_face.h similarity index 100% rename from movement/watch_faces/clock/clock_face.h rename to watch-faces/clock/clock_face.h