activity logging: try to ignore spurious active minutes

This commit is contained in:
Joey Castillo 2025-05-20 17:34:45 -04:00
parent acdc32ffb4
commit e048cdeb52
2 changed files with 9 additions and 1 deletions

View File

@ -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

View File

@ -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);