Files
MuditaOS/module-sys/SystemManager/PowerManager.hpp
Adam Dobrowolski 2cee195e09 EGD-3056 subscribtion based execution (on typeid) added and works fine
Till now there was no clear way to register hanlder for message in
Service, with this approach one can register function/lambda handler
for Message which encurages handling messages in functions rather than
in hudge switch cases.
With aproach like this our Messages resembe something between Command
and State pattern. In state pattern `Message` would be `Event` send,
whereas Service would be `Context`.
2020-04-15 16:50:19 +02:00

54 lines
931 B
C++

/*
* @file PowerManager.hpp
* @author Mateusz Piesta (mateusz.piesta@mudita.com)
* @date 12.09.19
* @brief
* @copyright Copyright (C) 2019 mudita.com
* @details
*/
#ifndef PUREPHONE_POWERMANAGER_HPP
#define PUREPHONE_POWERMANAGER_HPP
#include <functional>
#include "bsp/lpm/bsp_lpm.hpp"
namespace sys
{
class PowerManager
{
public:
enum class Mode
{
FullSpeed,
LowPowerRun,
LowPowerIdle,
Suspend
};
PowerManager();
~PowerManager();
int32_t Switch(const Mode mode);
int32_t PowerOff();
int32_t Reboot();
Mode GetCurrentMode()
{
return currentPowerMode;
}
private:
std::unique_ptr<bsp::LowPowerMode> lowPowerControl;
Mode currentPowerMode = Mode ::FullSpeed;
};
} // namespace sys
#endif // PUREPHONE_POWERMANAGER_HPP