DEKI/ENGINE docs
Deki 0.19.0
Modular C++ 2D engine for embedded displays and desktop
Loading...
Searching...
No Matches
Deki::IPower Class Referenceabstract

Device power management (sleep and wake). More...

#include <deki/providers/IPower.h>

Classes

struct  SleepInfo

Public Types

enum class  State { Awake , Sleeping }
enum class  SleepMode { Light , Deep }
using SleepCallback = std::function<void(SleepInfo)>

Public Member Functions

virtual ~IPower ()=default
virtual bool Initialize ()=0
virtual void Shutdown ()=0
virtual State GetState () const =0
virtual SleepInfo GetCurrentSleepInfo () const =0
virtual bool SupportsMode (SleepMode mode) const =0
virtual void NotifyActivity ()=0
virtual void SetIdleTimeoutSec (int32_t seconds)=0
virtual void SetIdleSleepMode (SleepMode mode)=0
virtual void RequestSleep (SleepMode mode)=0
virtual void SetWakeGpio (int gpioNum, int level)=0
virtual void RegisterOnScreenOn (SleepCallback cb)=0
virtual void RegisterOnBeforeSleep (SleepCallback cb)=0
virtual void Tick ()=0

Detailed Description

Device power management (sleep and wake).

The engine uses it through the Power facade; the platform package loaded at runtime registers its driver with Power::SetCurrent at init.

Sleep modes are two platform-neutral tiers, Light and Deep, which each implementation maps to native modes: ESP32: Light -> esp_light_sleep, Deep -> esp_deep_sleep nRF52: Light -> System ON idle, Deep -> System OFF

The main loop calls Tick() once per iteration. Tick() either blocks (real light sleep, returning on wake) or, without hardware support, sets the state to Sleeping; the loop checks GetState() after Tick() and skips Update and Render while sleeping.

Boot counts as an OnScreenOn event, so one callback covers every wake including the cold boot.

Member Typedef Documentation

◆ SleepCallback

using Deki::IPower::SleepCallback = std::function<void(SleepInfo)>

Member Enumeration Documentation

◆ State

enum class Deki::IPower::State
strong
Enumerator
Awake 
Sleeping 

◆ SleepMode

enum class Deki::IPower::SleepMode
strong
Enumerator
Light 
Deep 

Constructor & Destructor Documentation

◆ ~IPower()

virtual Deki::IPower::~IPower ( )
virtualdefault

Member Function Documentation

◆ Initialize()

virtual bool Deki::IPower::Initialize ( )
pure virtual

◆ Shutdown()

virtual void Deki::IPower::Shutdown ( )
pure virtual

◆ GetState()

virtual State Deki::IPower::GetState ( ) const
pure virtual

◆ GetCurrentSleepInfo()

virtual SleepInfo Deki::IPower::GetCurrentSleepInfo ( ) const
pure virtual

◆ SupportsMode()

virtual bool Deki::IPower::SupportsMode ( SleepMode mode) const
pure virtual

◆ NotifyActivity()

virtual void Deki::IPower::NotifyActivity ( )
pure virtual

◆ SetIdleTimeoutSec()

virtual void Deki::IPower::SetIdleTimeoutSec ( int32_t seconds)
pure virtual

◆ SetIdleSleepMode()

virtual void Deki::IPower::SetIdleSleepMode ( SleepMode mode)
pure virtual

◆ RequestSleep()

virtual void Deki::IPower::RequestSleep ( SleepMode mode)
pure virtual

◆ SetWakeGpio()

virtual void Deki::IPower::SetWakeGpio ( int gpioNum,
int level )
pure virtual

◆ RegisterOnScreenOn()

virtual void Deki::IPower::RegisterOnScreenOn ( SleepCallback cb)
pure virtual

◆ RegisterOnBeforeSleep()

virtual void Deki::IPower::RegisterOnBeforeSleep ( SleepCallback cb)
pure virtual

◆ Tick()

virtual void Deki::IPower::Tick ( )
pure virtual

The documentation for this class was generated from the following file:
  • deki-engine/include/deki/providers/IPower.h