diff --git a/src/heartratetask/HeartRateTask.cpp b/src/heartratetask/HeartRateTask.cpp index 1184ba1e..25437c42 100644 --- a/src/heartratetask/HeartRateTask.cpp +++ b/src/heartratetask/HeartRateTask.cpp @@ -100,8 +100,8 @@ void HeartRateTask::StopMeasurement() { } void HeartRateTask::StartWaiting() { - StopMeasurement(); - backgroundWaitingStart = xTaskGetTickCount(); + StopMeasurement(); + backgroundWaitingStart = xTaskGetTickCount(); } void HeartRateTask::HandleBackgroundWaiting() { @@ -138,22 +138,23 @@ void HeartRateTask::HandleSensorData(int* lastBpm) { StartWaiting(); } } - if (bpm == 0 && state == States::BackgroundMeasuring && xTaskGetTickCount() - measurementStart >= DURATION_UNTIL_BACKGROUND_MEASURMENT_IS_STOPPED) { + if (bpm == 0 && state == States::BackgroundMeasuring && + xTaskGetTickCount() - measurementStart >= DURATION_UNTIL_BACKGROUND_MEASURMENT_IS_STOPPED) { state = States::BackgroundWaiting; StartWaiting(); } } int HeartRateTask::CurrentTaskDelay() { - switch (state) { - case States::Measuring: - case States::BackgroundMeasuring: - return ppg.deltaTms; - case States::Running: - return 100; - case States::BackgroundWaiting: - return 10000; - default: - return portMAX_DELAY; - } + switch (state) { + case States::Measuring: + case States::BackgroundMeasuring: + return ppg.deltaTms; + case States::Running: + return 100; + case States::BackgroundWaiting: + return 10000; + default: + return portMAX_DELAY; + } } \ No newline at end of file diff --git a/src/heartratetask/HeartRateTask.h b/src/heartratetask/HeartRateTask.h index 620dcf24..d087d517 100644 --- a/src/heartratetask/HeartRateTask.h +++ b/src/heartratetask/HeartRateTask.h @@ -4,8 +4,8 @@ #include #include -#define DURATION_BETWEEN_BACKGROUND_MEASUREMENTS 5 * 60 * 1000 // 5 minutes assuming 1 Hz -#define DURATION_UNTIL_BACKGROUND_MEASURMENT_IS_STOPPED 30 * 1000 // 30 seconds assuming 1 Hz +#define DURATION_BETWEEN_BACKGROUND_MEASUREMENTS 5 * 60 * 1000 // 5 minutes assuming 1 Hz +#define DURATION_UNTIL_BACKGROUND_MEASURMENT_IS_STOPPED 30 * 1000 // 30 seconds assuming 1 Hz namespace Pinetime { namespace Drivers {