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

#include <LockScreenView.h>

Inheritance diagram for cdc::ui::LockScreenView:
cdc::ui::ViewBase cdc::ui::IView

Public Types

using UnlockCallback = void(*)()
using PreRenderCallback = void (*)()

Public Member Functions

void init ()
 Initializes lock-screen state fields to defaults.
void setOnUnlock (UnlockCallback callback)
void setDisplayName (const char *name)
 Sets primary display name shown on lock screen.
void setInfo (const char *info)
 Sets first informational line.
void setInfo2 (const char *info2)
 Sets second informational line.
const char * getDisplayName () const
const char * getInfo () const
const char * getInfo2 () const
void setClock (const char *clock)
 Sets clock text shown in the header.
void setDate (const char *date)
 Sets date text shown below clock.
void setBatteryPercent (uint8_t percent)
 Updates battery percentage indicator.
void setStatusIcons (StatusIcon icons)
 Replaces full status-icon bitmask.
void addStatusIcon (StatusIcon icon)
 Adds one status icon flag.
void removeStatusIcon (StatusIcon icon)
 Removes one status icon flag.
StatusIcon getStatusIcons () const
void render (bool partial) override
 Renders complete lock-screen layout.
InputResult onKey (char key) override
 Handles lock-screen key actions.
void onTick (uint32_t nowMs) override
 Per-tick handler for long-press deep-sleep detection.
void onEnter (void *context) override
 Handles entering lock screen and updates backlight behavior.
void onResume () override
 Handles returning to lock screen and reapplies backlight policy.
const char * getName () const override
const char * getFooterHint () const override
 Returns footer hint based on current lock-screen mode.
bool prefersLightRefresh () const override
void toggleBacklight ()
 Toggles display backlight and corresponding status icon.
void setPreRenderCallback (PreRenderCallback callback)
Public Member Functions inherited from cdc::ui::ViewBase
virtual ~ViewBase ()=default
void onEnter (void *context) override
void onExit () override
void onResume () override
void onPause () override
void setLifecycleHooks (void(*onHide)(void *), void(*onShow)(void *), void *userData) override
bool needsRender () const override
void markDirty () override
void clearDirty () override
void setFooterHint (const char *hint) override
const char * getFooterHint () const override
Public Member Functions inherited from cdc::ui::IView
virtual ~IView ()=default
virtual InputResult onLongPress (char key)

Static Public Attributes

static constexpr uint8_t MAX_TEXT_LEN = 64

Additional Inherited Members

Protected Member Functions inherited from cdc::ui::ViewBase
void setTitle (const char *title)
const char * getTitle () const
Protected Attributes inherited from cdc::ui::ViewBase
bool dirty_ = true
const char * title_ = nullptr
const char * customFooter_ = nullptr
void(* onHide_ )(void *) = nullptr
void(* onShow_ )(void *) = nullptr
void * lifecycleUserData_ = nullptr

Detailed Description

LockScreenView - Main lock screen display

Shows:

  • Clock and date (top)
  • Status icons (top right)
  • Three text lines (center)
  • Battery indicator

Press any key to unlock (triggers callback).

Definition at line 58 of file LockScreenView.h.

Member Typedef Documentation

◆ PreRenderCallback

Callback invoked at the start of every render so the host can sync the lock-screen state (battery percent, charge/USB icons) with current hardware readings. No automatic polling happens outside this hook.

Definition at line 132 of file LockScreenView.h.

◆ UnlockCallback

Unlock callback

Definition at line 65 of file LockScreenView.h.

Member Function Documentation

◆ addStatusIcon()

void cdc::ui::LockScreenView::addStatusIcon ( StatusIcon icon)

Adds one status icon flag.

Parameters
iconIcon bit to set.

Definition at line 173 of file LockScreenView.cpp.

References setStatusIcons().

Referenced by toggleBacklight().

◆ getDisplayName()

const char * cdc::ui::LockScreenView::getDisplayName ( ) const
inline

Definition at line 84 of file LockScreenView.h.

◆ getFooterHint()

const char * cdc::ui::LockScreenView::getFooterHint ( ) const
overridevirtual

Returns footer hint based on current lock-screen mode.

Returns
Localized footer hint string.

Reimplemented from cdc::ui::IView.

Definition at line 456 of file LockScreenView.cpp.

References cdc::ui::tr().

Referenced by render().

◆ getInfo()

const char * cdc::ui::LockScreenView::getInfo ( ) const
inline

Definition at line 85 of file LockScreenView.h.

◆ getInfo2()

const char * cdc::ui::LockScreenView::getInfo2 ( ) const
inline

Definition at line 86 of file LockScreenView.h.

◆ getName()

const char * cdc::ui::LockScreenView::getName ( ) const
inlineoverridevirtual

Get view name for debugging

Implements cdc::ui::IView.

Definition at line 117 of file LockScreenView.h.

◆ getStatusIcons()

StatusIcon cdc::ui::LockScreenView::getStatusIcons ( ) const
inline

Definition at line 109 of file LockScreenView.h.

◆ init()

void cdc::ui::LockScreenView::init ( )

Initializes lock-screen state fields to defaults.

Initialize lock screen

Definition at line 54 of file LockScreenView.cpp.

References cdc::ui::ViewBase::dirty_, and cdc::ui::NONE.

◆ onEnter()

void cdc::ui::LockScreenView::onEnter ( void * context)
overridevirtual

