From 0d16329574a18f7ba8cbf9e8705d9c5b60b8fa3f Mon Sep 17 00:00:00 2001 From: David Volovskiy Date: Sun, 8 Sep 2024 09:03:43 -0400 Subject: [PATCH] Sunrise sunset face now warns about using DST --- .../complication/sunrise_sunset_face.c | 15 +++++++++------ .../complication/sunrise_sunset_face.h | 12 +++++++----- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/movement/watch_faces/complication/sunrise_sunset_face.c b/movement/watch_faces/complication/sunrise_sunset_face.c index 29e6404..a436776 100644 --- a/movement/watch_faces/complication/sunrise_sunset_face.c +++ b/movement/watch_faces/complication/sunrise_sunset_face.c @@ -57,7 +57,10 @@ static void _sunrise_sunset_face_update(movement_settings_t *settings, sunrise_s else{ movement_location.bit.latitude = longLatPresets[state->longLatToUse].latitude; movement_location.bit.longitude = longLatPresets[state->longLatToUse].longitude; - tz = movement_timezone_offsets[longLatPresets[state->longLatToUse].timezone]; + if (longLatPresets[state->longLatToUse].timezone == SUNRISE_USE_LOCAL_TZ) + tz = movement_timezone_offsets[settings->bit.time_zone]; + else + tz = movement_timezone_offsets[longLatPresets[state->longLatToUse].timezone]; } if (movement_location.reg == 0) { @@ -405,11 +408,11 @@ bool sunrise_sunset_face_loop(movement_event_t event, movement_settings_t *setti break; case EVENT_ALARM_LONG_PRESS: if (state->page == 0) { - if (state->longLatToUse != 0) { - state->longLatToUse = 0; - _sunrise_sunset_face_update(settings, state); - break; - } + if (state->longLatToUse != 0) { + state->longLatToUse = 0; + _sunrise_sunset_face_update(settings, state); + break; + } state->page++; state->active_digit = 0; watch_clear_display(); diff --git a/movement/watch_faces/complication/sunrise_sunset_face.h b/movement/watch_faces/complication/sunrise_sunset_face.h index 429253e..537fc51 100644 --- a/movement/watch_faces/complication/sunrise_sunset_face.h +++ b/movement/watch_faces/complication/sunrise_sunset_face.h @@ -59,6 +59,8 @@ typedef struct { uint8_t longLatToUse; } sunrise_sunset_state_t; +#define SUNRISE_USE_LOCAL_TZ 0xFF + void sunrise_sunset_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr); void sunrise_sunset_face_activate(movement_settings_t *settings, void *context); bool sunrise_sunset_face_loop(movement_event_t event, movement_settings_t *settings, void *context); @@ -76,15 +78,15 @@ typedef struct { char name[2]; int16_t latitude; int16_t longitude; - int16_t timezone; // References element in movement_timezone_offsets + uint8_t timezone; // References element in movement_timezone_offsets; Set to 0xFF to use local timezone } long_lat_presets_t; +// Locations must either use the same timezone as local time, or not observe DST. static const long_lat_presets_t longLatPresets[] = { - { .name = " "}, // Default, the long and lat get replaced by what's set in the watch - { .name = "Ny", .latitude = 4072, .longitude = -7401, .timezone = 35 }, // New York City, NY - { .name = "LA", .latitude = 3405, .longitude = -11824, .timezone = 30 }, // Los Angeles, CA - { .name = "dE", .latitude = 4221, .longitude = -8305, .timezone = 35 }, // Detroit, MI + { .name = " "}, // Default, the long, lat, and timezone get replaced by what's set in the watch +// { .name = "dE", .latitude = 4221, .longitude = -8305, .timezone = SUNRISE_USE_LOCAL_TZ }, // Detroit, MI; Assumes you live in the Eastern Timezone +// { .name = "To", .latitude = 3567, .longitude = 13965, .timezone = 15 }, // Tokyo, JP }; #endif // SUNRISE_SUNSET_FACE_H_