mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-12-24 02:02:22 +03:00
HR Sensor : do not go to sleep when the HR app is running.
This commit is contained in:
parent
1a582815ba
commit
c82c22650c
@ -1,23 +1,34 @@
|
||||
#include "HeartRateController.h"
|
||||
#include <heartratetask/HeartRateTask.h>
|
||||
#include <systemtask/SystemTask.h>
|
||||
|
||||
using namespace Pinetime::Controllers;
|
||||
|
||||
HeartRateController::HeartRateController(Pinetime::System::SystemTask &systemTask) : systemTask{systemTask} {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void HeartRateController::Update(HeartRateController::States newState, uint8_t heartRate) {
|
||||
this->state = newState;
|
||||
this->heartRate = heartRate;
|
||||
}
|
||||
|
||||
void HeartRateController::Start() {
|
||||
if(task != nullptr)
|
||||
if(task != nullptr) {
|
||||
task->PushMessage(Pinetime::Applications::HeartRateTask::Messages::StartMeasurement);
|
||||
systemTask.PushMessage(System::SystemTask::Messages::HeartRateRunning);
|
||||
}
|
||||
}
|
||||
|
||||
void HeartRateController::Stop() {
|
||||
if(task != nullptr)
|
||||
if(task != nullptr) {
|
||||
task->PushMessage(Pinetime::Applications::HeartRateTask::Messages::StopMeasurement);
|
||||
systemTask.PushMessage(System::SystemTask::Messages::HeartRateStopped);
|
||||
}
|
||||
}
|
||||
|
||||
void HeartRateController::SetHeartRateTask(Pinetime::Applications::HeartRateTask *task) {
|
||||
this->task = task;
|
||||
}
|
||||
|
||||
|
@ -6,11 +6,16 @@ namespace Pinetime {
|
||||
namespace Applications {
|
||||
class HeartRateTask;
|
||||
}
|
||||
namespace System {
|
||||
class SystemTask;
|
||||
}
|
||||
namespace Controllers {
|
||||
class HeartRateController {
|
||||
public:
|
||||
enum class States { NotEnoughData, NoTouch, Running};
|
||||
|
||||
explicit HeartRateController(System::SystemTask& systemTask);
|
||||
|
||||
void Start();
|
||||
void Stop();
|
||||
void Update(States newState, uint8_t heartRate);
|
||||
@ -20,6 +25,7 @@ namespace Pinetime {
|
||||
uint8_t HeartRate() const { return heartRate; }
|
||||
|
||||
private:
|
||||
System::SystemTask& systemTask;
|
||||
Applications::HeartRateTask* task = nullptr;
|
||||
States state = States::NotEnoughData;
|
||||
uint8_t heartRate = 0;
|
||||
|
@ -44,6 +44,7 @@ SystemTask::SystemTask(Drivers::SpiMaster &spi, Drivers::St7789 &lcd,
|
||||
Pinetime::Drivers::Hrs3300& heartRateSensor) :
|
||||
spi{spi}, lcd{lcd}, spiNorFlash{spiNorFlash},
|
||||
twiMaster{twiMaster}, touchPanel{touchPanel}, lvgl{lvgl}, batteryController{batteryController},
|
||||
heartRateController{*this},
|
||||
bleController{bleController}, dateTimeController{dateTimeController},
|
||||
watchdog{}, watchdogView{watchdog}, notificationManager{notificationManager},
|
||||
nimbleController(*this, bleController,dateTimeController, notificationManager, batteryController, spiNorFlash),
|
||||
@ -194,6 +195,12 @@ void SystemTask::Work() {
|
||||
isSleeping = true;
|
||||
isGoingToSleep = false;
|
||||
break;
|
||||
case Messages::HeartRateRunning:
|
||||
doNotGoToSleep = true;
|
||||
break;
|
||||
case Messages::HeartRateStopped:
|
||||
doNotGoToSleep = false;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,8 @@ namespace Pinetime {
|
||||
class SystemTask {
|
||||
public:
|
||||
enum class Messages {GoToSleep, GoToRunning, OnNewTime, OnNewNotification, BleConnected,
|
||||
BleFirmwareUpdateStarted, BleFirmwareUpdateFinished, OnTouchEvent, OnButtonEvent, OnDisplayTaskSleeping
|
||||
BleFirmwareUpdateStarted, BleFirmwareUpdateFinished, OnTouchEvent, OnButtonEvent, OnDisplayTaskSleeping,
|
||||
HeartRateRunning, HeartRateStopped
|
||||
};
|
||||
|
||||
SystemTask(Drivers::SpiMaster &spi, Drivers::St7789 &lcd,
|
||||
|
Loading…
Reference in New Issue
Block a user