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