Handles entering lock screen and updates backlight behavior.

Parameters
contextOptional enter context (unused).

Implements cdc::ui::IView.

Definition at line 196 of file LockScreenView.cpp.

References cdc::ui::BACKLIGHT, cdc::ui::ViewBase::dirty_, cdc::ui::display, cdc::hal::getDisplayInstance(), cdc::ui::NONE, and cdc::ui::s_lockScreenInstance.

◆ onKey()

◆ onResume()

void cdc::ui::LockScreenView::onResume ( )
overridevirtual

Handles returning to lock screen and reapplies backlight policy.

Implements cdc::ui::IView.

Definition at line 214 of file LockScreenView.cpp.

References cdc::ui::BACKLIGHT, cdc::ui::ViewBase::dirty_, cdc::ui::display, cdc::hal::getDisplayInstance(), and cdc::ui::NONE.

◆ onTick()

void cdc::ui::LockScreenView::onTick ( uint32_t nowMs)
overridevirtual

Per-tick handler for long-press deep-sleep detection.

Parameters
nowMsCurrent uptime in milliseconds.

Reimplemented from cdc::ui::IView.

Definition at line 399 of file LockScreenView.cpp.

◆ prefersLightRefresh()

bool cdc::ui::LockScreenView::prefersLightRefresh ( ) const
inlineoverridevirtual

Whether this view's partial updates should use RefreshMode::PARTIAL_LIGHT, i.e. never be periodically promoted to a full refresh. Views whose updates are tiny and low-churn (e.g. the lock-screen clock) return true so the panel does not flicker through a forced full refresh while idle. A full refresh still happens on the next view change.

Reimplemented from cdc::ui::IView.

Definition at line 120 of file LockScreenView.h.

◆ removeStatusIcon()

void cdc::ui::LockScreenView::removeStatusIcon ( StatusIcon icon)

Removes one status icon flag.

Parameters
iconIcon bit to clear.

Definition at line 181 of file LockScreenView.cpp.

References setStatusIcons().

Referenced by toggleBacklight().

◆ render()

void cdc::ui::LockScreenView::render ( bool partial)
overridevirtual

◆ setBatteryPercent()

void cdc::ui::LockScreenView::setBatteryPercent ( uint8_t percent)

Updates battery percentage indicator.

Set battery level (0-100)

Parameters
percentBattery percentage (clamped to 0..100).

Definition at line 150 of file LockScreenView.cpp.

References cdc::ui::ViewBase::dirty_.

◆ setClock()

void cdc::ui::LockScreenView::setClock ( const char * clock)

Sets clock text shown in the header.

Set clock display ("HH:MM" or "--:--")

Parameters
clockClock text (nullable).

Definition at line 118 of file LockScreenView.cpp.

References cdc::ui::ViewBase::dirty_.

◆ setDate()

void cdc::ui::LockScreenView::setDate ( const char * date)

Sets date text shown below clock.

Set date display ("DD.MM" or empty)

Parameters
dateDate text (nullable).

Definition at line 134 of file LockScreenView.cpp.

References cdc::ui::ViewBase::dirty_.

◆ setDisplayName()

void cdc::ui::LockScreenView::setDisplayName ( const char * name)

Sets primary display name shown on lock screen.

Set display texts

Parameters
nameName text (nullable).

Definition at line 70 of file LockScreenView.cpp.

References cdc::ui::ViewBase::dirty_, MAX_TEXT_LEN, and name.

◆ setInfo()

void cdc::ui::LockScreenView::setInfo ( const char * info)

Sets first informational line.

Parameters
infoInfo text (nullable).

Definition at line 86 of file LockScreenView.cpp.

References cdc::ui::ViewBase::dirty_, and MAX_TEXT_LEN.

◆ setInfo2()

void cdc::ui::LockScreenView::setInfo2 ( const char * info2)

Sets second informational line.

Parameters
info2Secondary info text (nullable).

Definition at line 102 of file LockScreenView.cpp.

References cdc::ui::ViewBase::dirty_, and MAX_TEXT_LEN.

◆ setOnUnlock()

void cdc::ui::LockScreenView::setOnUnlock ( UnlockCallback callback)
inline

Set unlock callback

Definition at line 75 of file LockScreenView.h.

◆ setPreRenderCallback()

void cdc::ui::LockScreenView::setPreRenderCallback ( PreRenderCallback callback)
inline

Definition at line 133 of file LockScreenView.h.

◆ setStatusIcons()

void cdc::ui::LockScreenView::setStatusIcons ( StatusIcon icons)

Replaces full status-icon bitmask.

Set status icons

Parameters
iconsNew status icon mask.

Definition at line 162 of file LockScreenView.cpp.

References cdc::ui::ViewBase::dirty_.

Referenced by addStatusIcon(), and removeStatusIcon().

◆ toggleBacklight()

void cdc::ui::LockScreenView::toggleBacklight ( )

Toggles display backlight and corresponding status icon.

Toggle backlight from context menu

Definition at line 231 of file LockScreenView.cpp.

References addStatusIcon(), cdc::ui::BACKLIGHT, cdc::ui::ViewBase::dirty_, cdc::ui::display, cdc::hal::getDisplayInstance(), and removeStatusIcon().

Member Data Documentation

◆ MAX_TEXT_LEN

uint8_t cdc::ui::LockScreenView::MAX_TEXT_LEN = 64
staticconstexpr

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