reduce RAM size

This commit is contained in:
Patric Gruber 2024-07-11 15:53:18 +02:00
parent 616926345e
commit e6f0a89202
2 changed files with 21 additions and 22 deletions

View file

@ -5,6 +5,21 @@
using namespace Pinetime::Applications;
TickType_t CurrentTaskDelay(HeartRateTask::States state, TickType_t ppgDeltaTms) {
switch (state) {
case HeartRateTask::States::Measuring:
case HeartRateTask::States::BackgroundMeasuring:
return ppgDeltaTms;
case HeartRateTask::States::Running:
return pdMS_TO_TICKS(100);
case HeartRateTask::States::BackgroundWaiting:
return pdMS_TO_TICKS(10000);
default:
return portMAX_DELAY;
}
}
HeartRateTask::HeartRateTask(Drivers::Hrs3300& heartRateSensor,
Controllers::HeartRateController& controller,
Controllers::Settings& settings)
@ -26,10 +41,10 @@ void HeartRateTask::Process(void* instance) {
}
void HeartRateTask::Work() {
lastBpm = 0;
int lastBpm = 0;
while (true) {
TickType_t delay = CurrentTaskDelay();
TickType_t delay = CurrentTaskDelay(state, ppg.deltaTms);
Messages msg;
if (xQueueReceive(messageQueue, &msg, delay) == pdTRUE) {
@ -41,7 +56,7 @@ void HeartRateTask::Work() {
HandleWakeUp();
break;
case Messages::StartMeasurement:
HandleStartMeasurement();
HandleStartMeasurement(&lastBpm);
break;
case Messages::StopMeasurement:
HandleStopMeasurement();
@ -117,12 +132,12 @@ void HeartRateTask::HandleWakeUp() {
}
}
void HeartRateTask::HandleStartMeasurement() {
void HeartRateTask::HandleStartMeasurement(int* lastBpm) {
switch (state) {
case States::Idle:
case States::Running:
state = States::Measuring;
lastBpm = 0;
*lastBpm = 0;
StartMeasurement();
break;
case States::Measuring:
@ -201,20 +216,6 @@ void HeartRateTask::HandleSensorData(int* lastBpm) {
}
}
TickType_t HeartRateTask::CurrentTaskDelay() {
switch (state) {
case States::Measuring:
case States::BackgroundMeasuring:
return ppg.deltaTms;
case States::Running:
return pdMS_TO_TICKS(100);
case States::BackgroundWaiting:
return pdMS_TO_TICKS(10000);
default:
return portMAX_DELAY;
}
}
TickType_t HeartRateTask::GetHeartRateBackgroundMeasurementIntervalInTicks() {
int ms;
switch (settings.GetHeartRateBackgroundMeasurementInterval()) {

View file

@ -58,12 +58,11 @@ namespace Pinetime {
void HandleGoToSleep();
void HandleWakeUp();
void HandleStartMeasurement();
void HandleStartMeasurement(int* lastBpm);
void HandleStopMeasurement();
void HandleBackgroundWaiting();
void HandleSensorData(int* lastBpm);
TickType_t CurrentTaskDelay();
TickType_t GetHeartRateBackgroundMeasurementIntervalInTicks();
bool IsContinuosModeActivated();
@ -78,7 +77,6 @@ namespace Pinetime {
Controllers::Ppg ppg;
TickType_t backgroundWaitingStart = 0;
TickType_t measurementStart = 0;
int lastBpm = 0;
};
}