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

#include <IKeypad.h>

Inheritance diagram for cdc::hal::IKeypad:
cdc::core::IService cdc::hal::TCA9535Keypad

Public Types

using LongPressCallback = void(*)(Key key)
using PanicChordCallback = void(*)()

Public Member Functions

virtual ~IKeypad ()=default
virtual void poll ()=0
virtual bool isKeyPressed (Key key) const =0
virtual Key getNextKey ()=0
virtual bool hasKey () const =0
virtual bool anyKeyDown () const =0
virtual void setCallback (KeyCallback callback)=0
virtual void setLongPressEnabled (bool enabled, uint32_t thresholdMs=800)=0
virtual void setLongPressCallback (LongPressCallback callback)=0
virtual void setPanicChordCallback (PanicChordCallback callback)=0
virtual void setDeferShortPress (uint32_t source, bool enabled)
virtual void setKeyRepeat (uint16_t initial_ms, uint16_t period_ms)
virtual void prepareForSleep ()=0
virtual void recoverFromSleep ()=0
virtual void clearBuffer ()=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

Static Public Attributes

static constexpr uint32_t DEFER_SRC_VIEW = 1u << 0
 active view (e.g. canvas long-press)
static constexpr uint32_t DEFER_SRC_EVENT = 1u << 1
 plugin KEY_LONG_PRESS subscription

Detailed Description

Keypad interface for button input

Definition at line 32 of file IKeypad.h.

Member Typedef Documentation

◆ LongPressCallback

Set callback for long-press events

Definition at line 79 of file IKeypad.h.

◆ PanicChordCallback

Set callback for the reserved rescue chord (N + Y held together). Fired once per chord hold; used for the anti-block instant lock.

Definition at line 86 of file IKeypad.h.

Constructor & Destructor Documentation

◆ ~IKeypad()

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

Member Function Documentation

◆ anyKeyDown()

virtual bool cdc::hal::IKeypad::anyKeyDown ( ) const
pure virtual

Check if any key is currently pressed

Implemented in cdc::hal::TCA9535Keypad.

◆ clearBuffer()

virtual void cdc::hal::IKeypad::clearBuffer ( )
pure virtual

Clear key buffer (consume all pending keys)

Implemented in cdc::hal::TCA9535Keypad.

◆ getNextKey()

virtual Key cdc::hal::IKeypad::getNextKey ( )
pure virtual

Get next key from buffer (consumes the key)

Returns
Key code or KEY_NONE if buffer empty

Implemented in cdc::hal::TCA9535Keypad.

◆ hasKey()

virtual bool cdc::hal::IKeypad::hasKey ( ) const
pure virtual

Check if there are keys in the buffer

Implemented in cdc::hal::TCA9535Keypad.

◆ isKeyPressed()

virtual bool cdc::hal::IKeypad::isKeyPressed ( Key key) const
pure virtual

Check if a specific key is currently pressed

Implemented in cdc::hal::TCA9535Keypad.

◆ poll()

virtual void cdc::hal::IKeypad::poll ( )
pure virtual

Poll for key state changes Should be called periodically from main loop

Implemented in cdc::hal::TCA9535Keypad.

◆ prepareForSleep()

virtual void cdc::hal::IKeypad::prepareForSleep ( )
pure virtual

Prepare keypad for sleep mode Disables ISR and interrupt to prevent spurious wakeups

Implemented in cdc::hal::TCA9535Keypad.

◆ recoverFromSleep()

virtual void cdc::hal::IKeypad::recoverFromSleep ( )
pure virtual

Recover keypad after sleep wakeup Waits for keys to be released, clears buffer, re-enables ISR

Implemented in cdc::hal::TCA9535Keypad.

◆ setCallback()

virtual void cdc::hal::IKeypad::setCallback ( KeyCallback callback)
pure virtual

Set callback for key events

Parameters
callbackFunction to call on key press/release

Implemented in cdc::hal::TCA9535Keypad.

◆ setDeferShortPress()

virtual void cdc::hal::IKeypad::setDeferShortPress ( uint32_t source,
bool enabled )
inlinevirtual

Defer the short-press event until key release and suppress it when a long-press already fired. When no source requests it (default) the short press is emitted on key-down. Each source is tracked independently and OR-combined, so a view and an event subscription cannot clobber each other.

Parameters
sourceOne of the DEFER_SRC_* bits identifying the requester.
enabledWhether that source requests deferred short-press.

Reimplemented in cdc::hal::TCA9535Keypad.

Definition at line 102 of file IKeypad.h.

◆ setKeyRepeat()

virtual void cdc::hal::IKeypad::setKeyRepeat ( uint16_t initial_ms,
uint16_t period_ms )
inlinevirtual

Re-emit a held key on a repeat schedule, for every view. While a single key is held, the key is re-buffered every period_ms after an initial delay. Mutually exclusive with long-press: a non-zero period suppresses the long-press for held keys. Pass 0/0 to disable (default).

Parameters
initial_msDelay before the first repeat.
period_msInterval between subsequent repeats; 0 disables.

Reimplemented in cdc::hal::TCA9535Keypad.

Definition at line 115 of file IKeypad.h.

◆ setLongPressCallback()

virtual void cdc::hal::IKeypad::setLongPressCallback ( LongPressCallback callback)
pure virtual

Implemented in cdc::hal::TCA9535Keypad.

◆ setLongPressEnabled()

virtual void cdc::hal::IKeypad::setLongPressEnabled ( bool enabled,
uint32_t thresholdMs = 800 )
pure virtual

Enable/disable long-press detection

Parameters
enabledEnable long-press
thresholdMsTime in ms to trigger long-press

Implemented in cdc::hal::TCA9535Keypad.

◆ setPanicChordCallback()

virtual void cdc::hal::IKeypad::setPanicChordCallback ( PanicChordCallback callback)
pure virtual

Implemented in cdc::hal::TCA9535Keypad.

Member Data Documentation

◆ DEFER_SRC_EVENT

uint32_t cdc::hal::IKeypad::DEFER_SRC_EVENT = 1u << 1
staticconstexpr

plugin KEY_LONG_PRESS subscription

Definition at line 91 of file IKeypad.h.

◆ DEFER_SRC_VIEW

uint32_t cdc::hal::IKeypad::DEFER_SRC_VIEW = 1u << 0
staticconstexpr

active view (e.g. canvas long-press)

Independent requesters of deferred short-press mode (OR-combined).

Definition at line 90 of file IKeypad.h.

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


The documentation for this class was generated from the following file:
  • components/cdc_hal/include/cdc_hal/IKeypad.h