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.
This commit is contained in:
Matheus Afonso Martins Moreira 2024-03-05 04:29:52 -03:00
parent e1b1493894
commit fb3b96c8b7

View file

@ -139,7 +139,11 @@ void pulsometer_face_setup(movement_settings_t *settings, uint8_t watch_face_ind
if (*context_ptr == NULL) { if (*context_ptr == NULL) {
pulsometer_state_t *pulsometer = malloc(sizeof(pulsometer_state_t)); pulsometer_state_t *pulsometer = malloc(sizeof(pulsometer_state_t));
pulsometer->calibration = PULSOMETER_FACE_CALIBRATION_DEFAULT; pulsometer->calibration = PULSOMETER_FACE_CALIBRATION_DEFAULT;
pulsometer->pulses = 0;
pulsometer->ticks = 0;
*context_ptr = pulsometer; *context_ptr = pulsometer;
} }
} }
@ -150,8 +154,6 @@ void pulsometer_face_activate(movement_settings_t *settings, void *context) {
pulsometer_state_t *pulsometer = context; pulsometer_state_t *pulsometer = context;
pulsometer->measuring = false; pulsometer->measuring = false;
pulsometer->pulses = 0;
pulsometer->ticks = 0;
pulsometer_display_title(pulsometer); pulsometer_display_title(pulsometer);
pulsometer_display_calibration(pulsometer); pulsometer_display_calibration(pulsometer);