#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 #include #include #include 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 running_{false}; std::atomic entering_soft_off_{false}; TaskHandle_t task_ = nullptr; StaticTask_t task_control_{}; std::array task_stack_{}; }; } // namespace borla