From: Matheus Afonso Martins Moreira Date: Sun, 8 Sep 2024 14:09:10 +0000 (-0300) Subject: Merge PR #268 - add daylight savings time toggle X-Git-Url: https://git.earman.xyz/?a=commitdiff_plain;h=5a8a49a8c77d6d5ba0f46f0e5b51dec2daba46db;p=sensor-watch.git Merge PR #268 - add daylight savings time toggle Adds a toggle in the preferences face that allows the user to enable or disable the daylight savings time. Should help produce the correct results with the sunrise/sunset presets. A proper solution would be to integrate the tzinfo database but it's too big for the watch at the time of this writing. Can't be done unless it can be shrunk down into a subset the user would be interested. Even then it's a stopgap since the database is likely to keep growing over time. Reviewed-by: Matheus Afonso Martins Moreira GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/268 --- 5a8a49a8c77d6d5ba0f46f0e5b51dec2daba46db diff --cc movement/movement.h index 2158b7d,d61d510..929552f --- a/movement/movement.h +++ b/movement/movement.h @@@ -60,10 -60,10 +60,11 @@@ typedef union // time-oriented complication like a sunrise/sunset timer, and a simple locale preference could tell an // altimeter to display feet or meters as easily as it tells a thermometer to display degrees in F or C. bool clock_mode_24h : 1; // indicates whether clock should use 12 or 24 hour mode. + bool clock_24h_leading_zero : 1; // indicates whether clock should leading zero to indicate 24 hour mode. bool use_imperial_units : 1; // indicates whether to use metric units (the default) or imperial. bool alarm_enabled : 1; // indicates whether there is at least one alarm enabled. - uint8_t reserved : 5; // room for more preferences if needed. + bool dst_active : 1; // indicates whether daylight savings time is active - uint8_t reserved : 5; // room for more preferences if needed. ++ uint8_t reserved : 4; // room for more preferences if needed. } bit; uint32_t reg; } movement_settings_t; diff --cc movement/watch_faces/settings/set_time_face.c index 605849f,fb0c806..d50d24b --- a/movement/watch_faces/settings/set_time_face.c +++ b/movement/watch_faces/settings/set_time_face.c @@@ -25,10 -25,9 +25,10 @@@ #include #include "set_time_face.h" #include "watch.h" +#include "watch_utility.h" - #define SET_TIME_FACE_NUM_SETTINGS (7) - const char set_time_face_titles[SET_TIME_FACE_NUM_SETTINGS][3] = {"HR", "M1", "SE", "YR", "MO", "DA", "ZO"}; + #define SET_TIME_FACE_NUM_SETTINGS (8) + const char set_time_face_titles[SET_TIME_FACE_NUM_SETTINGS][3] = {"HR", "M1", "SE", "YR", "MO", "DA", "ZO", "DS"}; static bool _quick_ticks_running; @@@ -59,9 -66,17 +59,19 @@@ static void _handle_alarm_button(moveme settings->bit.time_zone++; if (settings->bit.time_zone > 40) settings->bit.time_zone = 0; break; + case 7: // daylight savings time + if (settings->bit.dst_active) { // deactivate DST + date_time.unit.hour = (date_time.unit.hour + 24 - 1) % 24; + settings->bit.time_zone = movement_dst_inverse_jump_table[settings->bit.time_zone]; + } else { // activate DST + date_time.unit.hour = (date_time.unit.hour + 1) % 24; + settings->bit.time_zone = movement_dst_jump_table[settings->bit.time_zone]; + } + settings->bit.dst_active = !settings->bit.dst_active; + break; } + if (date_time.unit.day > days_in_month(date_time.unit.month, date_time.unit.year + WATCH_RTC_REFERENCE_YEAR)) + date_time.unit.day = 1; watch_rtc_set_date_time(date_time); }