mirror of
https://github.com/firewalkwithm3/Sensor-Watch.git
synced 2024-11-22 11:10:29 +08:00
sunrise sunset fix during DST
This commit is contained in:
parent
0d16329574
commit
9d1410780c
|
@ -50,15 +50,16 @@ static void _sunrise_sunset_face_update(movement_settings_t *settings, sunrise_s
|
||||||
bool show_next_match = false;
|
bool show_next_match = false;
|
||||||
movement_location_t movement_location;
|
movement_location_t movement_location;
|
||||||
int16_t tz;
|
int16_t tz;
|
||||||
|
watch_date_time date_time = watch_rtc_get_date_time(); // the current local date / time
|
||||||
if (state->longLatToUse == 0 || _location_count <= 1) {
|
if (state->longLatToUse == 0 || _location_count <= 1) {
|
||||||
|
tz = get_timezone_offset(settings->bit.time_zone, date_time);
|
||||||
movement_location = (movement_location_t) watch_get_backup_data(1);
|
movement_location = (movement_location_t) watch_get_backup_data(1);
|
||||||
tz = movement_timezone_offsets[settings->bit.time_zone];
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
movement_location.bit.latitude = longLatPresets[state->longLatToUse].latitude;
|
movement_location.bit.latitude = longLatPresets[state->longLatToUse].latitude;
|
||||||
movement_location.bit.longitude = longLatPresets[state->longLatToUse].longitude;
|
movement_location.bit.longitude = longLatPresets[state->longLatToUse].longitude;
|
||||||
if (longLatPresets[state->longLatToUse].timezone == SUNRISE_USE_LOCAL_TZ)
|
if (longLatPresets[state->longLatToUse].uses_dst && dst_occurring(date_time))
|
||||||
tz = movement_timezone_offsets[settings->bit.time_zone];
|
tz = movement_timezone_dst_offsets[longLatPresets[state->longLatToUse].timezone];
|
||||||
else
|
else
|
||||||
tz = movement_timezone_offsets[longLatPresets[state->longLatToUse].timezone];
|
tz = movement_timezone_offsets[longLatPresets[state->longLatToUse].timezone];
|
||||||
}
|
}
|
||||||
|
@ -70,7 +71,6 @@ static void _sunrise_sunset_face_update(movement_settings_t *settings, sunrise_s
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
watch_date_time date_time = watch_rtc_get_date_time(); // the current local date / time
|
|
||||||
watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, tz * 60, 0); // the current date / time in UTC
|
watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, tz * 60, 0); // the current date / time in UTC
|
||||||
watch_date_time scratch_time; // scratchpad, contains different values at different times
|
watch_date_time scratch_time; // scratchpad, contains different values at different times
|
||||||
scratch_time.reg = utc_now.reg;
|
scratch_time.reg = utc_now.reg;
|
||||||
|
@ -343,7 +343,6 @@ void sunrise_sunset_face_activate(movement_settings_t *settings, void *context)
|
||||||
movement_location_t movement_location = (movement_location_t) watch_get_backup_data(1);
|
movement_location_t movement_location = (movement_location_t) watch_get_backup_data(1);
|
||||||
state->working_latitude = _sunrise_sunset_face_struct_from_latlon(movement_location.bit.latitude);
|
state->working_latitude = _sunrise_sunset_face_struct_from_latlon(movement_location.bit.latitude);
|
||||||
state->working_longitude = _sunrise_sunset_face_struct_from_latlon(movement_location.bit.longitude);
|
state->working_longitude = _sunrise_sunset_face_struct_from_latlon(movement_location.bit.longitude);
|
||||||
state->tz = get_timezone_offset(settings->bit.time_zone, watch_rtc_get_date_time());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sunrise_sunset_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
bool sunrise_sunset_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||||
|
|
|
@ -52,7 +52,6 @@ typedef struct {
|
||||||
uint8_t rise_index;
|
uint8_t rise_index;
|
||||||
uint8_t active_digit;
|
uint8_t active_digit;
|
||||||
bool location_changed;
|
bool location_changed;
|
||||||
int16_t tz;
|
|
||||||
watch_date_time rise_set_expires;
|
watch_date_time rise_set_expires;
|
||||||
sunrise_sunset_lat_lon_settings_t working_latitude;
|
sunrise_sunset_lat_lon_settings_t working_latitude;
|
||||||
sunrise_sunset_lat_lon_settings_t working_longitude;
|
sunrise_sunset_lat_lon_settings_t working_longitude;
|
||||||
|
@ -78,15 +77,18 @@ typedef struct {
|
||||||
char name[2];
|
char name[2];
|
||||||
int16_t latitude;
|
int16_t latitude;
|
||||||
int16_t longitude;
|
int16_t longitude;
|
||||||
uint8_t timezone; // References element in movement_timezone_offsets; Set to 0xFF to use local timezone
|
uint8_t timezone; // References element in movement_timezone_offsets
|
||||||
|
bool uses_dst;
|
||||||
} long_lat_presets_t;
|
} long_lat_presets_t;
|
||||||
|
|
||||||
// Locations must either use the same timezone as local time, or not observe DST.
|
// Locations must either use the same timezone as local time, or not observe DST.
|
||||||
static const long_lat_presets_t longLatPresets[] =
|
static const long_lat_presets_t longLatPresets[] =
|
||||||
{
|
{
|
||||||
{ .name = " "}, // Default, the long, lat, and timezone get replaced by what's set in the watch
|
{ .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 = "Ny", .latitude = 4072, .longitude = -7401, .timezone = 33, .uses_dst = true }, // New York City, NY
|
||||||
// { .name = "To", .latitude = 3567, .longitude = 13965, .timezone = 15 }, // Tokyo, JP
|
// { .name = "LA", .latitude = 3405, .longitude = -11824, .timezone = 30, .uses_dst = true }, // Los Angeles, CA
|
||||||
|
// { .name = "dE", .latitude = 4221, .longitude = -8305, .timezone = 33, .uses_dst = true }, // Detroit, MI
|
||||||
|
// { .name = "To", .latitude = 3567, .longitude = 13965, .timezone = 15, .uses_dst = false }, // Tokyo, JP
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SUNRISE_SUNSET_FACE_H_
|
#endif // SUNRISE_SUNSET_FACE_H_
|
||||||
|
|
Loading…
Reference in a new issue