2021-01-10 16:57:26 +00:00
|
|
|
#include "HeartRateController.h"
|
|
|
|
#include <heartratetask/HeartRateTask.h>
|
2021-01-10 21:02:21 +00:00
|
|
|
#include <systemtask/SystemTask.h>
|
2021-01-10 16:57:26 +00:00
|
|
|
|
|
|
|
using namespace Pinetime::Controllers;
|
|
|
|
|
2021-01-10 21:02:21 +00:00
|
|
|
HeartRateController::HeartRateController(Pinetime::System::SystemTask &systemTask) : systemTask{systemTask} {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-10 16:57:26 +00:00
|
|
|
void HeartRateController::Update(HeartRateController::States newState, uint8_t heartRate) {
|
|
|
|
this->state = newState;
|
|
|
|
this->heartRate = heartRate;
|
|
|
|
}
|
|
|
|
|
|
|
|
void HeartRateController::Start() {
|
2021-01-10 21:02:21 +00:00
|
|
|
if(task != nullptr) {
|
2021-01-10 16:57:26 +00:00
|
|
|
task->PushMessage(Pinetime::Applications::HeartRateTask::Messages::StartMeasurement);
|
2021-01-10 21:02:21 +00:00
|
|
|
systemTask.PushMessage(System::SystemTask::Messages::HeartRateRunning);
|
|
|
|
}
|
2021-01-10 16:57:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HeartRateController::Stop() {
|
2021-01-10 21:02:21 +00:00
|
|
|
if(task != nullptr) {
|
2021-01-10 16:57:26 +00:00
|
|
|
task->PushMessage(Pinetime::Applications::HeartRateTask::Messages::StopMeasurement);
|
2021-01-10 21:02:21 +00:00
|
|
|
systemTask.PushMessage(System::SystemTask::Messages::HeartRateStopped);
|
|
|
|
}
|
2021-01-10 16:57:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HeartRateController::SetHeartRateTask(Pinetime::Applications::HeartRateTask *task) {
|
|
|
|
this->task = task;
|
|
|
|
}
|
2021-01-10 21:02:21 +00:00
|
|
|
|