|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
#include <LockScreenView.h>
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 |
LockScreenView - Main lock screen display
Shows:
Press any key to unlock (triggers callback).
Definition at line 58 of file LockScreenView.h.
| using cdc::ui::LockScreenView::PreRenderCallback = void (*)() |
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.
| using cdc::ui::LockScreenView::UnlockCallback = void(*)() |
Unlock callback
Definition at line 65 of file LockScreenView.h.
| void cdc::ui::LockScreenView::addStatusIcon | ( | StatusIcon | icon | ) |
Adds one status icon flag.
| icon | Icon bit to set. |
Definition at line 173 of file LockScreenView.cpp.
References setStatusIcons().
Referenced by toggleBacklight().
|
inline |
Definition at line 84 of file LockScreenView.h.
|
overridevirtual |
Returns footer hint based on current lock-screen mode.
Reimplemented from cdc::ui::IView.
Definition at line 456 of file LockScreenView.cpp.
References cdc::ui::tr().
Referenced by render().
|
inline |
Definition at line 85 of file LockScreenView.h.
|
inline |
Definition at line 86 of file LockScreenView.h.
|
inlineoverridevirtual |
Get view name for debugging
Implements cdc::ui::IView.
Definition at line 117 of file LockScreenView.h.
|
inline |
Definition at line 109 of file LockScreenView.h.
| 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.
|
overridevirtual |
Handles entering lock screen and updates backlight behavior.
| context | Optional 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.
|
overridevirtual |
Handles lock-screen key actions.
Key 3 opens the context menu; any other key triggers unlock callback.
| key | Pressed key code. |
Implements cdc::ui::IView.
Definition at line 354 of file LockScreenView.cpp.
References cdc::ui::CONSUMED, cdc::plugin_manager::PluginManager::getLockscreenItems(), cdc::core::ModuleRegistry::instance(), cdc::plugin_manager::PluginManager::instance(), cdc::ui::WifiHandlers::instance(), cdc::ui::WifiHandlers::isConnected(), cdc::ui::KEY_MENU, cdc::ui::MAX_CONTEXT_ITEMS, cdc::ui::MAX_MODULE_CONTEXT_ITEMS, cdc::ui::MAX_PLUGIN_ITEMS, cdc::ui::onLightMenuCallback(), cdc::ui::onWifiToggleCallback(), cdc::ui::s_contextItems, cdc::ui::s_moduleCallbacks, cdc::ui::s_moduleContextCount, cdc::ui::s_moduleContextItems, cdc::ui::s_pluginCallbacks, cdc::ui::s_pluginContextCount, cdc::ui::s_pluginContextItems, cdc::ui::showContextMenu(), and cdc::ui::tr().
|
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.
|
overridevirtual |
Per-tick handler for long-press deep-sleep detection.
| nowMs | Current uptime in milliseconds. |
Reimplemented from cdc::ui::IView.
Definition at line 399 of file LockScreenView.cpp.
|
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.
| void cdc::ui::LockScreenView::removeStatusIcon | ( | StatusIcon | icon | ) |
Removes one status icon flag.
| icon | Icon bit to clear. |
Definition at line 181 of file LockScreenView.cpp.
References setStatusIcons().
Referenced by toggleBacklight().
|
overridevirtual |
Renders complete lock-screen layout.
| partial | true for partial redraw, false for full redraw. |
Implements cdc::ui::IView.
Definition at line 659 of file LockScreenView.cpp.
References BATTERY_X, BATTERY_Y, cdc::ui::Bold12pt, cdc::ui::Bold9pt, cdc::ui::Builtin, CLOCK_Y, DATE_Y, cdc::ui::ViewBase::dirty_, cdc::ui::display, DISPLAY_WIDTH, cdc::ui::render::drawText(), cdc::hal::getDisplayInstance(), getFooterHint(), cdc::ui::getGfxFont(), ICONS_Y, INFO2_Y, INFO_Y, cdc::ui::render::measureText(), NAME_Y, cdc::ui::render::pickFontThatFits(), and cdc::ui::render::printText().
| void cdc::ui::LockScreenView::setBatteryPercent | ( | uint8_t | percent | ) |
Updates battery percentage indicator.
Set battery level (0-100)
| percent | Battery percentage (clamped to 0..100). |
Definition at line 150 of file LockScreenView.cpp.
References cdc::ui::ViewBase::dirty_.
| void cdc::ui::LockScreenView::setClock | ( | const char * | clock | ) |
Sets clock text shown in the header.
Set clock display ("HH:MM" or "--:--")
| clock | Clock text (nullable). |
Definition at line 118 of file LockScreenView.cpp.
References cdc::ui::ViewBase::dirty_.
| void cdc::ui::LockScreenView::setDate | ( | const char * | date | ) |
Sets date text shown below clock.
Set date display ("DD.MM" or empty)
| date | Date text (nullable). |
Definition at line 134 of file LockScreenView.cpp.
References cdc::ui::ViewBase::dirty_.
| void cdc::ui::LockScreenView::setDisplayName | ( | const char * | name | ) |
Sets primary display name shown on lock screen.
Set display texts
| name | Name text (nullable). |
Definition at line 70 of file LockScreenView.cpp.
References cdc::ui::ViewBase::dirty_, MAX_TEXT_LEN, and name.
| void cdc::ui::LockScreenView::setInfo | ( | const char * | info | ) |
Sets first informational line.
| info | Info text (nullable). |
Definition at line 86 of file LockScreenView.cpp.
References cdc::ui::ViewBase::dirty_, and MAX_TEXT_LEN.
| void cdc::ui::LockScreenView::setInfo2 | ( | const char * | info2 | ) |
Sets second informational line.
| info2 | Secondary info text (nullable). |
Definition at line 102 of file LockScreenView.cpp.
References cdc::ui::ViewBase::dirty_, and MAX_TEXT_LEN.
|
inline |
Set unlock callback
Definition at line 75 of file LockScreenView.h.
|
inline |
Definition at line 133 of file LockScreenView.h.
| void cdc::ui::LockScreenView::setStatusIcons | ( | StatusIcon | icons | ) |
Replaces full status-icon bitmask.
Set status icons
| icons | New status icon mask. |
Definition at line 162 of file LockScreenView.cpp.
References cdc::ui::ViewBase::dirty_.
Referenced by addStatusIcon(), and removeStatusIcon().
| 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().
|
staticconstexpr |
Definition at line 60 of file LockScreenView.h.
Referenced by cdc::os_ui::SystemSettingsBackup::exportSystemSettings(), setDisplayName(), setInfo(), setInfo2(), and cdc::ui::settings::showBadgeTextStep().