Ersa Wearable Platform
Embedded smartwatch firmware and application framework
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes | List of all members
ersa::app::ApplicationManager Class Reference

#include <application_manager.h>

Collaboration diagram for ersa::app::ApplicationManager:
Collaboration graph
[legend]

Public Member Functions

 ApplicationManager ()
 
bool registerApp (Application *app)
 
bool switchTo (const char *appId)
 
bool switchTo (size_t index)
 
Application * getActiveApp () const
 
size_t getAppCount () const
 
Application * getApp (size_t index) const
 
bool handleEvent (const events::Event &event)
 
void markDirty (bool fullRefresh=false)
 
void clearDirty ()
 
bool isDirty () const
 
bool isFullRefreshNeeded () const
 
bool isAppSwitched () const
 
void clearAppSwitched ()
 
void render (hal::IDisplay &display)
 
void tick ()
 

Static Public Member Functions

static ApplicationManager & instance ()
 

Static Public Attributes

static constexpr size_t MAX_APPS = 16
 

Private Attributes

Application * apps_ [MAX_APPS]
 
size_t appCount_ {0}
 
Application * activeApp_ {nullptr}
 
bool dirty_ {true}
 
bool fullRefreshNeeded_ {true}
 
bool appSwitched_ {true}
 
uint32_t lastRenderTime_ {0}
 

Detailed Description

Owns the fixed-capacity registry and foreground state for firmware apps.

Apps are registered as static C++ objects at startup. The manager does not load binaries or allocate app packages at runtime; a bounded registry keeps memory use predictable on the microcontroller. It centralizes lifecycle and dirty-screen state so individual apps do not manage panel refresh policy.

Constructor & Destructor Documentation

◆ ApplicationManager()

ersa::app::ApplicationManager::ApplicationManager ( )

Construct an empty registry with no active application.

Member Function Documentation

◆ clearAppSwitched()

void ersa::app::ApplicationManager::clearAppSwitched ( )

Clear the app-switch notification after navigation effects are handled.

◆ clearDirty()

void ersa::app::ApplicationManager::clearDirty ( )

Clear pending render flags after the display has been updated.

◆ getActiveApp()

Application * ersa::app::ApplicationManager::getActiveApp ( ) const

Return the foreground app, or null before an app has been selected.

◆ getApp()

Application * ersa::app::ApplicationManager::getApp ( size_t  index) const

Return a non-owning app pointer, or null when the index is out of range.

◆ getAppCount()

size_t ersa::app::ApplicationManager::getAppCount ( ) const

Return the number of successfully registered apps.

◆ handleEvent()

bool ersa::app::ApplicationManager::handleEvent ( const events::Event &  event)

Deliver one event to the foreground app. Inactive screens are excluded so they cannot act on foreground buttons; app adapters request redraws separately through markDirty().

Returns
True when an active app received the event; false when none exists.

◆ instance()

ApplicationManager & ersa::app::ApplicationManager::instance ( )
static

Return the firmware's process-wide application registry.

◆ isAppSwitched()

bool ersa::app::ApplicationManager::isAppSwitched ( ) const

Report whether navigation changed the foreground app since last clear.

◆ isDirty()

bool ersa::app::ApplicationManager::isDirty ( ) const

Report whether a render is pending.

◆ isFullRefreshNeeded()

bool ersa::app::ApplicationManager::isFullRefreshNeeded ( ) const

Report whether the next render must refresh the whole panel.

◆ markDirty()

void ersa::app::ApplicationManager::markDirty ( bool  fullRefresh = false)

Schedule a render; fullRefresh also requests a full panel update.

◆ registerApp()

bool ersa::app::ApplicationManager::registerApp ( Application *  app)

Add an application to the registry without taking ownership. Static registration avoids heap use and makes the maximum application count a fixed memory budget on the wearable target.

Parameters
appNon-owning pointer to a long-lived application instance.
Returns
True if registered; false for null, duplicate, or full registry.

◆ render()

void ersa::app::ApplicationManager::render ( hal::IDisplay &  display)

Render the active app when dirty and clear the handled refresh state. The manager passes full-refresh intent and app bounds to the display contract. DisplayManager still owns physical refresh cadence and panel power policy, which keeps application code independent from panel limits.

◆ switchTo() [1/2]

bool ersa::app::ApplicationManager::switchTo ( const char *  appId)

Navigate by stable app ID. The old and new apps receive lifecycle callbacks, and a full redraw is scheduled because the screen contents have changed completely.

Returns
False when the ID is null or unknown. Selecting the current app succeeds without repeating lifecycle callbacks.

◆ switchTo() [2/2]

bool ersa::app::ApplicationManager::switchTo ( size_t  index)

Navigate by registry/drawer index; invalid indices leave state unchanged. Selecting the already active index succeeds without another transition.

◆ tick()

void ersa::app::ApplicationManager::tick ( )

Run the foreground app's bounded periodic callback.

Member Data Documentation

◆ activeApp_

Application* ersa::app::ApplicationManager::activeApp_ {nullptr}
private

◆ appCount_

size_t ersa::app::ApplicationManager::appCount_ {0}
private

◆ apps_

Application* ersa::app::ApplicationManager::apps_[MAX_APPS]
private

◆ appSwitched_

bool ersa::app::ApplicationManager::appSwitched_ {true}
private

◆ dirty_

bool ersa::app::ApplicationManager::dirty_ {true}
private

◆ fullRefreshNeeded_

bool ersa::app::ApplicationManager::fullRefreshNeeded_ {true}
private

◆ lastRenderTime_

uint32_t ersa::app::ApplicationManager::lastRenderTime_ {0}
private

◆ MAX_APPS

constexpr size_t ersa::app::ApplicationManager::MAX_APPS = 16
staticconstexpr

Maximum number of statically registered apps supported by this build.


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