mirror of
https://github.com/firewalkwithm3/Sensor-Watch.git
synced 2024-11-22 19:20:30 +08:00
Fixed the tz that the world clock references
This commit is contained in:
parent
5ae88e438d
commit
1462d18376
|
@ -185,7 +185,7 @@ static bool mode_display(movement_event_t event, movement_settings_t *settings,
|
||||||
/* Determine current time at time zone and store date/time */
|
/* Determine current time at time zone and store date/time */
|
||||||
date_time = watch_rtc_get_date_time();
|
date_time = watch_rtc_get_date_time();
|
||||||
timestamp = watch_utility_date_time_to_unix_time(date_time, state->tz * 60);
|
timestamp = watch_utility_date_time_to_unix_time(date_time, state->tz * 60);
|
||||||
date_time = watch_utility_date_time_from_unix_time(timestamp, state->tz * 60);
|
date_time = watch_utility_date_time_from_unix_time(timestamp, state->tz_curr * 60);
|
||||||
previous_date_time = state->previous_date_time;
|
previous_date_time = state->previous_date_time;
|
||||||
state->previous_date_time = date_time.reg;
|
state->previous_date_time = date_time.reg;
|
||||||
|
|
||||||
|
@ -234,6 +234,7 @@ static bool mode_display(movement_event_t event, movement_settings_t *settings,
|
||||||
break;
|
break;
|
||||||
case EVENT_ALARM_BUTTON_UP:
|
case EVENT_ALARM_BUTTON_UP:
|
||||||
state->current_zone = find_selected_zone(state, FORWARD);
|
state->current_zone = find_selected_zone(state, FORWARD);
|
||||||
|
state->tz_curr = get_timezone_offset(state->current_zone, watch_rtc_get_date_time());
|
||||||
state->previous_date_time = REFRESH_TIME;
|
state->previous_date_time = REFRESH_TIME;
|
||||||
break;
|
break;
|
||||||
case EVENT_LIGHT_BUTTON_DOWN:
|
case EVENT_LIGHT_BUTTON_DOWN:
|
||||||
|
@ -241,6 +242,7 @@ static bool mode_display(movement_event_t event, movement_settings_t *settings,
|
||||||
break;
|
break;
|
||||||
case EVENT_LIGHT_BUTTON_UP:
|
case EVENT_LIGHT_BUTTON_UP:
|
||||||
state->current_zone = find_selected_zone(state, BACKWARD);
|
state->current_zone = find_selected_zone(state, BACKWARD);
|
||||||
|
state->tz_curr = get_timezone_offset(state->current_zone, watch_rtc_get_date_time());
|
||||||
state->previous_date_time = REFRESH_TIME;
|
state->previous_date_time = REFRESH_TIME;
|
||||||
break;
|
break;
|
||||||
case EVENT_LIGHT_LONG_PRESS:
|
case EVENT_LIGHT_LONG_PRESS:
|
||||||
|
@ -285,7 +287,7 @@ static bool mode_settings(movement_event_t event, movement_settings_t *settings,
|
||||||
watch_clear_indicator(WATCH_INDICATOR_PM);
|
watch_clear_indicator(WATCH_INDICATOR_PM);
|
||||||
refresh_face = false;
|
refresh_face = false;
|
||||||
}
|
}
|
||||||
result = div(state->tz, 60);
|
result = div(state->tz_curr, 60);
|
||||||
hours = result.quot;
|
hours = result.quot;
|
||||||
minutes = result.rem;
|
minutes = result.rem;
|
||||||
|
|
||||||
|
@ -314,17 +316,21 @@ static bool mode_settings(movement_event_t event, movement_settings_t *settings,
|
||||||
break;
|
break;
|
||||||
case EVENT_ALARM_BUTTON_UP:
|
case EVENT_ALARM_BUTTON_UP:
|
||||||
state->current_zone = mod(state->current_zone + FORWARD, NUM_TIME_ZONES);
|
state->current_zone = mod(state->current_zone + FORWARD, NUM_TIME_ZONES);
|
||||||
|
state->tz_curr = get_timezone_offset(state->current_zone, watch_rtc_get_date_time());
|
||||||
break;
|
break;
|
||||||
case EVENT_LIGHT_BUTTON_UP:
|
case EVENT_LIGHT_BUTTON_UP:
|
||||||
state->current_zone = mod(state->current_zone + BACKWARD, NUM_TIME_ZONES);
|
state->current_zone = mod(state->current_zone + BACKWARD, NUM_TIME_ZONES);
|
||||||
|
state->tz_curr = get_timezone_offset(state->current_zone, watch_rtc_get_date_time());
|
||||||
break;
|
break;
|
||||||
case EVENT_LIGHT_BUTTON_DOWN:
|
case EVENT_LIGHT_BUTTON_DOWN:
|
||||||
/* Do nothing */
|
/* Do nothing */
|
||||||
break;
|
break;
|
||||||
case EVENT_ALARM_LONG_PRESS:
|
case EVENT_ALARM_LONG_PRESS:
|
||||||
/* Find next selected zone */
|
/* Find next selected zone */
|
||||||
if (!state->zones[state->current_zone].selected)
|
if (!state->zones[state->current_zone].selected) {
|
||||||
state->current_zone = find_selected_zone(state, FORWARD);
|
state->current_zone = find_selected_zone(state, FORWARD);
|
||||||
|
state->tz_curr = get_timezone_offset(state->current_zone, watch_rtc_get_date_time());
|
||||||
|
}
|
||||||
|
|
||||||
/* Switch to display mode */
|
/* Switch to display mode */
|
||||||
state->current_mode = WORLD_CLOCK2_MODE_DISPLAY;
|
state->current_mode = WORLD_CLOCK2_MODE_DISPLAY;
|
||||||
|
|
|
@ -105,6 +105,7 @@ typedef struct {
|
||||||
uint8_t current_zone;
|
uint8_t current_zone;
|
||||||
uint32_t previous_date_time;
|
uint32_t previous_date_time;
|
||||||
int16_t tz;
|
int16_t tz;
|
||||||
|
int16_t tz_curr;
|
||||||
} world_clock2_state_t;
|
} world_clock2_state_t;
|
||||||
|
|
||||||
void world_clock2_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void **context_ptr);
|
void world_clock2_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void **context_ptr);
|
||||||
|
|
|
@ -69,7 +69,7 @@ static bool world_clock_face_do_display_mode(movement_event_t event, movement_se
|
||||||
case EVENT_LOW_ENERGY_UPDATE:
|
case EVENT_LOW_ENERGY_UPDATE:
|
||||||
date_time = watch_rtc_get_date_time();
|
date_time = watch_rtc_get_date_time();
|
||||||
timestamp = watch_utility_date_time_to_unix_time(date_time, state->tz * 60);
|
timestamp = watch_utility_date_time_to_unix_time(date_time, state->tz * 60);
|
||||||
date_time = watch_utility_date_time_from_unix_time(timestamp, state->tz * 60);
|
date_time = watch_utility_date_time_from_unix_time(timestamp, state->tz_curr * 60);
|
||||||
previous_date_time = state->previous_date_time;
|
previous_date_time = state->previous_date_time;
|
||||||
state->previous_date_time = date_time.reg;
|
state->previous_date_time = date_time.reg;
|
||||||
|
|
||||||
|
@ -158,6 +158,7 @@ static bool _world_clock_face_do_settings_mode(movement_event_t event, movement_
|
||||||
case 3:
|
case 3:
|
||||||
state->settings.bit.timezone_index++;
|
state->settings.bit.timezone_index++;
|
||||||
if (state->settings.bit.timezone_index > 40) state->settings.bit.timezone_index = 0;
|
if (state->settings.bit.timezone_index > 40) state->settings.bit.timezone_index = 0;
|
||||||
|
state->tz_curr = get_timezone_offset(state->settings.bit.timezone_index, watch_rtc_get_date_time());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -172,8 +173,8 @@ static bool _world_clock_face_do_settings_mode(movement_event_t event, movement_
|
||||||
sprintf(buf, "%c%c %3d%02d ",
|
sprintf(buf, "%c%c %3d%02d ",
|
||||||
movement_valid_position_0_chars[state->settings.bit.char_0],
|
movement_valid_position_0_chars[state->settings.bit.char_0],
|
||||||
movement_valid_position_1_chars[state->settings.bit.char_1],
|
movement_valid_position_1_chars[state->settings.bit.char_1],
|
||||||
(int8_t) (state->tz / 60),
|
(int8_t) (state->tz_curr / 60),
|
||||||
(int8_t) (state->tz % 60) * (state->tz < 0 ? -1 : 1));
|
(int8_t) (state->tz_curr % 60) * (state->tz_curr < 0 ? -1 : 1));
|
||||||
watch_set_colon();
|
watch_set_colon();
|
||||||
watch_clear_indicator(WATCH_INDICATOR_PM);
|
watch_clear_indicator(WATCH_INDICATOR_PM);
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ typedef struct {
|
||||||
uint8_t current_screen;
|
uint8_t current_screen;
|
||||||
uint32_t previous_date_time;
|
uint32_t previous_date_time;
|
||||||
int16_t tz;
|
int16_t tz;
|
||||||
|
int16_t tz_curr;
|
||||||
} world_clock_state_t;
|
} world_clock_state_t;
|
||||||
|
|
||||||
void world_clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
void world_clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||||
|
|
Loading…
Reference in a new issue