From e048cdeb5278b8ccbf99f38b5a8bb2036dbb157f Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Tue, 20 May 2025 17:34:45 -0400 Subject: [PATCH] activity logging: try to ignore spurious active minutes --- watch-faces/sensor/activity_logging_face.c | 9 ++++++++- watch-faces/sensor/activity_logging_face.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/watch-faces/sensor/activity_logging_face.c b/watch-faces/sensor/activity_logging_face.c index d73f3e46..1fdfd9b4 100644 --- a/watch-faces/sensor/activity_logging_face.c +++ b/watch-faces/sensor/activity_logging_face.c @@ -135,7 +135,14 @@ movement_watch_face_advisory_t activity_logging_face_advise(void *context) { activity_logging_state_t *state = (activity_logging_state_t *)context; movement_watch_face_advisory_t retval = { 0 }; - if (!HAL_GPIO_A4_read()) state->active_minutes_today++; + if (!HAL_GPIO_A4_read()) { + // only count this as an active minute if the previous minute was also active. + // otherwise, set the flag and we'll count the next minute if the wearer is still active. + if (state->previous_minute_was_active) state->active_minutes_today++; + else state->previous_minute_was_active = true; + } else { + state->previous_minute_was_active = false; + } watch_date_time_t datetime = movement_get_local_date_time(); // request a background task at midnight to shuffle the data into the log diff --git a/watch-faces/sensor/activity_logging_face.h b/watch-faces/sensor/activity_logging_face.h index 8deea666..6c5b74fb 100644 --- a/watch-faces/sensor/activity_logging_face.h +++ b/watch-faces/sensor/activity_logging_face.h @@ -53,6 +53,7 @@ typedef struct { uint16_t data_points; // the number of days logged uint8_t display_index; // the index we are displaying on screen uint16_t active_minutes_today; // the number of active minutes logged today + bool previous_minute_was_active; // we only want to count two or more consecutive active minutes } activity_logging_state_t; void activity_logging_face_setup(uint8_t watch_face_index, void ** context_ptr);