CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
cdc::ui::SleepManager Class Reference

#include <SleepManager.h>

Public Member Functions

void init (hal::ISleepController *sleep, hal::IPowerManager *power, LockScreenView *lockScreen)
 Initializes sleep-manager dependencies and state.
void checkLockScreenSleep (uint32_t nowMs)
 Evaluates whether lock-screen light sleep should be entered.
void resetTimer (uint32_t nowMs)
 Resets lock-screen sleep timer using explicit timestamp.
void resetTimer ()
 Resets lock-screen sleep timer using current system tick.
bool isInLightSleep () const
bool addSleepInhibitor (const char *reason)
 Sleep inhibitor API implementation.
bool removeSleepInhibitor (const char *reason)
 Removes a sleep inhibitor reason.
bool isSleepInhibited () const
uint8_t getInhibitorCount () const

Static Public Member Functions

static SleepManager & instance ()
 Returns singleton sleep manager instance.

Detailed Description

Definition at line 23 of file SleepManager.h.

Member Function Documentation

◆ addSleepInhibitor()

bool cdc::ui::SleepManager::addSleepInhibitor ( const char * reason)

Sleep inhibitor API implementation.

Add a sleep inhibitor (prevents sleep while active)

Parameters
reasonIdentifier for the inhibitor (e.g., module name)
Returns
true if added, false if already exists or full

Adds a sleep inhibitor reason.

Parameters
reasonInhibitor identifier string.
Returns
true if added, otherwise false.

Definition at line 208 of file SleepManager.cpp.

References LOG_I, LOG_W, cdc::ui::MAX_SLEEP_INHIBITORS, and cdc::ui::TAG.

Referenced by cdc::ui::BlePairingView::onEnter().

◆ checkLockScreenSleep()

void cdc::ui::SleepManager::checkLockScreenSleep ( uint32_t nowMs)

Evaluates whether lock-screen light sleep should be entered.

Parameters
nowMsCurrent monotonic time in milliseconds.
Returns
void

Definition at line 69 of file SleepManager.cpp.

References cdc::ui::ViewStack::instance(), isSleepInhibited(), cdc::ui::LIGHT_SLEEP, cdc::ui::LIGHT_SLEEP_TIMEOUT_MS, and cdc::ui::NONE.

Referenced by cdc::ui::ui_process().

◆ getInhibitorCount()

uint8_t cdc::ui::SleepManager::getInhibitorCount ( ) const
inline

Get count of active inhibitors

Definition at line 66 of file SleepManager.h.

◆ init()

void cdc::ui::SleepManager::init ( hal::ISleepController * sleep,
hal::IPowerManager * power,
LockScreenView * lockScreen )

Initializes sleep-manager dependencies and state.

Parameters
sleepSleep controller dependency.
PowerPower manager dependency.
lockScreenLock-screen view dependency.
Returns
void

Definition at line 39 of file SleepManager.cpp.

Referenced by cdc::ui::ui_init().

◆ instance()

SleepManager & cdc::ui::SleepManager::instance ( )
static

Returns singleton sleep manager instance.

Returns
Reference to global SleepManager instance.

Definition at line 27 of file SleepManager.cpp.

Referenced by host_set_sleep_inhibit(), cdc::ui::BlePairingView::onEnter(), cdc::ui::BlePairingView::onExit(), cdc::ui::ui_init(), and cdc::ui::ui_process().

◆ isInLightSleep()

bool cdc::ui::SleepManager::isInLightSleep ( ) const
inline

Definition at line 40 of file SleepManager.h.

◆ isSleepInhibited()

bool cdc::ui::SleepManager::isSleepInhibited ( ) const
inline

Check if sleep is currently inhibited

Definition at line 61 of file SleepManager.h.

Referenced by checkLockScreenSleep().

◆ removeSleepInhibitor()

bool cdc::ui::SleepManager::removeSleepInhibitor ( const char * reason)

Removes a sleep inhibitor reason.

Remove a sleep inhibitor

Parameters
reasonIdentifier to remove
Returns
true if removed, false if not found
Parameters
reasonInhibitor identifier string.
Returns
true if removed, otherwise false.

Definition at line 238 of file SleepManager.cpp.

References LOG_I, and cdc::ui::TAG.

Referenced by cdc::ui::BlePairingView::onExit().

◆ resetTimer() [1/2]

void cdc::ui::SleepManager::resetTimer ( )

Resets lock-screen sleep timer using current system tick.

Returns
void

Definition at line 60 of file SleepManager.cpp.

◆ resetTimer() [2/2]

void cdc::ui::SleepManager::resetTimer ( uint32_t nowMs)

Resets lock-screen sleep timer using explicit timestamp.

Parameters
nowMsCurrent monotonic time in milliseconds.
Returns
void

Definition at line 52 of file SleepManager.cpp.

Referenced by cdc::ui::ui_process().


The documentation for this class was generated from the following files: