integrate code review

This commit is contained in:
Patric Gruber 2024-08-31 20:49:19 +02:00
parent 9501d36060
commit 7df39994ab
3 changed files with 5 additions and 8 deletions

View file

@ -13,7 +13,6 @@ void Settings::Init() {
} }
void Settings::SaveSettings() { void Settings::SaveSettings() {
// verify if is necessary to save // verify if is necessary to save
if (settingsChanged) { if (settingsChanged) {
SaveSettingsToFile(); SaveSettingsToFile();

View file

@ -10,10 +10,8 @@ TickType_t CurrentTaskDelay(HeartRateTask::States state, TickType_t ppgDeltaTms)
case HeartRateTask::States::ScreenOnAndMeasuring: case HeartRateTask::States::ScreenOnAndMeasuring:
case HeartRateTask::States::ScreenOffAndMeasuring: case HeartRateTask::States::ScreenOffAndMeasuring:
return ppgDeltaTms; return ppgDeltaTms;
case HeartRateTask::States::ScreenOnAndStopped:
return pdMS_TO_TICKS(100);
case HeartRateTask::States::ScreenOffAndWaiting: case HeartRateTask::States::ScreenOffAndWaiting:
return pdMS_TO_TICKS(10000); return pdMS_TO_TICKS(1000);
default: default:
return portMAX_DELAY; return portMAX_DELAY;
} }
@ -207,7 +205,7 @@ void HeartRateTask::HandleSensorData(int* lastBpm) {
if (bpm != 0) { if (bpm != 0) {
*lastBpm = bpm; *lastBpm = bpm;
controller.Update(Controllers::HeartRateController::States::Running, bpm); controller.Update(Controllers::HeartRateController::States::Running, bpm);
if (state == States::ScreenOnAndMeasuring || IsContinuosModeActivated()) { if (state == States::ScreenOnAndMeasuring || IsContinuousModeActivated()) {
return; return;
} }
if (state == States::ScreenOffAndMeasuring) { if (state == States::ScreenOffAndMeasuring) {
@ -216,7 +214,7 @@ void HeartRateTask::HandleSensorData(int* lastBpm) {
} }
} }
TickType_t ticksSinceMeasurementStart = xTaskGetTickCount() - measurementStart; TickType_t ticksSinceMeasurementStart = xTaskGetTickCount() - measurementStart;
if (bpm == 0 && state == States::ScreenOffAndMeasuring && !IsContinuosModeActivated() && if (bpm == 0 && state == States::ScreenOffAndMeasuring && !IsContinuousModeActivated() &&
ticksSinceMeasurementStart >= DURATION_UNTIL_BACKGROUND_MEASUREMENT_IS_STOPPED) { ticksSinceMeasurementStart >= DURATION_UNTIL_BACKGROUND_MEASUREMENT_IS_STOPPED) {
state = States::ScreenOffAndWaiting; state = States::ScreenOffAndWaiting;
StartWaiting(); StartWaiting();
@ -251,7 +249,7 @@ TickType_t HeartRateTask::GetHeartRateBackgroundMeasurementIntervalInTicks() {
return pdMS_TO_TICKS(ms); return pdMS_TO_TICKS(ms);
} }
bool HeartRateTask::IsContinuosModeActivated() { bool HeartRateTask::IsContinuousModeActivated() {
return settings.GetHeartRateBackgroundMeasurementInterval() == return settings.GetHeartRateBackgroundMeasurementInterval() ==
Pinetime::Controllers::Settings::HeartRateBackgroundMeasurementInterval::Continuous; Pinetime::Controllers::Settings::HeartRateBackgroundMeasurementInterval::Continuous;
} }

View file

@ -56,7 +56,7 @@ namespace Pinetime {
void HandleSensorData(int* lastBpm); void HandleSensorData(int* lastBpm);
TickType_t GetHeartRateBackgroundMeasurementIntervalInTicks(); TickType_t GetHeartRateBackgroundMeasurementIntervalInTicks();
bool IsContinuosModeActivated(); bool IsContinuousModeActivated();
bool IsBackgroundMeasurementActivated(); bool IsBackgroundMeasurementActivated();
TaskHandle_t taskHandle; TaskHandle_t taskHandle;