bring in clock face, add 024h mode, refactor out last raw access of settings->bit

This commit is contained in:
joeycastillo 2024-09-29 09:50:44 -04:00
parent 07d6a05e33
commit b3ed4df0a1
6 changed files with 14 additions and 18 deletions

View File

@ -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;

View File

@ -28,6 +28,7 @@
#include "movement_faces.h"
const watch_face_t watch_faces[] = {
clock_face,
simple_clock_face,
beats_face,
world_clock_face,

View File

@ -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"

View File

@ -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 \

View File

@ -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) {