CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
cdc::hal::ISleepController Class Referenceabstract

#include <ISleepController.h>

Inheritance diagram for cdc::hal::ISleepController:
cdc::core::IService cdc::hal::Esp32SleepController

Public Member Functions

virtual ~ISleepController ()=default
virtual void enterLightSleep ()=0
virtual void enterDeepSleep ()=0
virtual WakeupSource getWakeupSource () const =0
virtual bool wasInDeepSleep () const =0
virtual void clearDeepSleepFlag ()=0
virtual void setLightSleepInterval (uint32_t seconds)=0
virtual uint32_t getLightSleepInterval () const =0
virtual void prepareGpioForSleep ()=0
virtual void stabilizeGpioAfterWakeup ()=0
virtual bool registerPreSleepCallback (const SleepCallbackEntry &entry)=0
virtual bool registerWakeupCallback (const SleepCallbackEntry &entry)=0
virtual void unregisterCallbacks (const char *moduleName)=0
Public Member Functions inherited from cdc::core::IService
virtual ~IService ()=default
virtual bool init ()=0
virtual bool start ()=0
virtual void stop ()=0
virtual ServiceState getState () const =0
virtual const char * getName () const =0

Detailed Description

Sleep Controller Interface

Manages light sleep and deep sleep modes for the ESP32-S3.

Light Sleep: CPU paused, RTC running, fast wake (<10ms), GPIO wakeup Deep Sleep: Full power down, causes reset on wake, survives in RTC memory

Reference: ~/GIT/cdc-badge-os-legacy/main/app_power.cpp

Definition at line 54 of file ISleepController.h.

Constructor & Destructor Documentation

◆ ~ISleepController()

virtual cdc::hal::ISleepController::~ISleepController ( )
virtualdefault

Member Function Documentation

◆ clearDeepSleepFlag()

virtual void cdc::hal::ISleepController::clearDeepSleepFlag ( )
pure virtual

Clear deep sleep flag (call after handling deep sleep wake)

Implemented in cdc::hal::Esp32SleepController.

◆ enterDeepSleep()

virtual void cdc::hal::ISleepController::enterDeepSleep ( )
pure virtual

Enter deep sleep mode

Full power down. Causes RESET on wakeup. Only GPIO wakeup is configured (no timer).

Before calling:

  • Turn off backlight
  • Update display (show sleep icon)
  • Wait for display refresh to complete

This function does NOT return.

Implemented in cdc::hal::Esp32SleepController.

◆ enterLightSleep()

virtual void cdc::hal::ISleepController::enterLightSleep ( )
pure virtual

Enter light sleep mode

CPU is paused, but RTC continues. Wakes on:

  • Timer (configurable interval)
  • GPIO (keypad interrupt)

Returns immediately after wakeup.

Implemented in cdc::hal::Esp32SleepController.

◆ getLightSleepInterval()

virtual uint32_t cdc::hal::ISleepController::getLightSleepInterval ( ) const
pure virtual

Get light sleep timer interval

Implemented in cdc::hal::Esp32SleepController.

◆ getWakeupSource()

virtual WakeupSource cdc::hal::ISleepController::getWakeupSource ( ) const
pure virtual

Get last wakeup source

Implemented in cdc::hal::Esp32SleepController.

◆ prepareGpioForSleep()

virtual void cdc::hal::ISleepController::prepareGpioForSleep ( )
pure virtual

Prepare GPIO for sleep (disable interrupts to avoid conflicts)

Implemented in cdc::hal::Esp32SleepController.

◆ registerPreSleepCallback()

virtual bool cdc::hal::ISleepController::registerPreSleepCallback ( const SleepCallbackEntry & entry)
pure virtual

Register a callback to be called BEFORE entering sleep Use to prepare module state (stop timers, save data, etc.)

Parameters
entryCallback entry with module name and priority
Returns
true if registered successfully

Implemented in cdc::hal::Esp32SleepController.

◆ registerWakeupCallback()

virtual bool cdc::hal::ISleepController::registerWakeupCallback ( const SleepCallbackEntry & entry)
pure virtual

Register a callback to be called AFTER waking from light sleep Use to resume module operations, refresh data, etc. NOTE: Not called after deep sleep (that's a reset)

Parameters
entryCallback entry with module name and priority
Returns
true if registered successfully

Implemented in cdc::hal::Esp32SleepController.

◆ setLightSleepInterval()

virtual void cdc::hal::ISleepController::setLightSleepInterval ( uint32_t seconds)
pure virtual

Set light sleep timer interval in seconds

Parameters
secondsInterval between timer wakeups (0 = no timer wakeup)

Implemented in cdc::hal::Esp32SleepController.

◆ stabilizeGpioAfterWakeup()

virtual void cdc::hal::ISleepController::stabilizeGpioAfterWakeup ( )
pure virtual

Stabilize GPIO after wakeup (restore edge trigger)

Implemented in cdc::hal::Esp32SleepController.

◆ unregisterCallbacks()

virtual void cdc::hal::ISleepController::unregisterCallbacks ( const char * moduleName)
pure virtual

Unregister all callbacks for a module

Parameters
moduleNameModule name used in registration

Implemented in cdc::hal::Esp32SleepController.

◆ wasInDeepSleep()

virtual bool cdc::hal::ISleepController::wasInDeepSleep ( ) const
pure virtual

Check if device just woke from deep sleep (persistent flag in RTC memory)

Implemented in cdc::hal::Esp32SleepController.


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