From fb3b96c8b772948956819374991e984998bd2324 Mon Sep 17 00:00:00 2001 From: Matheus Afonso Martins Moreira Date: Tue, 5 Mar 2024 04:29:52 -0300 Subject: [PATCH] faces/pulsometer: remember pulsometer measurement Avoid resetting it to zero when the face is activated. Initialize the variables once when the face is first set up. This makes it remember the last measurement taken by the user. It will no longer be overwritten when the watch face activates. --- movement/watch_faces/complication/pulsometer_face.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/movement/watch_faces/complication/pulsometer_face.c b/movement/watch_faces/complication/pulsometer_face.c index bf7027c..3c04aa1 100644 --- a/movement/watch_faces/complication/pulsometer_face.c +++ b/movement/watch_faces/complication/pulsometer_face.c @@ -139,7 +139,11 @@ void pulsometer_face_setup(movement_settings_t *settings, uint8_t watch_face_ind if (*context_ptr == NULL) { pulsometer_state_t *pulsometer = malloc(sizeof(pulsometer_state_t)); + pulsometer->calibration = PULSOMETER_FACE_CALIBRATION_DEFAULT; + pulsometer->pulses = 0; + pulsometer->ticks = 0; + *context_ptr = pulsometer; } } @@ -150,8 +154,6 @@ void pulsometer_face_activate(movement_settings_t *settings, void *context) { pulsometer_state_t *pulsometer = context; pulsometer->measuring = false; - pulsometer->pulses = 0; - pulsometer->ticks = 0; pulsometer_display_title(pulsometer); pulsometer_display_calibration(pulsometer);