rebase on main
This commit is contained in:
parent
0370e3cd65
commit
a5db54af27
|
@ -24,7 +24,7 @@ void HeartRateTask::Process(void* instance) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeartRateTask::Work() {
|
void HeartRateTask::Work() {
|
||||||
lastBpm = 0;
|
int lastBpm = 0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
auto delay = CurrentTaskDelay();
|
auto delay = CurrentTaskDelay();
|
||||||
|
@ -75,7 +75,7 @@ void HeartRateTask::Work() {
|
||||||
if (state == States::BackgroundWaiting) {
|
if (state == States::BackgroundWaiting) {
|
||||||
HandleBackgroundWaiting();
|
HandleBackgroundWaiting();
|
||||||
} else if (state == States::BackgroundMeasuring || state == States::Measuring) {
|
} else if (state == States::BackgroundMeasuring || state == States::Measuring) {
|
||||||
HandleSensorData();
|
HandleSensorData(&lastBpm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ void HeartRateTask::HandleBackgroundWaiting() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeartRateTask::HandleSensorData() {
|
void HeartRateTask::HandleSensorData(int* lastBpm) {
|
||||||
int8_t ambient = ppg.Preprocess(heartRateSensor.ReadHrs(), heartRateSensor.ReadAls());
|
int8_t ambient = ppg.Preprocess(heartRateSensor.ReadHrs(), heartRateSensor.ReadAls());
|
||||||
int bpm = ppg.HeartRate();
|
int bpm = ppg.HeartRate();
|
||||||
|
|
||||||
|
@ -113,24 +113,20 @@ void HeartRateTask::HandleSensorData() {
|
||||||
if (ambient > 0) {
|
if (ambient > 0) {
|
||||||
// Reset all DAQ buffers
|
// Reset all DAQ buffers
|
||||||
ppg.Reset(true);
|
ppg.Reset(true);
|
||||||
// Force state to NotEnoughData (below)
|
|
||||||
lastBpm = 0;
|
|
||||||
bpm = 0;
|
|
||||||
} else if (bpm < 0) {
|
} else if (bpm < 0) {
|
||||||
// Reset all DAQ buffers except HRS buffer
|
// Reset all DAQ buffers except HRS buffer
|
||||||
ppg.Reset(false);
|
ppg.Reset(false);
|
||||||
// Set HR to zero and update
|
// Set HR to zero and update
|
||||||
bpm = 0;
|
bpm = 0;
|
||||||
controller.Update(Controllers::HeartRateController::States::Running, bpm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastBpm == 0 && bpm == 0) {
|
if (*lastBpm == 0 && bpm == 0) {
|
||||||
controller.Update(Controllers::HeartRateController::States::NotEnoughData, bpm);
|
controller.Update(Controllers::HeartRateController::States::NotEnoughData, bpm);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bpm != 0) {
|
if (bpm != 0) {
|
||||||
lastBpm = bpm;
|
*lastBpm = bpm;
|
||||||
controller.Update(Controllers::HeartRateController::States::Running, lastBpm);
|
controller.Update(Controllers::HeartRateController::States::Running, bpm);
|
||||||
if (state == States::BackgroundMeasuring) {
|
if (state == States::BackgroundMeasuring) {
|
||||||
StopMeasurement();
|
StopMeasurement();
|
||||||
state = States::BackgroundWaiting;
|
state = States::BackgroundWaiting;
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Pinetime {
|
||||||
void StopMeasurement();
|
void StopMeasurement();
|
||||||
|
|
||||||
void HandleBackgroundWaiting();
|
void HandleBackgroundWaiting();
|
||||||
void HandleSensorData();
|
void HandleSensorData(int* lastBpm);
|
||||||
int CurrentTaskDelay();
|
int CurrentTaskDelay();
|
||||||
|
|
||||||
TaskHandle_t taskHandle;
|
TaskHandle_t taskHandle;
|
||||||
|
@ -41,7 +41,6 @@ namespace Pinetime {
|
||||||
Drivers::Hrs3300& heartRateSensor;
|
Drivers::Hrs3300& heartRateSensor;
|
||||||
Controllers::HeartRateController& controller;
|
Controllers::HeartRateController& controller;
|
||||||
Controllers::Ppg ppg;
|
Controllers::Ppg ppg;
|
||||||
int lastBpm = 0;
|
|
||||||
TickType_t backgroundMeasurementWaitingStart = 0;
|
TickType_t backgroundMeasurementWaitingStart = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue