// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once #include #include "BatteryBrownoutDetector.hpp" #include "BatteryState.hpp" #include #include #include namespace sevm::battery { /// Battery controller class that glues various submodules together. It does not perform any logic by itself but /// just routes notifications and messages received from corresponding submodules. class BatteryController { public: using Events = hal::battery::AbstractBatteryCharger::Events; using ChargerPresence = hal::battery::AbstractBatteryCharger::ChargerPresence; explicit BatteryController(sys::Service *service, xQueueHandle notificationChannel); void poll(); /// Handler for incoming async notifications from the back-end void handleNotification(Events); private: void update(); void updateSoC(); void printCurrentState(); void checkChargerPresence(); sys::Service *service{nullptr}; std::unique_ptr charger; BatteryBrownoutDetector brownoutDetector; BatteryState batteryState; ChargerPresence chargerPresence{ChargerPresence::Undefined}; }; }; // namespace sevm::battery