From 1c871045c7b8b33b69c0d8bd13486edb08fab0b9 Mon Sep 17 00:00:00 2001 From: Tony Hoyle Date: Sat, 31 Aug 2024 16:47:47 +0100 Subject: [PATCH 1/2] Call set_time_face on long press of alarm. Move alert toggle to light. --- movement/watch_faces/clock/clock_face.c | 27 ++++++++++++++++++- .../watch_faces/clock/simple_clock_face.c | 25 ++++++++++++++++- .../watch_faces/clock/simple_clock_face.h | 2 ++ 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/movement/watch_faces/clock/clock_face.c b/movement/watch_faces/clock/clock_face.c index 20a02e7dc..349ffe645 100644 --- a/movement/watch_faces/clock/clock_face.c +++ b/movement/watch_faces/clock/clock_face.c @@ -35,6 +35,7 @@ #include "watch.h" #include "watch_utility.h" #include "watch_private_display.h" +#include "../settings/set_time_face.h" // 2.2 volts will happen when the battery has maybe 5-10% remaining? // we can refine this later. @@ -50,6 +51,8 @@ typedef struct { uint8_t watch_face_index; bool time_signal_enabled; bool battery_low; + void *set_time_context; + bool setting_mode; } clock_state_t; static bool clock_is_in_24h_mode(movement_settings_t *settings) { @@ -221,6 +224,7 @@ void clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, v clock_state_t *state = (clock_state_t *) *context_ptr; state->time_signal_enabled = false; state->watch_face_index = watch_face_index; + set_time_face.setup(settings, -1, &state->set_time_context); } } @@ -237,12 +241,27 @@ void clock_face_activate(movement_settings_t *settings, void *context) { // this ensures that none of the timestamp fields will match, so we can re-render them all. clock->date_time.previous.reg = 0xFFFFFFFF; + + clock->setting_mode = false; } bool clock_face_loop(movement_event_t event, movement_settings_t *settings, void *context) { clock_state_t *state = (clock_state_t *) context; watch_date_time current; + if(state->setting_mode) { + if(event.event_type != EVENT_MODE_BUTTON_UP) { + return set_time_face.loop(event, settings, state->set_time_context); + } else { + // We have to trigger an end to fastticks first.. bit hacky + event.event_type = EVENT_ALARM_LONG_UP; + set_time_face.loop(event, settings, state->set_time_context); + + state->setting_mode = false; + event.event_type = EVENT_ACTIVATE; + } + } + switch (event.event_type) { case EVENT_LOW_ENERGY_UPDATE: clock_start_tick_tock_animation(); @@ -260,6 +279,10 @@ bool clock_face_loop(movement_event_t event, movement_settings_t *settings, void break; case EVENT_ALARM_LONG_PRESS: + state->setting_mode = true; + set_time_face.activate(settings, state->set_time_context); + break; + case EVENT_LIGHT_LONG_PRESS: clock_toggle_time_signal(state); break; case EVENT_BACKGROUND_TASK: @@ -276,13 +299,15 @@ bool clock_face_loop(movement_event_t event, movement_settings_t *settings, void void clock_face_resign(movement_settings_t *settings, void *context) { (void) settings; - (void) context; + clock_state_t *state = (clock_state_t *) context; + set_time_face.resign(settings, state->set_time_context); } bool clock_face_wants_background_task(movement_settings_t *settings, void *context) { (void) settings; clock_state_t *state = (clock_state_t *) context; if (!state->time_signal_enabled) return false; + if (state->setting_mode) return true; watch_date_time date_time = watch_rtc_get_date_time(); diff --git a/movement/watch_faces/clock/simple_clock_face.c b/movement/watch_faces/clock/simple_clock_face.c index ac4ec2ee5..8153e1fa3 100644 --- a/movement/watch_faces/clock/simple_clock_face.c +++ b/movement/watch_faces/clock/simple_clock_face.c @@ -27,6 +27,7 @@ #include "watch.h" #include "watch_utility.h" #include "watch_private_display.h" +#include "../settings/set_time_face.h" static void _update_alarm_indicator(bool settings_alarm_enabled, simple_clock_state_t *state) { state->alarm_enabled = settings_alarm_enabled; @@ -43,6 +44,7 @@ void simple_clock_face_setup(movement_settings_t *settings, uint8_t watch_face_i simple_clock_state_t *state = (simple_clock_state_t *)*context_ptr; state->signal_enabled = false; state->watch_face_index = watch_face_index; + set_time_face.setup(settings, -1, &state->set_time_context); } } @@ -68,6 +70,8 @@ void simple_clock_face_activate(movement_settings_t *settings, void *context) { // this ensures that none of the timestamp fields will match, so we can re-render them all. state->previous_date_time = 0xFFFFFFFF; + + state->setting_mode = false; } bool simple_clock_face_loop(movement_event_t event, movement_settings_t *settings, void *context) { @@ -75,6 +79,19 @@ bool simple_clock_face_loop(movement_event_t event, movement_settings_t *setting char buf[11]; uint8_t pos; + if(state->setting_mode) { + if(event.event_type != EVENT_MODE_BUTTON_UP) { + return set_time_face.loop(event, settings, state->set_time_context); + } else { + // We have to trigger an end to fastticks first.. bit hacky + event.event_type = EVENT_ALARM_LONG_UP; + set_time_face.loop(event, settings, state->set_time_context); + + state->setting_mode = false; + event.event_type = EVENT_LOW_ENERGY_UPDATE; // This forces a full refresh + } + } + watch_date_time date_time; uint32_t previous_date_time; switch (event.event_type) { @@ -135,6 +152,10 @@ bool simple_clock_face_loop(movement_event_t event, movement_settings_t *setting if (state->alarm_enabled != settings->bit.alarm_enabled) _update_alarm_indicator(settings->bit.alarm_enabled, state); break; case EVENT_ALARM_LONG_PRESS: + state->setting_mode = true; + set_time_face.activate(settings, state->set_time_context); + break; + case EVENT_LIGHT_LONG_PRESS: state->signal_enabled = !state->signal_enabled; if (state->signal_enabled) watch_set_indicator(WATCH_INDICATOR_BELL); else watch_clear_indicator(WATCH_INDICATOR_BELL); @@ -153,13 +174,15 @@ bool simple_clock_face_loop(movement_event_t event, movement_settings_t *setting void simple_clock_face_resign(movement_settings_t *settings, void *context) { (void) settings; - (void) context; + simple_clock_state_t *state = (simple_clock_state_t *) context; + set_time_face.resign(settings, state->set_time_context); } bool simple_clock_face_wants_background_task(movement_settings_t *settings, void *context) { (void) settings; simple_clock_state_t *state = (simple_clock_state_t *)context; if (!state->signal_enabled) return false; + if (state->setting_mode) return true; watch_date_time date_time = watch_rtc_get_date_time(); diff --git a/movement/watch_faces/clock/simple_clock_face.h b/movement/watch_faces/clock/simple_clock_face.h index e74a6e864..a769fd33f 100644 --- a/movement/watch_faces/clock/simple_clock_face.h +++ b/movement/watch_faces/clock/simple_clock_face.h @@ -43,6 +43,8 @@ typedef struct { bool signal_enabled; bool battery_low; bool alarm_enabled; + void *set_time_context; + bool setting_mode; } simple_clock_state_t; void simple_clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr); From cbebf731309a3dbcd5515acf102ed2825ba0aaf1 Mon Sep 17 00:00:00 2001 From: Tony Hoyle Date: Sat, 31 Aug 2024 17:30:53 +0100 Subject: [PATCH 2/2] Remove set_time_face from default rotation --- movement/movement_config.h | 1 - 1 file changed, 1 deletion(-) diff --git a/movement/movement_config.h b/movement/movement_config.h index abceacf1c..e3c81c313 100644 --- a/movement/movement_config.h +++ b/movement/movement_config.h @@ -34,7 +34,6 @@ const watch_face_t watch_faces[] = { moon_phase_face, stopwatch_face, preferences_face, - set_time_face, thermistor_readout_face, voltage_face };