2021-01-10 16:57:26 +00:00
|
|
|
#pragma once
|
|
|
|
#include <FreeRTOS.h>
|
|
|
|
#include <task.h>
|
|
|
|
#include <queue.h>
|
|
|
|
#include <components/heartrate/Ppg.h>
|
|
|
|
|
|
|
|
namespace Pinetime {
|
|
|
|
namespace Drivers {
|
|
|
|
class Hrs3300;
|
|
|
|
}
|
2021-04-18 17:28:14 +00:00
|
|
|
namespace Controllers {
|
2021-01-10 16:57:26 +00:00
|
|
|
class HeartRateController;
|
|
|
|
}
|
|
|
|
namespace Applications {
|
|
|
|
class HeartRateTask {
|
|
|
|
public:
|
2021-04-18 17:28:14 +00:00
|
|
|
enum class Messages : uint8_t { GoToSleep, WakeUp, StartMeasurement, StopMeasurement };
|
|
|
|
enum class States { Idle, Running };
|
2021-01-10 16:57:26 +00:00
|
|
|
|
|
|
|
explicit HeartRateTask(Drivers::Hrs3300& heartRateSensor, Controllers::HeartRateController& controller);
|
|
|
|
void Start();
|
|
|
|
void Work();
|
|
|
|
void PushMessage(Messages msg);
|
|
|
|
|
|
|
|
private:
|
|
|
|
static void Process(void* instance);
|
|
|
|
void StartMeasurement();
|
|
|
|
void StopMeasurement();
|
|
|
|
|
|
|
|
TaskHandle_t taskHandle;
|
|
|
|
QueueHandle_t messageQueue;
|
|
|
|
States state = States::Running;
|
2021-04-18 17:28:14 +00:00
|
|
|
Drivers::Hrs3300& heartRateSensor;
|
2021-01-10 16:57:26 +00:00
|
|
|
Controllers::HeartRateController& controller;
|
|
|
|
Controllers::Ppg ppg;
|
|
|
|
bool measurementStarted = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|