bolar_2 backup
This commit is contained in:
57
main/power/power_service.h
Normal file
57
main/power/power_service.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
#include "ports/battery_status_provider.h"
|
||||
#include "ports/device_platform.h"
|
||||
#include "ports/event_publisher.h"
|
||||
#include "ports/power_service.h"
|
||||
#include "schedule/alarm_service.h"
|
||||
#include "schedule/reminder_service.h"
|
||||
#include "sensor/sensor_service.h"
|
||||
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/task.h>
|
||||
|
||||
namespace borla {
|
||||
|
||||
class PowerService final : public IPowerService {
|
||||
public:
|
||||
PowerService(
|
||||
IBatteryStatusProvider& battery,
|
||||
SensorService& sensors,
|
||||
AlarmService& alarms,
|
||||
ReminderService& reminders,
|
||||
IDevicePlatform& platform)
|
||||
: battery_(battery),
|
||||
sensors_(sensors),
|
||||
alarms_(alarms),
|
||||
reminders_(reminders),
|
||||
platform_(platform)
|
||||
{
|
||||
}
|
||||
|
||||
bool Initialize(IEventPublisher& publisher);
|
||||
void Stop();
|
||||
void EnterSoftOff() override;
|
||||
|
||||
private:
|
||||
static constexpr uint32_t kTaskStackDepth = 2048;
|
||||
static void TaskEntry(void* context);
|
||||
void Run();
|
||||
|
||||
IBatteryStatusProvider& battery_;
|
||||
SensorService& sensors_;
|
||||
AlarmService& alarms_;
|
||||
ReminderService& reminders_;
|
||||
IDevicePlatform& platform_;
|
||||
IEventPublisher* publisher_ = nullptr;
|
||||
std::atomic<bool> running_{false};
|
||||
std::atomic<bool> entering_soft_off_{false};
|
||||
TaskHandle_t task_ = nullptr;
|
||||
StaticTask_t task_control_{};
|
||||
std::array<StackType_t, kTaskStackDepth> task_stack_{};
|
||||
};
|
||||
|
||||
} // namespace borla
|
||||
Reference in New Issue
Block a user