From 1a33ae88f75eaeee5167a88e29d1164cbd77a992 Mon Sep 17 00:00:00 2001 From: Raffael Mancini Date: Wed, 4 Mar 2026 12:34:23 +0100 Subject: [PATCH] Move complications/local_solar_time_face -> clock/solar_time_face --- movement_faces.h | 2 +- watch-faces.mk | 2 +- .../solar_time_face.c} | 38 +++++++++---------- .../solar_time_face.h} | 38 +++++++++---------- 4 files changed, 40 insertions(+), 40 deletions(-) rename watch-faces/{complication/local_solar_time_face.c => clock/solar_time_face.c} (85%) rename watch-faces/{complication/local_solar_time_face.h => clock/solar_time_face.h} (74%) diff --git a/movement_faces.h b/movement_faces.h index 4a346850..cf940da4 100644 --- a/movement_faces.h +++ b/movement_faces.h @@ -80,5 +80,5 @@ #include "simon_face.h" #include "ping_face.h" #include "rtccount_face.h" -#include "local_solar_time_face.h" +#include "solar_time_face.h" // New includes go above this line. diff --git a/watch-faces.mk b/watch-faces.mk index bb5d5aca..95bd22ad 100644 --- a/watch-faces.mk +++ b/watch-faces.mk @@ -55,5 +55,5 @@ SRCS += \ ./watch-faces/complication/lander_face.c \ ./watch-faces/complication/simon_face.c \ ./watch-faces/complication/ping_face.c \ - ./watch-faces/complication/local_solar_time_face.c \ + ./watch-faces/clock/solar_time_face.c \ # New watch faces go above this line. diff --git a/watch-faces/complication/local_solar_time_face.c b/watch-faces/clock/solar_time_face.c similarity index 85% rename from watch-faces/complication/local_solar_time_face.c rename to watch-faces/clock/solar_time_face.c index 4c8b2397..f0b69ed0 100644 --- a/watch-faces/complication/local_solar_time_face.c +++ b/watch-faces/clock/solar_time_face.c @@ -28,7 +28,7 @@ #include #include #include -#include "local_solar_time_face.h" +#include "solar_time_face.h" #include "watch.h" #include "watch_utility.h" #include "filesystem.h" @@ -62,7 +62,7 @@ static movement_location_t _load_location(void) { } /* Compute and cache EoT and TC. Call when d != state->last_calc_d. */ -static void _compute_daily(local_solar_time_state_t *state, uint16_t d) { +static void _compute_daily(solar_time_state_t *state, uint16_t d) { /* LSTM — movement_get_current_timezone_offset() returns seconds from UTC */ float delta_T_UTC = (float)movement_get_current_timezone_offset() / 3600.0f; float LSTM = 15.0f * delta_T_UTC; @@ -79,7 +79,7 @@ static void _compute_daily(local_solar_time_state_t *state, uint16_t d) { } /* Recompute if the day-of-year has rolled over. Returns current d. */ -static uint16_t _maybe_recompute(local_solar_time_state_t *state, watch_date_time_t dt) { +static uint16_t _maybe_recompute(solar_time_state_t *state, watch_date_time_t dt) { uint16_t d = watch_utility_days_since_new_year( (uint16_t)(dt.unit.year + WATCH_RTC_REFERENCE_YEAR), dt.unit.month, @@ -101,7 +101,7 @@ static int32_t _lst_seconds(watch_date_time_t dt, float TC) { return ((lt + tc) % 86400 + 86400) % 86400; } -static void _update_display(local_solar_time_state_t *state, watch_date_time_t dt) { +static void _update_display(solar_time_state_t *state, watch_date_time_t dt) { char buf[14]; if (_load_location().reg == 0) { @@ -111,7 +111,7 @@ static void _update_display(local_solar_time_state_t *state, watch_date_time_t d switch (state->mode) { - case LOCAL_SOLAR_TIME_MODE_LST: { + case SOLAR_TIME_MODE_LST: { int32_t s = _lst_seconds(dt, state->TC); sprintf(buf, "SO %02d%02d%02d", (int)(s / 3600), (int)((s % 3600) / 60), (int)(s % 60)); @@ -119,7 +119,7 @@ static void _update_display(local_solar_time_state_t *state, watch_date_time_t d break; } - case LOCAL_SOLAR_TIME_MODE_NOON: { + case SOLAR_TIME_MODE_NOON: { /* Solar noon: moment when LST = 12:00 → LT_noon = 12h - TC/60 */ int32_t s = (int32_t)(( 12.0f - state->TC / 60.0f) * 3600.0f); s = ((s % 86400) + 86400) % 86400; @@ -128,7 +128,7 @@ static void _update_display(local_solar_time_state_t *state, watch_date_time_t d break; } - case LOCAL_SOLAR_TIME_MODE_HRA: { + case SOLAR_TIME_MODE_HRA: { /* HRA = 15 * (LST - 12); negative = morning, positive = afternoon */ int32_t s = _lst_seconds(dt, state->TC); int16_t hra = (int16_t)roundf(15.0f * ((float)s / 3600.0f - 12.0f)); @@ -146,17 +146,17 @@ static void _update_display(local_solar_time_state_t *state, watch_date_time_t d /* ---- Movement callbacks -------------------------------------------------- */ -void local_solar_time_face_setup(uint8_t watch_face_index, void **context_ptr) { +void solar_time_face_setup(uint8_t watch_face_index, void **context_ptr) { (void)watch_face_index; if (*context_ptr == NULL) { - *context_ptr = malloc(sizeof(local_solar_time_state_t)); - memset(*context_ptr, 0, sizeof(local_solar_time_state_t)); + *context_ptr = malloc(sizeof(solar_time_state_t)); + memset(*context_ptr, 0, sizeof(solar_time_state_t)); /* last_calc_d == 0 guarantees recomputation on first tick */ } } -void local_solar_time_face_activate(void *context) { - local_solar_time_state_t *state = (local_solar_time_state_t *)context; +void solar_time_face_activate(void *context) { + solar_time_state_t *state = (solar_time_state_t *)context; #if __EMSCRIPTEN__ /* In the simulator the browser exposes lat/lon as JS globals. @@ -180,8 +180,8 @@ void local_solar_time_face_activate(void *context) { _maybe_recompute(state, dt); } -bool local_solar_time_face_loop(movement_event_t event, void *context) { - local_solar_time_state_t *state = (local_solar_time_state_t *)context; +bool solar_time_face_loop(movement_event_t event, void *context) { + solar_time_state_t *state = (solar_time_state_t *)context; switch (event.event_type) { case EVENT_ACTIVATE: @@ -193,7 +193,7 @@ bool local_solar_time_face_loop(movement_event_t event, void *context) { } case EVENT_ALARM_BUTTON_UP: - state->mode = (local_solar_time_mode_t)((state->mode + 1) % LOCAL_SOLAR_TIME_NUM_MODES); + state->mode = (solar_time_mode_t)((state->mode + 1) % SOLAR_TIME_NUM_MODES); { watch_date_time_t dt = movement_get_local_date_time(); _update_display(state, dt); @@ -209,7 +209,7 @@ bool local_solar_time_face_loop(movement_event_t event, void *context) { } case EVENT_TIMEOUT: - state->mode = LOCAL_SOLAR_TIME_MODE_LST; + state->mode = SOLAR_TIME_MODE_LST; if (_load_location().reg == 0) movement_move_to_face(0); break; @@ -220,8 +220,8 @@ bool local_solar_time_face_loop(movement_event_t event, void *context) { return true; } -void local_solar_time_face_resign(void *context) { - local_solar_time_state_t *state = (local_solar_time_state_t *)context; - state->mode = LOCAL_SOLAR_TIME_MODE_LST; +void solar_time_face_resign(void *context) { + solar_time_state_t *state = (solar_time_state_t *)context; + state->mode = SOLAR_TIME_MODE_LST; watch_clear_colon(); } diff --git a/watch-faces/complication/local_solar_time_face.h b/watch-faces/clock/solar_time_face.h similarity index 74% rename from watch-faces/complication/local_solar_time_face.h rename to watch-faces/clock/solar_time_face.h index dc677ed0..48faf693 100644 --- a/watch-faces/complication/local_solar_time_face.h +++ b/watch-faces/clock/solar_time_face.h @@ -25,7 +25,7 @@ #pragma once /* - * LOCAL SOLAR TIME FACE + * SOLAR TIME FACE * * Displays solar time information based on the user's location. * Formulas follow the notation from: @@ -36,7 +36,7 @@ * B - Seasonal angle [degrees] = (360/365) * (d - 81) * EoT - Equation of Time [minutes] = 9.87*sin(2B) - 7.53*cos(B) - 1.5*sin(B) * TC - Time Correction Factor [minutes] = 4*(Longitude - LSTM) + EoT - * LST - Local Solar Time [hours] = LT + TC/60 + * LST - Solar Time [hours] = LT + TC/60 * HRA - Hour Angle [degrees] = 15*(LST - 12) * * B, EoT and TC only depend on the day-of-year d, so they are cached @@ -48,7 +48,7 @@ * "SO no Loc". * * Display modes (cycle with the Alarm / start-stop button): - * SO HH:MM:SS — Local Solar Time (LST), live seconds display + * SO HH:MM:SS — Solar Time (LST), live seconds display * nO HH:MM — Solar Noon in local clock time * Hr ±DDD — Hour Angle (HRA) in degrees; negative=morning, positive=afternoon */ @@ -56,29 +56,29 @@ #include "movement.h" typedef enum { - LOCAL_SOLAR_TIME_MODE_LST = 0, /* Local Solar Time SO HH:MM:SS */ - LOCAL_SOLAR_TIME_MODE_NOON = 1, /* Solar Noon (local) nO HH:MM */ - LOCAL_SOLAR_TIME_MODE_HRA = 2, /* Hour Angle Hr ±DDD */ - LOCAL_SOLAR_TIME_NUM_MODES -} local_solar_time_mode_t; + SOLAR_TIME_MODE_LST = 0, /* Solar Time SO HH:MM:SS */ + SOLAR_TIME_MODE_NOON = 1, /* Solar Noon (local) nO HH:MM */ + SOLAR_TIME_MODE_HRA = 2, /* Hour Angle Hr ±DDD */ + SOLAR_TIME_NUM_MODES +} solar_time_mode_t; typedef struct { - local_solar_time_mode_t mode; + solar_time_mode_t mode; uint16_t last_calc_d; /* day-of-year (1-366) when EoT/TC were last computed; 0 (zero-init) guarantees recomputation on first tick */ float EoT; /* Equation of Time [minutes] */ float TC; /* Time Correction Factor [minutes] */ -} local_solar_time_state_t; +} solar_time_state_t; -void local_solar_time_face_setup(uint8_t watch_face_index, void **context_ptr); -void local_solar_time_face_activate(void *context); -bool local_solar_time_face_loop(movement_event_t event, void *context); -void local_solar_time_face_resign(void *context); +void solar_time_face_setup(uint8_t watch_face_index, void **context_ptr); +void solar_time_face_activate(void *context); +bool solar_time_face_loop(movement_event_t event, void *context); +void solar_time_face_resign(void *context); -#define local_solar_time_face ((const watch_face_t){ \ - local_solar_time_face_setup, \ - local_solar_time_face_activate, \ - local_solar_time_face_loop, \ - local_solar_time_face_resign, \ +#define solar_time_face ((const watch_face_t){ \ + solar_time_face_setup, \ + solar_time_face_activate, \ + solar_time_face_loop, \ + solar_time_face_resign, \ NULL, \ })