2021-01-10 11:57:26 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
2021-01-17 10:34:14 -05:00
|
|
|
#include <components/ble/HeartRateService.h>
|
2021-01-10 11:57:26 -05:00
|
|
|
|
|
|
|
namespace Pinetime {
|
|
|
|
namespace Applications {
|
|
|
|
class HeartRateTask;
|
|
|
|
}
|
2023-01-07 15:23:15 -05:00
|
|
|
|
2021-01-10 16:02:21 -05:00
|
|
|
namespace System {
|
|
|
|
class SystemTask;
|
|
|
|
}
|
2023-01-07 15:23:15 -05:00
|
|
|
|
2021-01-10 11:57:26 -05:00
|
|
|
namespace Controllers {
|
|
|
|
class HeartRateController {
|
2021-04-24 05:00:45 -04:00
|
|
|
public:
|
2021-04-18 13:28:14 -04:00
|
|
|
enum class States { Stopped, NotEnoughData, NoTouch, Running };
|
2021-01-10 11:57:26 -05:00
|
|
|
|
2021-06-06 09:56:03 -04:00
|
|
|
HeartRateController() = default;
|
2021-01-10 11:57:26 -05:00
|
|
|
void Start();
|
|
|
|
void Stop();
|
|
|
|
void Update(States newState, uint8_t heartRate);
|
|
|
|
|
|
|
|
void SetHeartRateTask(Applications::HeartRateTask* task);
|
2023-01-07 15:23:15 -05:00
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
States State() const {
|
|
|
|
return state;
|
|
|
|
}
|
2023-01-07 15:23:15 -05:00
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
uint8_t HeartRate() const {
|
|
|
|
return heartRate;
|
|
|
|
}
|
2021-01-10 11:57:26 -05:00
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
void SetService(Pinetime::Controllers::HeartRateService* service);
|
2021-01-17 10:34:14 -05:00
|
|
|
|
2021-04-24 05:00:45 -04:00
|
|
|
private:
|
2021-01-10 11:57:26 -05:00
|
|
|
Applications::HeartRateTask* task = nullptr;
|
2021-01-17 04:39:46 -05:00
|
|
|
States state = States::Stopped;
|
2021-01-10 11:57:26 -05:00
|
|
|
uint8_t heartRate = 0;
|
2021-01-17 10:34:14 -05:00
|
|
|
Pinetime::Controllers::HeartRateService* service = nullptr;
|
2021-01-10 11:57:26 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|