InfiniTime/src/components/heartrate/HeartRateController.cpp

36 lines
1,001 B
C++
Raw Normal View History

#include "HeartRateController.h"
#include <heartratetask/HeartRateTask.h>
#include <systemtask/SystemTask.h>
using namespace Pinetime::Controllers;
void HeartRateController::Update(HeartRateController::States newState, uint8_t heartRate) {
this->state = newState;
if (this->heartRate != heartRate) {
2021-01-17 10:34:14 -05:00
this->heartRate = heartRate;
service->OnNewHeartRateValue(heartRate);
}
}
void HeartRateController::Start() {
if (task != nullptr) {
state = States::NotEnoughData;
task->PushMessage(Pinetime::Applications::HeartRateTask::Messages::StartMeasurement);
}
}
void HeartRateController::Stop() {
if (task != nullptr) {
state = States::Stopped;
task->PushMessage(Pinetime::Applications::HeartRateTask::Messages::StopMeasurement);
}
}
void HeartRateController::SetHeartRateTask(Pinetime::Applications::HeartRateTask* task) {
this->task = task;
}
void HeartRateController::SetService(Pinetime::Controllers::HeartRateService* service) {
2021-01-17 10:34:14 -05:00
this->service = service;
}