mirror of
https://github.com/firewalkwithm3/Sensor-Watch.git
synced 2024-11-22 19:20:30 +08:00
Bugfix on not registering the top of an hour
This commit is contained in:
parent
aebea960c0
commit
2824a62908
|
@ -430,8 +430,8 @@ uint8_t movement_claim_backup_register(void) {
|
|||
return movement_state.next_available_backup_register++;
|
||||
}
|
||||
|
||||
uint8_t check_and_act_on_daylight_savings(watch_date_time date_time) {
|
||||
if (movement_state.settings.bit.dst_active) return date_time.unit.hour;
|
||||
bool check_and_act_on_daylight_savings(watch_date_time date_time) {
|
||||
if (!movement_state.settings.bit.dst_active) return false;
|
||||
uint8_t dst_result = get_dst_status(date_time);
|
||||
bool dst_skip_rolling_back = get_dst_skip_rolling_back();
|
||||
|
||||
|
@ -439,15 +439,17 @@ uint8_t check_and_act_on_daylight_savings(watch_date_time date_time) {
|
|||
clear_dst_skip_rolling_back();
|
||||
}
|
||||
else if (dst_result == DST_ENDING && !dst_skip_rolling_back) {
|
||||
set_dst_skip_rolling_back();
|
||||
date_time.unit.hour = (date_time.unit.hour + 24 - 1) % 24;
|
||||
watch_rtc_set_date_time(date_time);
|
||||
set_dst_skip_rolling_back();
|
||||
return true;
|
||||
}
|
||||
else if (dst_result == DST_STARTING) {
|
||||
date_time.unit.hour = (date_time.unit.hour + 1) % 24;
|
||||
watch_rtc_set_date_time(date_time);
|
||||
return true;
|
||||
}
|
||||
return date_time.unit.hour;
|
||||
return false;
|
||||
}
|
||||
|
||||
int16_t get_timezone_offset(uint8_t timezone_idx, watch_date_time date_time) {
|
||||
|
@ -476,6 +478,18 @@ void app_init(void) {
|
|||
movement_state.settings.bit.le_interval = MOVEMENT_DEFAULT_LOW_ENERGY_INTERVAL;
|
||||
movement_state.settings.bit.led_duration = MOVEMENT_DEFAULT_LED_DURATION;
|
||||
movement_state.settings.bit.dst_active = MOVEMENT_DEFAULT_DST_ACTIVE;
|
||||
|
||||
#ifdef MAKEFILE_TIMEZONE
|
||||
timezone_offsets = dst_occurring(watch_rtc_get_date_time()) ? movement_timezone_dst_offsets : movement_timezone_offsets;
|
||||
for (int i = 0; i < NUM_TIME_ZONES; i++) {
|
||||
if (timezone_offsets[i] == MAKEFILE_TIMEZONE) {
|
||||
movement_state.settings.bit.time_zone = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
movement_state.settings.bit.time_zone = 35; // Atlantic Time as default
|
||||
#endif
|
||||
movement_state.light_ticks = -1;
|
||||
movement_state.alarm_ticks = -1;
|
||||
movement_state.next_available_backup_register = 4;
|
||||
|
|
|
@ -313,7 +313,7 @@ void movement_play_alarm(void);
|
|||
void movement_play_alarm_beeps(uint8_t rounds, BuzzerNote alarm_note);
|
||||
|
||||
uint8_t movement_claim_backup_register(void);
|
||||
uint8_t check_and_act_on_daylight_savings(watch_date_time date_time); // Returns the currently set hour
|
||||
bool check_and_act_on_daylight_savings(watch_date_time date_time); // Returns if the time was changed due to DST
|
||||
int16_t get_timezone_offset(uint8_t timezone_idx, watch_date_time date_time);
|
||||
|
||||
#endif // MOVEMENT_H_
|
||||
|
|
|
@ -284,12 +284,7 @@ bool clock_face_wants_background_task(movement_settings_t *settings, void *conte
|
|||
(void) settings;
|
||||
clock_state_t *state = (clock_state_t *) context;
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
uint8_t hour_dst = check_and_act_on_daylight_savings(date_time);
|
||||
if(hour_dst != date_time.unit.hour) {
|
||||
char buf[3 + 1];
|
||||
sprintf(buf, "%2d", hour_dst);
|
||||
watch_display_string(buf, 4);
|
||||
}
|
||||
check_and_act_on_daylight_savings(date_time);
|
||||
if (!state->time_signal_enabled) return false;
|
||||
|
||||
return date_time.unit.minute == 0;
|
||||
|
|
|
@ -154,12 +154,7 @@ bool simple_clock_face_wants_background_task(movement_settings_t *settings, void
|
|||
(void) settings;
|
||||
simple_clock_state_t *state = (simple_clock_state_t *)context;
|
||||
watch_date_time date_time = watch_rtc_get_date_time();
|
||||
uint8_t hour_dst = check_and_act_on_daylight_savings(date_time);
|
||||
if(hour_dst != date_time.unit.hour) {
|
||||
char buf[3 + 1];
|
||||
sprintf(buf, "%2d", hour_dst);
|
||||
watch_display_string(buf, 4);
|
||||
}
|
||||
check_and_act_on_daylight_savings(date_time);
|
||||
if (!state->signal_enabled) return false;
|
||||
|
||||
return date_time.unit.minute == 0;
|
||||
|
|
|
@ -106,10 +106,10 @@ uint8_t get_dst_status(watch_date_time date_time) {
|
|||
dst_end_time.unit.day = 15 - watch_utility_get_iso8601_weekday_number(dst_end_time.unit.year + WATCH_RTC_REFERENCE_YEAR, dst_end_time.unit.month, 1);
|
||||
unix_dst_end_time = watch_utility_date_time_to_unix_time(dst_end_time, 0);
|
||||
|
||||
if (date_time.unit.second > 45) // In emu, it's been seen that we may trigger at 59sec rather than exactly 0 each time
|
||||
date_time.unit.minute = (date_time.unit.minute + 1) % 60;
|
||||
date_time.unit.second = 0;
|
||||
unix_curr_time = watch_utility_date_time_to_unix_time(date_time, 0);
|
||||
unix_curr_time -= date_time.unit.second;
|
||||
if (date_time.unit.second > 45) // In emu, it's been seen that we may trigger at 59sec rather than exactly 0 each time
|
||||
unix_curr_time += 60;
|
||||
|
||||
if (unix_curr_time == unix_dst_start_time) return DST_STARTING;
|
||||
if (unix_curr_time == unix_dst_end_time) return DST_ENDING;
|
||||
|
|
Loading…
Reference in a new issue