summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>2024-02-24 19:36:34 -0300
committerMatheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>2024-02-25 15:24:14 -0300
commite2cba9f2f2ed43a9ec4f35749867190aa08de9f9 (patch)
treecf17bd0c2a02643ce584b1a6fb4c3140d2993866
parente6d8b6aaff4e67aee68c34156f3a781aaa8c2709 (diff)
downloadSensor-Watch-e2cba9f2f2ed43a9ec4f35749867190aa08de9f9.tar.gz
Sensor-Watch-e2cba9f2f2ed43a9ec4f35749867190aa08de9f9.tar.bz2
Sensor-Watch-e2cba9f2f2ed43a9ec4f35749867190aa08de9f9.zip
faces/clock: simplify alarm indication function
Deduplicates state in the clock state and movement settings. Makes the code simpler. Also makes it use the correct indicator. For some reason it had been switched with the hourly chime indicator. WATCH_INDICATOR_BELL The small bell indicating that an alarm is set. WATCH_INDICATOR_SIGNAL The hourly signal indicator. Also useful for indicating that sensors are on.
-rw-r--r--movement/watch_faces/clock/clock_face.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/movement/watch_faces/clock/clock_face.c b/movement/watch_faces/clock/clock_face.c
index 24e33c9c..ec0afe86 100644
--- a/movement/watch_faces/clock/clock_face.c
+++ b/movement/watch_faces/clock/clock_face.c
@@ -34,7 +34,6 @@ typedef struct {
uint8_t watch_face_index;
bool signal_enabled;
bool battery_low;
- bool alarm_enabled;
} clock_state_t;
static void clock_indicate(WatchIndicatorSegment indicator, bool on) {
@@ -45,10 +44,8 @@ static void clock_indicate(WatchIndicatorSegment indicator, bool on) {
}
}
-static void _update_alarm_indicator(bool settings_alarm_enabled, clock_state_t *state) {
- state->alarm_enabled = settings_alarm_enabled;
- if (state->alarm_enabled) watch_set_indicator(WATCH_INDICATOR_SIGNAL);
- else watch_clear_indicator(WATCH_INDICATOR_SIGNAL);
+static void clock_indicate_alarm(movement_settings_t *settings) {
+ clock_indicate(WATCH_INDICATOR_BELL, settings->bit.alarm_enabled);
}
void clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
@@ -64,7 +61,7 @@ void clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, v
}
void clock_face_activate(movement_settings_t *settings, void *context) {
- clock_state_t *state = (clock_state_t *) context;
+ clock_state_t *clock = (clock_state_t *) context;
if (watch_tick_animation_is_running()) watch_stop_tick_animation();
@@ -74,13 +71,12 @@ void clock_face_activate(movement_settings_t *settings, void *context) {
if (state->signal_enabled) watch_set_indicator(WATCH_INDICATOR_BELL);
else watch_clear_indicator(WATCH_INDICATOR_BELL);
- // show alarm indicator if there is an active alarm
- _update_alarm_indicator(settings->bit.alarm_enabled, state);
+ clock_indicate_alarm(settings);
watch_set_colon();
// this ensures that none of the timestamp fields will match, so we can re-render them all.
- state->previous_date_time = 0xFFFFFFFF;
+ clock->previous_date_time = 0xFFFFFFFF;
}
bool clock_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
@@ -142,8 +138,10 @@ bool clock_face_loop(movement_event_t event, movement_settings_t *settings, void
}
}
watch_display_string(buf, pos);
+
// handle alarm indicator
- if (state->alarm_enabled != settings->bit.alarm_enabled) _update_alarm_indicator(settings->bit.alarm_enabled, state);
+ clock_indicate_alarm(settings);
+
break;
case EVENT_ALARM_LONG_PRESS:
state->signal_enabled = !state->signal_enabled;