From ff3c8a72fced39b858f464c9b5f573450d3e1645 Mon Sep 17 00:00:00 2001 From: Raffael Mancini Date: Sat, 21 Feb 2026 18:06:19 +0100 Subject: [PATCH 1/7] Implement local solar time face MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Full implementation of the local solar time complication using the pveducation.org formula set (LSTM, B, EoT, TC, LST, HRA). EoT and TC are cached by day-of-year and recomputed once at midnight rollover. Three display modes cycle with the Alarm button: SO HH:MM:SS — Local Solar Time nO HH:MM — Solar Noon in local clock time Hr ±DDD — Hour Angle in degrees Location is read from location.u32 on the filesystem. In the simulator the browser lat/lon globals are written to location.u32 on activation if not already set, fixing the "no Loc" issue in the emulator. --- movement_config.h | 5 +- movement_faces.h | 1 + watch-faces.mk | 1 + .../complication/local_solar_time_face.c | 227 ++++++++++++++++++ .../complication/local_solar_time_face.h | 84 +++++++ 5 files changed, 316 insertions(+), 2 deletions(-) create mode 100644 watch-faces/complication/local_solar_time_face.c create mode 100644 watch-faces/complication/local_solar_time_face.h diff --git a/movement_config.h b/movement_config.h index 2f48d8fd..bd23b810 100644 --- a/movement_config.h +++ b/movement_config.h @@ -28,8 +28,9 @@ #include "movement_faces.h" const watch_face_t watch_faces[] = { - clock_face, - world_clock_face, + local_solar_time_face, + clock_face, + /* world_clock_face, */ sunrise_sunset_face, moon_phase_face, fast_stopwatch_face, diff --git a/movement_faces.h b/movement_faces.h index 164dbb4c..4a346850 100644 --- a/movement_faces.h +++ b/movement_faces.h @@ -80,4 +80,5 @@ #include "simon_face.h" #include "ping_face.h" #include "rtccount_face.h" +#include "local_solar_time_face.h" // New includes go above this line. diff --git a/watch-faces.mk b/watch-faces.mk index 69ec4e9c..bb5d5aca 100644 --- a/watch-faces.mk +++ b/watch-faces.mk @@ -55,4 +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 \ # New watch faces go above this line. diff --git a/watch-faces/complication/local_solar_time_face.c b/watch-faces/complication/local_solar_time_face.c new file mode 100644 index 00000000..4c8b2397 --- /dev/null +++ b/watch-faces/complication/local_solar_time_face.c @@ -0,0 +1,227 @@ +/* + * MIT License + * + * Copyright (c) 2025 Raffael Mancini + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Solar time formulas follow the notation from: + * https://www.pveducation.org/pvcdrom/properties-of-sunlight/solar-time + */ + +#include +#include +#include +#include "local_solar_time_face.h" +#include "watch.h" +#include "watch_utility.h" +#include "filesystem.h" + +#if __EMSCRIPTEN__ +#include +#endif + +#ifndef M_PI +#define M_PI 3.14159265358979323846f +#endif + +/* --------------------------------------------------------------------------- + * Solar time math (pveducation.org notation) + * --------------------------------------------------------------------------- + * + * LSTM = 15 * ΔTUTC [degrees] + * B = (360 / 365) * (d - 81) [degrees] d = day-of-year + * EoT = 9.87*sin(2B) - 7.53*cos(B) + * - 1.5*sin(B) [minutes] + * TC = 4 * (Longitude - LSTM) + EoT [minutes] + * LST = LT + TC/60 [hours] + * HRA = 15 * (LST - 12) [degrees] + * --------------------------------------------------------------------------- + */ + +static movement_location_t _load_location(void) { + movement_location_t loc = {0}; + filesystem_read_file("location.u32", (char *)&loc.reg, sizeof(loc.reg)); + return loc; +} + +/* 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) { + /* 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; + + movement_location_t loc = _load_location(); + float longitude = (float)(int16_t)loc.bit.longitude / 100.0f; + + /* B in radians for sinf/cosf */ + float B = (360.0f / 365.0f) * ((float)d - 81.0f) * ((float)M_PI / 180.0f); + + state->EoT = 9.87f * sinf(2.0f * B) - 7.53f * cosf(B) - 1.5f * sinf(B); + state->TC = 4.0f * (longitude - LSTM) + state->EoT; + state->last_calc_d = 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) { + uint16_t d = watch_utility_days_since_new_year( + (uint16_t)(dt.unit.year + WATCH_RTC_REFERENCE_YEAR), + dt.unit.month, + dt.unit.day + ); + if (d != state->last_calc_d && _load_location().reg != 0) { + _compute_daily(state, d); + } + return d; +} + +/* LST as total seconds since midnight (0..86399). + * LST = LT + TC/60 => in seconds: LT_sec + TC*60 */ +static int32_t _lst_seconds(watch_date_time_t dt, float TC) { + int32_t lt = (int32_t)dt.unit.hour * 3600 + + (int32_t)dt.unit.minute * 60 + + (int32_t)dt.unit.second; + int32_t tc = (int32_t)(TC * 60.0f); + return ((lt + tc) % 86400 + 86400) % 86400; +} + +static void _update_display(local_solar_time_state_t *state, watch_date_time_t dt) { + char buf[14]; + + if (_load_location().reg == 0) { + watch_display_text(WATCH_POSITION_FULL, "SO no Loc"); + return; + } + + switch (state->mode) { + + case LOCAL_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)); + watch_set_colon(); + break; + } + + case LOCAL_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; + sprintf(buf, "nO %02d%02d ", (int)(s / 3600), (int)((s % 3600) / 60)); + watch_set_colon(); + break; + } + + case LOCAL_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)); + sprintf(buf, "Hr %+4d ", (int)hra); + watch_clear_colon(); + break; + } + + default: + return; + } + + watch_display_text(WATCH_POSITION_FULL, buf); +} + +/* ---- Movement callbacks -------------------------------------------------- */ + +void local_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)); + /* 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; + +#if __EMSCRIPTEN__ + /* In the simulator the browser exposes lat/lon as JS globals. + * Write them to location.u32 if not already set. */ + int16_t browser_lat = EM_ASM_INT({ return lat; }); + int16_t browser_lon = EM_ASM_INT({ return lon; }); + if (browser_lat || browser_lon) { + movement_location_t browser_loc = {0}; + filesystem_read_file("location.u32", (char *)&browser_loc.reg, sizeof(browser_loc.reg)); + if (browser_loc.reg == 0) { + browser_loc.bit.latitude = browser_lat; + browser_loc.bit.longitude = browser_lon; + filesystem_write_file("location.u32", (char *)&browser_loc.reg, sizeof(browser_loc.reg)); + } + } +#endif + + /* Force recompute on activation: timezone or location may have changed */ + state->last_calc_d = 0; + watch_date_time_t dt = movement_get_local_date_time(); + _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; + + switch (event.event_type) { + case EVENT_ACTIVATE: + case EVENT_TICK: { + watch_date_time_t dt = movement_get_local_date_time(); + _maybe_recompute(state, dt); + _update_display(state, dt); + break; + } + + case EVENT_ALARM_BUTTON_UP: + state->mode = (local_solar_time_mode_t)((state->mode + 1) % LOCAL_SOLAR_TIME_NUM_MODES); + { + watch_date_time_t dt = movement_get_local_date_time(); + _update_display(state, dt); + } + break; + + case EVENT_LOW_ENERGY_UPDATE: { + if (!watch_sleep_animation_is_running()) watch_start_sleep_animation(1000); + watch_date_time_t dt = movement_get_local_date_time(); + _maybe_recompute(state, dt); + _update_display(state, dt); + break; + } + + case EVENT_TIMEOUT: + state->mode = LOCAL_SOLAR_TIME_MODE_LST; + if (_load_location().reg == 0) movement_move_to_face(0); + break; + + default: + return movement_default_loop_handler(event); + } + + 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; + watch_clear_colon(); +} diff --git a/watch-faces/complication/local_solar_time_face.h b/watch-faces/complication/local_solar_time_face.h new file mode 100644 index 00000000..dc677ed0 --- /dev/null +++ b/watch-faces/complication/local_solar_time_face.h @@ -0,0 +1,84 @@ +/* + * MIT License + * + * Copyright (c) 2025 Raffael Mancini + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +/* + * LOCAL SOLAR TIME FACE + * + * Displays solar time information based on the user's location. + * Formulas follow the notation from: + * https://www.pveducation.org/pvcdrom/properties-of-sunlight/solar-time + * + * Variables (pveducation.org notation): + * LSTM - Local Standard Time Meridian [degrees] = 15 * ΔTUTC + * 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 + * HRA - Hour Angle [degrees] = 15*(LST - 12) + * + * B, EoT and TC only depend on the day-of-year d, so they are cached + * in state and recomputed exactly once per day: the cache key is d itself + * (1-366). Zero-initialisation of state guarantees a recompute on first use. + * + * Requires the location to be set via the Sunrise/Sunset face, stored in + * "location.u32" on the filesystem. If no location is set, displays + * "SO no Loc". + * + * Display modes (cycle with the Alarm / start-stop button): + * SO HH:MM:SS — Local 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 + */ + +#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; + +typedef struct { + local_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; + +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); + +#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, \ + NULL, \ +}) From 1a33ae88f75eaeee5167a88e29d1164cbd77a992 Mon Sep 17 00:00:00 2001 From: Raffael Mancini Date: Wed, 4 Mar 2026 12:34:23 +0100 Subject: [PATCH 2/7] 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, \ }) From 0d6be495ef150f669d85663e517c0d17979f6a9b Mon Sep 17 00:00:00 2001 From: Raffael Mancini Date: Wed, 4 Mar 2026 13:33:26 +0100 Subject: [PATCH 3/7] Rollback config --- movement_config.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/movement_config.h b/movement_config.h index bd23b810..01d718b1 100644 --- a/movement_config.h +++ b/movement_config.h @@ -28,10 +28,10 @@ #include "movement_faces.h" const watch_face_t watch_faces[] = { - local_solar_time_face, - clock_face, - /* world_clock_face, */ + clock_face, + world_clock_face, sunrise_sunset_face, + solar_time_face, moon_phase_face, fast_stopwatch_face, countdown_face, @@ -50,7 +50,7 @@ const watch_face_t watch_faces[] = { * Some folks also like to use this to hide the preferences and time set faces from the normal rotation. * If you don't want any faces to be excluded, set this to 0 and a long Mode press will have no effect. */ -#define MOVEMENT_SECONDARY_FACE_INDEX (MOVEMENT_NUM_FACES - 5) +#define MOVEMENT_SECONDARY_FACE_INDEX 5 /* Custom hourly chime tune. Check movement_custom_signal_tunes.h for options. */ #define SIGNAL_TUNE_DEFAULT @@ -107,6 +107,6 @@ const watch_face_t watch_faces[] = { * A value of 4 is a good starting point if you have issues * with multiple button presses firing. */ -#define MOVEMENT_DEBOUNCE_TICKS 0 +#define MOVEMENT_DEBOUNCE_TICKS 4 #endif // MOVEMENT_CONFIG_H_ From c2cead4e3bfc4e84e8b9b5928f3b058ff2f0c778 Mon Sep 17 00:00:00 2001 From: Raffael Mancini Date: Wed, 4 Mar 2026 13:33:43 +0100 Subject: [PATCH 4/7] Support custom display --- watch-faces/clock/solar_time_face.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/watch-faces/clock/solar_time_face.c b/watch-faces/clock/solar_time_face.c index f0b69ed0..3f83e287 100644 --- a/watch-faces/clock/solar_time_face.c +++ b/watch-faces/clock/solar_time_face.c @@ -102,10 +102,13 @@ static int32_t _lst_seconds(watch_date_time_t dt, float TC) { } static void _update_display(solar_time_state_t *state, watch_date_time_t dt) { - char buf[14]; + char bottom[7]; if (_load_location().reg == 0) { - watch_display_text(WATCH_POSITION_FULL, "SO no Loc"); + watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "SOL", "SO"); + watch_display_text(WATCH_POSITION_TOP_RIGHT, " "); + watch_display_text(WATCH_POSITION_BOTTOM, "no Loc"); + watch_clear_colon(); return; } @@ -113,7 +116,8 @@ static void _update_display(solar_time_state_t *state, watch_date_time_t dt) { case SOLAR_TIME_MODE_LST: { int32_t s = _lst_seconds(dt, state->TC); - sprintf(buf, "SO %02d%02d%02d", + watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "SOL", "SO"); + sprintf(bottom, "%02d%02d%02d", (int)(s / 3600), (int)((s % 3600) / 60), (int)(s % 60)); watch_set_colon(); break; @@ -123,7 +127,8 @@ static void _update_display(solar_time_state_t *state, watch_date_time_t dt) { /* 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; - sprintf(buf, "nO %02d%02d ", (int)(s / 3600), (int)((s % 3600) / 60)); + watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "NOO", "nO"); + sprintf(bottom, "%02d%02d ", (int)(s / 3600), (int)((s % 3600) / 60)); watch_set_colon(); break; } @@ -132,7 +137,8 @@ static void _update_display(solar_time_state_t *state, watch_date_time_t dt) { /* 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)); - sprintf(buf, "Hr %+4d ", (int)hra); + watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "HrA", "Hr"); + sprintf(bottom, "%+4d ", (int)hra); watch_clear_colon(); break; } @@ -141,7 +147,8 @@ static void _update_display(solar_time_state_t *state, watch_date_time_t dt) { return; } - watch_display_text(WATCH_POSITION_FULL, buf); + watch_display_text(WATCH_POSITION_TOP_RIGHT, " "); + watch_display_text(WATCH_POSITION_BOTTOM, bottom); } /* ---- Movement callbacks -------------------------------------------------- */ From eba8b7953e976b3d01f9ec9f69b7686833d669dc Mon Sep 17 00:00:00 2001 From: Raffael Mancini Date: Wed, 4 Mar 2026 14:24:27 +0100 Subject: [PATCH 5/7] Revert more config --- movement_config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/movement_config.h b/movement_config.h index 01d718b1..adaf7cdb 100644 --- a/movement_config.h +++ b/movement_config.h @@ -50,7 +50,7 @@ const watch_face_t watch_faces[] = { * Some folks also like to use this to hide the preferences and time set faces from the normal rotation. * If you don't want any faces to be excluded, set this to 0 and a long Mode press will have no effect. */ -#define MOVEMENT_SECONDARY_FACE_INDEX 5 +#define MOVEMENT_SECONDARY_FACE_INDEX (MOVEMENT_NUM_FACES - 5) /* Custom hourly chime tune. Check movement_custom_signal_tunes.h for options. */ #define SIGNAL_TUNE_DEFAULT @@ -107,6 +107,6 @@ const watch_face_t watch_faces[] = { * A value of 4 is a good starting point if you have issues * with multiple button presses firing. */ -#define MOVEMENT_DEBOUNCE_TICKS 4 +#define MOVEMENT_DEBOUNCE_TICKS 0 #endif // MOVEMENT_CONFIG_H_ From 14d0ba73e0e1d3ca02f7b9b5f3f576970738ee61 Mon Sep 17 00:00:00 2001 From: Raffael Mancini Date: Wed, 4 Mar 2026 14:55:32 +0100 Subject: [PATCH 6/7] Better support for custom display --- watch-faces/clock/solar_time_face.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/watch-faces/clock/solar_time_face.c b/watch-faces/clock/solar_time_face.c index 3f83e287..54592975 100644 --- a/watch-faces/clock/solar_time_face.c +++ b/watch-faces/clock/solar_time_face.c @@ -117,6 +117,7 @@ static void _update_display(solar_time_state_t *state, watch_date_time_t dt) { case SOLAR_TIME_MODE_LST: { int32_t s = _lst_seconds(dt, state->TC); watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "SOL", "SO"); + watch_display_text(WATCH_POSITION_TOP_RIGHT, "Ar"); sprintf(bottom, "%02d%02d%02d", (int)(s / 3600), (int)((s % 3600) / 60), (int)(s % 60)); watch_set_colon(); @@ -127,7 +128,8 @@ static void _update_display(solar_time_state_t *state, watch_date_time_t dt) { /* 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; - watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "NOO", "nO"); + watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "NOO", "NO"); + watch_display_text(WATCH_POSITION_TOP_RIGHT, "n "); sprintf(bottom, "%02d%02d ", (int)(s / 3600), (int)((s % 3600) / 60)); watch_set_colon(); break; @@ -138,6 +140,7 @@ static void _update_display(solar_time_state_t *state, watch_date_time_t dt) { int32_t s = _lst_seconds(dt, state->TC); int16_t hra = (int16_t)roundf(15.0f * ((float)s / 3600.0f - 12.0f)); watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "HrA", "Hr"); + watch_display_text(WATCH_POSITION_TOP_RIGHT, "n "); sprintf(bottom, "%+4d ", (int)hra); watch_clear_colon(); break; @@ -147,7 +150,6 @@ static void _update_display(solar_time_state_t *state, watch_date_time_t dt) { return; } - watch_display_text(WATCH_POSITION_TOP_RIGHT, " "); watch_display_text(WATCH_POSITION_BOTTOM, bottom); } From 1243c57dccc1cfc825f529e70eff6002f09cafe1 Mon Sep 17 00:00:00 2001 From: voloved <36523934+voloved@users.noreply.github.com> Date: Sat, 14 Mar 2026 09:58:25 -0400 Subject: [PATCH 7/7] Remove solar_time_face from watch_faces array --- movement_config.h | 1 - 1 file changed, 1 deletion(-) diff --git a/movement_config.h b/movement_config.h index adaf7cdb..2f48d8fd 100644 --- a/movement_config.h +++ b/movement_config.h @@ -31,7 +31,6 @@ const watch_face_t watch_faces[] = { clock_face, world_clock_face, sunrise_sunset_face, - solar_time_face, moon_phase_face, fast_stopwatch_face, countdown_face,