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:
@@ -132,8 +132,9 @@ bool set_time_hackwatch_face_loop(movement_event_t event, movement_settings_t *s
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (current_page != 2) // Do not set time when we are at seconds, it was already set previously
|
||||
if (current_page != 2) { // Do not set time when we are at seconds, it was already set previously
|
||||
watch_rtc_set_date_time(date_time_settings);
|
||||
}
|
||||
break;
|
||||
|
||||
case EVENT_ALARM_LONG_UP://Setting seconds on long release
|
||||
@@ -171,11 +172,16 @@ bool set_time_hackwatch_face_loop(movement_event_t event, movement_settings_t *s
|
||||
if (settings->bit.time_zone > 40) settings->bit.time_zone = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (date_time_settings.unit.day > days_in_month(date_time_settings.unit.month, date_time_settings.unit.year + WATCH_RTC_REFERENCE_YEAR))
|
||||
date_time_settings.unit.day = 1;
|
||||
if (current_page != 2) // Do not set time when we are at seconds, it was already set previously
|
||||
|
||||
if (current_page != 2) { // Do not set time when we are at seconds, it was already set previously
|
||||
watch_rtc_set_date_time(date_time_settings);
|
||||
}
|
||||
|
||||
//TODO: Do not update whole RTC, just what we are changing
|
||||
|
||||
break;
|
||||
case EVENT_TIMEOUT:
|
||||
movement_move_to_face(0);
|
||||
@@ -231,12 +237,13 @@ bool set_time_hackwatch_face_loop(movement_event_t event, movement_settings_t *s
|
||||
watch_clear_colon();
|
||||
sprintf(buf, "%s ", set_time_hackwatch_face_titles[current_page]);
|
||||
} else {
|
||||
int16_t tz = get_timezone_offset(settings->bit.time_zone, date_time_settings);
|
||||
watch_set_colon();
|
||||
sprintf(buf,
|
||||
"%s %3d%02d ",
|
||||
set_time_hackwatch_face_titles[current_page],
|
||||
(int8_t)(movement_timezone_offsets[settings->bit.time_zone] / 60),
|
||||
(int8_t)(movement_timezone_offsets[settings->bit.time_zone] % 60) * (movement_timezone_offsets[settings->bit.time_zone] < 0 ? -1 : 1));
|
||||
(int8_t)(tz / 60),
|
||||
(int8_t)(tz % 60) * (tz < 0 ? -1 : 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user