add a manual dst toggle
Uses a simplistic set of jump tables to toggle daylight savings on and off.
This commit is contained in:
@@ -26,8 +26,8 @@
|
||||
#include "set_time_face.h"
|
||||
#include "watch.h"
|
||||
|
||||
#define SET_TIME_FACE_NUM_SETTINGS (7)
|
||||
const char set_time_face_titles[SET_TIME_FACE_NUM_SETTINGS][3] = {"HR", "M1", "SE", "YR", "MO", "DA", "ZO"};
|
||||
#define SET_TIME_FACE_NUM_SETTINGS (8)
|
||||
const char set_time_face_titles[SET_TIME_FACE_NUM_SETTINGS][3] = {"HR", "M1", "SE", "YR", "MO", "DA", "ZO", "DS"};
|
||||
|
||||
static bool _quick_ticks_running;
|
||||
|
||||
@@ -66,6 +66,16 @@ static void _handle_alarm_button(movement_settings_t *settings, watch_date_time
|
||||
settings->bit.time_zone++;
|
||||
if (settings->bit.time_zone > 40) settings->bit.time_zone = 0;
|
||||
break;
|
||||
case 7: // daylight savings time
|
||||
if (settings->bit.dst_active) { // deactivate DST
|
||||
date_time.unit.hour = (date_time.unit.hour + 24 - 1) % 24;
|
||||
settings->bit.time_zone = movement_dst_inverse_jump_table[settings->bit.time_zone];
|
||||
} else { // activate DST
|
||||
date_time.unit.hour = (date_time.unit.hour + 1) % 24;
|
||||
settings->bit.time_zone = movement_dst_jump_table[settings->bit.time_zone];
|
||||
}
|
||||
settings->bit.dst_active = !settings->bit.dst_active;
|
||||
break;
|
||||
}
|
||||
watch_rtc_set_date_time(date_time);
|
||||
}
|
||||
@@ -146,7 +156,7 @@ bool set_time_face_loop(movement_event_t event, movement_settings_t *settings, v
|
||||
watch_clear_indicator(WATCH_INDICATOR_24H);
|
||||
watch_clear_indicator(WATCH_INDICATOR_PM);
|
||||
sprintf(buf, "%s %2d%02d%02d", set_time_face_titles[current_page], date_time.unit.year + 20, date_time.unit.month, date_time.unit.day);
|
||||
} else {
|
||||
} else if (current_page < 7) { // zone
|
||||
if (event.subsecond % 2) {
|
||||
watch_clear_colon();
|
||||
sprintf(buf, "%s ", set_time_face_titles[current_page]);
|
||||
@@ -154,6 +164,10 @@ bool set_time_face_loop(movement_event_t event, movement_settings_t *settings, v
|
||||
watch_set_colon();
|
||||
sprintf(buf, "%s %3d%02d ", set_time_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));
|
||||
}
|
||||
} else { // daylight savings
|
||||
watch_clear_colon();
|
||||
if (settings->bit.dst_active) sprintf(buf, "%s dsT y", set_time_face_titles[current_page]);
|
||||
else sprintf(buf, "%s dsT n", set_time_face_titles[current_page]);
|
||||
}
|
||||
|
||||
// blink up the parameter we're setting
|
||||
|
||||
Reference in New Issue
Block a user