Merge PR #470 - implement automatic DST toggling

Implements logic to automatically offset daylight saving time settings
when calculating timezone offsets. This should make the DST functions
work automatically with no need for user input in most cases.

Reviewed-by: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/470
This commit is contained in:
Matheus Afonso Martins Moreira
2024-09-08 13:41:52 -03:00
32 changed files with 295 additions and 165 deletions

View File

@@ -30,6 +30,19 @@ ext_irq_cb_t btn_alarm_callback;
ext_irq_cb_t a2_callback;
ext_irq_cb_t a4_callback;
static bool dst_skip_rolling_back;
bool get_dst_skip_rolling_back(void) {
return dst_skip_rolling_back;
}
void set_dst_skip_rolling_back(void) {
dst_skip_rolling_back = true;
}
void clear_dst_skip_rolling_back(void) {
dst_skip_rolling_back = false;
}
bool _watch_rtc_is_enabled(void) {
return RTC->MODE2.CTRLA.bit.ENABLE;
}
@@ -60,6 +73,7 @@ void watch_rtc_set_date_time(watch_date_time date_time) {
_sync_rtc(); // Double sync as without it at high Hz faces setting time is unrealiable (specifically, set_time_hackwatch)
RTC->MODE2.CLOCK.reg = date_time.reg;
_sync_rtc();
clear_dst_skip_rolling_back();
}
watch_date_time watch_rtc_get_date_time(void) {