movement_state.settings.bit.button_should_sound = value;
}
+movement_clock_mode_t movement_clock_mode_24h(void) {
+ return movement_state.settings.bit.clock_mode_24h ? MOVEMENT_CLOCK_MODE_24H : MOVEMENT_CLOCK_MODE_12H;
+}
+
+void movement_set_clock_mode_24h(movement_clock_mode_t value) {
+ movement_state.settings.bit.clock_mode_24h = (value == MOVEMENT_CLOCK_MODE_24H);
+}
+
void app_init(void) {
_watch_init();
// stuff we'll want to make available to all watch faces and stash in the BKUP[3] register.
// This allows these preferences to be stored before entering BACKUP mode and and restored after waking from reset.
+typedef enum {
+ MOVEMENT_CLOCK_MODE_12H = 0,
+ MOVEMENT_CLOCK_MODE_24H,
+ MOVEMENT_NUM_CLOCK_MODES
+} movement_clock_mode_t;
+
// movement_settings_t contains global settings that cover watch behavior, including preferences around clock and unit
// display, time zones, buzzer behavior, LED color and low energy mode timeouts.
typedef union {
bool movement_button_should_sound(void);
void movement_set_button_should_sound(bool value);
+
+movement_clock_mode_t movement_clock_mode_24h(void);
+void movement_set_clock_mode_24h(movement_clock_mode_t value);
} clock_state_t;
static bool clock_is_in_24h_mode(movement_settings_t *settings) {
-#ifdef CLOCK_FACE_24H_ONLY
- return true;
-#else
- return settings->bit.clock_mode_24h;
-#endif
+ return movement_clock_mode_24h();
}
static bool clock_should_set_leading_zero(movement_settings_t *settings) {
}
static void clock_indicate_pm(movement_settings_t *settings, watch_date_time date_time) {
- if (settings->bit.clock_mode_24h) { return; }
+ if (movement_clock_mode_24h()) { return; }
clock_indicate(WATCH_INDICATOR_PM, clock_is_pm(date_time));
}
watch_stop_tick_animation();
}
- if (settings->bit.clock_mode_24h) {
+ if (movement_clock_mode_24h()) {
watch_set_indicator(WATCH_INDICATOR_24H);
}
close_enough_hour = (close_enough_hour + 1) % 24;
}
- if (!settings->bit.clock_mode_24h) {
+ if (!movement_clock_mode_24h()) {
// if we are in 12 hour mode, do some cleanup.
if (close_enough_hour < 12) {
watch_clear_indicator(WATCH_INDICATOR_PM);
else { watch_display_string("--", 8); }
break;
case EVENT_LIGHT_LONG_PRESS:
- // In case anyone really wants that upper time in 12-hour format. I thought about using the global setting (settings->bit.clock_mode_24h)
+ // In case anyone really wants that upper time in 12-hour format. I thought about using the global setting (movement_clock_mode_24h())
// for this preference, but thought someone who prefers 12-hour format normally, might prefer 24hr when compared to a 10hr decimal day,
// so this is separate for now.
state->use_am_pm = !state->use_am_pm;
watch_date_time date_time = watch_rtc_get_date_time();
char buffer[11];
- if (!settings->bit.clock_mode_24h) {
+ if (!movement_clock_mode_24h()) {
date_time.unit.hour %= 12;
sprintf(buffer, "%2d%02d ", date_time.unit.hour, date_time.unit.minute);
} else {
if (watch_tick_animation_is_running()) watch_stop_tick_animation();
- if (settings->bit.clock_mode_24h) watch_set_indicator(WATCH_INDICATOR_24H);
+ if (movement_clock_mode_24h()) watch_set_indicator(WATCH_INDICATOR_24H);
// handle chime indicator
if (state->signal_enabled) watch_set_indicator(WATCH_INDICATOR_BELL);
sprintf(buf, "%02d%02d", date_time.unit.minute, date_time.unit.second);
} else {
// other stuff changed; let's do it all.
- if (!settings->bit.clock_mode_24h) {
+ if (!movement_clock_mode_24h()) {
// if we are in 12 hour mode, do some cleanup.
if (date_time.unit.hour < 12) {
watch_clear_indicator(WATCH_INDICATOR_PM);
int minutes = date_time.unit.minute % 10;
// chiming hours
- if (!settings->bit.clock_mode_24h) {
+ if (!movement_clock_mode_24h()) {
hours = date_time.unit.hour % 12;
if (hours == 0) hours = 12;
}
if (watch_tick_animation_is_running()) watch_stop_tick_animation();
- if (settings->bit.clock_mode_24h) watch_set_indicator(WATCH_INDICATOR_24H);
+ if (movement_clock_mode_24h()) watch_set_indicator(WATCH_INDICATOR_24H);
// handle chime indicator
if (state->signal_enabled) watch_set_indicator(WATCH_INDICATOR_BELL);
sprintf(buf, "%02d%02d", date_time.unit.minute, date_time.unit.second);
} else {
// other stuff changed; let's do it all.
- if (!settings->bit.clock_mode_24h) {
+ if (!movement_clock_mode_24h()) {
// if we are in 12 hour mode, do some cleanup.
if (date_time.unit.hour < 12) {
watch_clear_indicator(WATCH_INDICATOR_PM);
int minutes = date_time.unit.minute % 15;
// chiming hours
- if (!settings->bit.clock_mode_24h) {
+ if (!movement_clock_mode_24h()) {
hours = date_time.unit.hour % 12;
if (hours == 0) hours = 12;
}
if (watch_tick_animation_is_running()) watch_stop_tick_animation();
- if (settings->bit.clock_mode_24h) watch_set_indicator(WATCH_INDICATOR_24H);
+ if (movement_clock_mode_24h()) watch_set_indicator(WATCH_INDICATOR_24H);
// handle chime indicator
if (state->signal_enabled) watch_set_indicator(WATCH_INDICATOR_BELL);
sprintf(buf, "%02d%02d", date_time.unit.minute, date_time.unit.second);
} else {
// other stuff changed; let's do it all.
- if (!settings->bit.clock_mode_24h) {
+ if (!movement_clock_mode_24h()) {
// if we are in 12 hour mode, do some cleanup.
if (date_time.unit.hour < 12) {
watch_clear_indicator(WATCH_INDICATOR_PM);
date_time = watch_rtc_get_date_time();
state->flashing_state = 1 + 128;
state->ticks = 4;
- if (!settings->bit.clock_mode_24h) {
+ if (!movement_clock_mode_24h()) {
date_time.unit.hour %= 12;
if (date_time.unit.hour == 0) date_time.unit.hour = 12;
}
if (watch_tick_animation_is_running()) watch_stop_tick_animation();
- if (settings->bit.clock_mode_24h) watch_set_indicator(WATCH_INDICATOR_24H);
+ if (movement_clock_mode_24h()) watch_set_indicator(WATCH_INDICATOR_24H);
// handle chime indicator
if (state->signal_enabled) watch_set_indicator(WATCH_INDICATOR_BELL);
sprintf(buf, "%02d%02d", date_time.unit.minute, watch_utility_get_weeknumber(date_time.unit.year, date_time.unit.month, date_time.unit.day));
} else {
// other stuff changed; let's do it all.
- if (!settings->bit.clock_mode_24h) {
+ if (!movement_clock_mode_24h()) {
// if we are in 12 hour mode, do some cleanup.
if (date_time.unit.hour < 12) {
watch_clear_indicator(WATCH_INDICATOR_PM);
if (refresh_face) {
watch_clear_indicator(WATCH_INDICATOR_SIGNAL);
watch_set_colon();
- if (settings->bit.clock_mode_24h)
+ if (movement_clock_mode_24h())
watch_set_indicator(WATCH_INDICATOR_24H);
state->previous_date_time = REFRESH_TIME;
sprintf(buf, "%02d%02d", date_time.unit.minute, date_time.unit.second);
} else {
/* Other stuff changed; Let's do it all. */
- if (!settings->bit.clock_mode_24h) {
+ if (!movement_clock_mode_24h()) {
/* If we are in 12 hour mode, do some cleanup. */
if (date_time.unit.hour < 12) {
watch_clear_indicator(WATCH_INDICATOR_PM);
watch_clear_indicator(WATCH_INDICATOR_LAP);
watch_date_time now = watch_rtc_get_date_time();
uint8_t hour = now.unit.hour;
- if (!settings->bit.clock_mode_24h) {
+ if (!movement_clock_mode_24h()) {
watch_clear_indicator(WATCH_INDICATOR_24H);
if (hour < 12)
watch_clear_indicator(WATCH_INDICATOR_PM);
}
//handle am/pm for hour display
uint8_t h = state->alarm[state->alarm_idx].hour;
- if (!settings->bit.clock_mode_24h) {
+ if (!movement_clock_mode_24h()) {
if (h >= 12) {
watch_set_indicator(WATCH_INDICATOR_PM);
h %= 12;
int i = state->current_index + 1;
if (state->current_page > 2) {
watch_set_colon();
- if (settings->bit.clock_mode_24h) {
+ if (movement_clock_mode_24h()) {
watch_set_indicator(WATCH_INDICATOR_24H);
sprintf(buf, "%s%2d%2d%02d ", settings_titles[state->current_page], i, date_time.unit.hour, date_time.unit.minute);
} else {
display_title(state);
break;
case EVENT_LOW_ENERGY_UPDATE:
- display_time(watch_rtc_get_date_time(), settings->bit.clock_mode_24h);
+ display_time(watch_rtc_get_date_time(), movement_clock_mode_24h());
break;
default:
return movement_default_loop_handler(event, settings);
return;
}
- if (settings->bit.clock_mode_24h) watch_set_indicator(WATCH_INDICATOR_24H);
+ if (movement_clock_mode_24h()) watch_set_indicator(WATCH_INDICATOR_24H);
// roll over hour iterator
if ( state->hour < 0 ) state->hour = 23;
else if ( scratch_time.unit.minute < 59 ) scratch_time.unit.minute++;
// if we are in 12 hour mode, do some cleanup
- if (!settings->bit.clock_mode_24h) {
+ if (!movement_clock_mode_24h()) {
if (scratch_time.unit.hour < 12) {
watch_clear_indicator(WATCH_INDICATOR_PM);
} else {
return;
}
- if (settings->bit.clock_mode_24h) watch_set_indicator(WATCH_INDICATOR_24H);
+ if (movement_clock_mode_24h()) watch_set_indicator(WATCH_INDICATOR_24H);
// PM for night hours, otherwise the night hours are counted from 13
if ( state->night ) {
- if (settings->bit.clock_mode_24h) night_hour_count = 12;
+ if (movement_clock_mode_24h()) night_hour_count = 12;
else watch_set_indicator(WATCH_INDICATOR_PM);
}
static void show_date_time(movement_settings_t *settings, solstice_state_t *state) {
char buf[11];
watch_date_time date_time = state->datetimes[state->index];
- if (!settings->bit.clock_mode_24h) {
+ if (!movement_clock_mode_24h()) {
if (date_time.unit.hour < 12) {
watch_clear_indicator(WATCH_INDICATOR_PM);
} else {
}
watch_set_colon();
- if (settings->bit.clock_mode_24h) watch_set_indicator(WATCH_INDICATOR_24H);
+ if (movement_clock_mode_24h()) watch_set_indicator(WATCH_INDICATOR_24H);
rise += hours_from_utc;
set += hours_from_utc;
if (date_time.reg < scratch_time.reg || show_next_match) {
if (state->rise_index == 0 || show_next_match) {
- if (!settings->bit.clock_mode_24h) {
+ if (!movement_clock_mode_24h()) {
if (watch_utility_convert_to_12_hour(&scratch_time)) watch_set_indicator(WATCH_INDICATOR_PM);
else watch_clear_indicator(WATCH_INDICATOR_PM);
}
if (date_time.reg < scratch_time.reg || show_next_match) {
if (state->rise_index == 0 || show_next_match) {
- if (!settings->bit.clock_mode_24h) {
+ if (!movement_clock_mode_24h()) {
if (watch_utility_convert_to_12_hour(&scratch_time)) watch_set_indicator(WATCH_INDICATOR_PM);
else watch_clear_indicator(WATCH_INDICATOR_PM);
}
uint8_t hour = state->hour;
watch_clear_display();
- if ( settings->bit.clock_mode_24h )
+ if ( movement_clock_mode_24h() )
watch_set_indicator(WATCH_INDICATOR_24H);
else {
if ( hour >= 12 )
} else {
date_time = logger_state->data[pos].timestamp;
watch_set_colon();
- if (settings->bit.clock_mode_24h) {
+ if (movement_clock_mode_24h()) {
watch_set_indicator(WATCH_INDICATOR_24H);
} else {
if (date_time.unit.hour > 11) watch_set_indicator(WATCH_INDICATOR_PM);
break;
case EVENT_LIGHT_BUTTON_DOWN:
logger_state->ts_ticks = 2;
- _thermistor_logging_face_update_display(logger_state, settings->bit.use_imperial_units, settings->bit.clock_mode_24h);
+ _thermistor_logging_face_update_display(logger_state, settings->bit.use_imperial_units, movement_clock_mode_24h());
break;
case EVENT_ALARM_BUTTON_DOWN:
logger_state->display_index = (logger_state->display_index + 1) % THERMISTOR_LOGGING_NUM_DATA_POINTS;
logger_state->ts_ticks = 0;
// fall through
case EVENT_ACTIVATE:
- _thermistor_logging_face_update_display(logger_state, settings->bit.use_imperial_units, settings->bit.clock_mode_24h);
+ _thermistor_logging_face_update_display(logger_state, settings->bit.use_imperial_units, movement_clock_mode_24h());
break;
case EVENT_TICK:
if (logger_state->ts_ticks && --logger_state->ts_ticks == 0) {
- _thermistor_logging_face_update_display(logger_state, settings->bit.use_imperial_units, settings->bit.clock_mode_24h);
+ _thermistor_logging_face_update_display(logger_state, settings->bit.use_imperial_units, movement_clock_mode_24h());
}
break;
case EVENT_BACKGROUND_TASK:
char buf[11];
if (current_page < 3) {
watch_set_colon();
- if (settings->bit.clock_mode_24h) {
+ if (movement_clock_mode_24h()) {
watch_set_indicator(WATCH_INDICATOR_24H);
sprintf(buf,
"%s %2d%02d%02d",
if (watch_tick_animation_is_running()) watch_stop_tick_animation();
- if (settings->bit.clock_mode_24h) watch_set_indicator(WATCH_INDICATOR_24H);
+ if (movement_clock_mode_24h()) watch_set_indicator(WATCH_INDICATOR_24H);
// handle chime indicator
if (state->signal_enabled) watch_set_indicator(WATCH_INDICATOR_BELL);
watch_display_text(WATCH_POSITION_SECONDS, buf + 2);
} else {
// other stuff changed; let's do it all.
- if (!settings->bit.clock_mode_24h) {
+ if (!movement_clock_mode_24h()) {
// if we are in 12 hour mode, do some cleanup.
if (date_time.unit.hour < 12) {
watch_clear_indicator(WATCH_INDICATOR_PM);
watch_date_time date_time;
switch (event.event_type) {
case EVENT_ACTIVATE:
- if (settings->bit.clock_mode_24h) watch_set_indicator(WATCH_INDICATOR_24H);
+ if (movement_clock_mode_24h()) watch_set_indicator(WATCH_INDICATOR_24H);
watch_set_colon();
state->previous_date_time = 0xFFFFFFFF;
// fall through
}
} else {
// other stuff changed; let's do it all.
- if (!settings->bit.clock_mode_24h) {
+ if (!movement_clock_mode_24h()) {
// if we are in 12 hour mode, do some cleanup.
if (date_time.unit.hour < 12) {
watch_clear_indicator(WATCH_INDICATOR_PM);
char buf[8];
switch (state->current_page) {
case PREFERENCES_PAGE_CLOCK_MODE:
- if (settings->bit.clock_mode_24h) watch_display_text(WATCH_POSITION_BOTTOM, "24h");
+ if (movement_clock_mode_24h()) watch_display_text(WATCH_POSITION_BOTTOM, "24h");
else watch_display_text(WATCH_POSITION_BOTTOM, "12h");
break;
case PREFERENCES_PAGE_BUTTON_SOUND:
case EVENT_ALARM_BUTTON_UP:
switch (state->current_page) {
case PREFERENCES_PAGE_CLOCK_MODE:
- settings->bit.clock_mode_24h = !settings->bit.clock_mode_24h;
+ movement_set_clock_mode_24h(((movement_clock_mode_24h() + 1) % MOVEMENT_NUM_CLOCK_MODES));
break;
case PREFERENCES_PAGE_BUTTON_SOUND:
movement_set_button_should_sound(!movement_button_should_sound());
watch_display_text(WATCH_POSITION_TOP_RIGHT, " ");
if (current_page < 3) {
watch_set_colon();
- if (settings->bit.clock_mode_24h) {
+ if (movement_clock_mode_24h()) {
watch_set_indicator(WATCH_INDICATOR_24H);
sprintf(buf, "%2d%02d%02d", date_time.unit.hour, date_time.unit.minute, date_time.unit.second);
} else {