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;
|
|
|
|
|
|
|
|
void HeartRateController::Update(HeartRateController::States newState, uint8_t heartRate) {
|
|
|
|
this->state = newState;
|
2021-04-18 13:28:14 -04:00
|
|
|
if (this->heartRate != heartRate) {
|
2021-01-17 10:34:14 -05:00
|
|
|
this->heartRate = heartRate;
|
|
|
|
service->OnNewHeartRateValue(heartRate);
|
|
|
|
}
|
2021-01-10 11:57:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void HeartRateController::Start() {
|
2021-04-18 13:28:14 -04:00
|
|
|
if (task != nullptr) {
|
2021-01-17 04:39:46 -05:00
|
|
|
state = States::NotEnoughData;
|
2021-01-10 11:57:26 -05:00
|
|
|
task->PushMessage(Pinetime::Applications::HeartRateTask::Messages::StartMeasurement);
|
2021-01-10 16:02:21 -05:00
|
|
|
}
|
2021-01-10 11:57:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void HeartRateController::Stop() {
|
2021-04-18 13:28:14 -04:00
|
|
|
if (task != nullptr) {
|
2021-01-17 04:39:46 -05:00
|
|
|
state = States::Stopped;
|
2021-01-10 11:57:26 -05:00
|
|
|
task->PushMessage(Pinetime::Applications::HeartRateTask::Messages::StopMeasurement);
|
2021-01-10 16:02:21 -05:00
|
|
|
}
|
2021-01-10 11:57:26 -05:00
|
|
|
}
|
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
void HeartRateController::SetHeartRateTask(Pinetime::Applications::HeartRateTask* task) {
|
2021-01-10 11:57:26 -05:00
|
|
|
this->task = task;
|
|
|
|
}
|
2021-01-10 16:02:21 -05:00
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
void HeartRateController::SetService(Pinetime::Controllers::HeartRateService* service) {
|
2021-01-17 10:34:14 -05:00
|
|
|
this->service = service;
|
|
|
|
}
|