CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
cdc::hal::TCA9535Keypad Class Reference
Inheritance diagram for cdc::hal::TCA9535Keypad:
cdc::hal::IKeypad cdc::core::IService

Public Member Functions

 TCA9535Keypad ()=default
bool init () override
 Initializes keypad hardware, ISR, and worker task.
bool start () override
 Starts keypad service state.
void stop () override
 Stops keypad service state.
core::ServiceState getState () const override
const char * getName () const override
void poll () override
bool isKeyPressed (Key key) const override
 Checks whether specified key is currently pressed.
Key getNextKey () override
 Retrieves next buffered key press.
bool hasKey () const override
 Returns whether key buffer currently contains entries.
bool anyKeyDown () const override
 Returns whether any keypad key is physically held down.
void setCallback (KeyCallback callback) override
void setLongPressEnabled (bool enabled, uint32_t thresholdMs) override
 Enables/disables long-press detection and sets threshold.
void setLongPressCallback (LongPressCallback callback) override
void setPanicChordCallback (PanicChordCallback callback) override
void setDeferShortPress (uint32_t source, bool enabled) override
void setKeyRepeat (uint16_t initial_ms, uint16_t period_ms) override
void prepareForSleep () override
 Prepares keypad interrupt handling for system sleep entry.
void recoverFromSleep () override
 Restores keypad operation after wakeup.
void clearBuffer () override
 Clears pending key buffer.
Public Member Functions inherited from cdc::hal::IKeypad
virtual ~IKeypad ()=default
Public Member Functions inherited from cdc::core::IService
virtual ~IService ()=default

Additional Inherited Members

Public Types inherited from cdc::hal::IKeypad
using LongPressCallback = void(*)(Key key)
using PanicChordCallback = void(*)()
Static Public Attributes inherited from cdc::hal::IKeypad
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

Concrete TCA9535 keypad implementation

Definition at line 131 of file TCA9535Keypad.cpp.

Constructor & Destructor Documentation

◆ TCA9535Keypad()

cdc::hal::TCA9535Keypad::TCA9535Keypad ( )
default

Member Function Documentation

◆ anyKeyDown()

bool cdc::hal::TCA9535Keypad::anyKeyDown ( ) const
overridevirtual

Returns whether any keypad key is physically held down.

Returns
true when any key is pressed.

Implements cdc::hal::IKeypad.

Definition at line 377 of file TCA9535Keypad.cpp.

References cdc::hal::KEY_MASK_ALL, and cdc::hal::KEY_STATE_IDLE.

Referenced by recoverFromSleep().

◆ clearBuffer()

void cdc::hal::TCA9535Keypad::clearBuffer ( )
overridevirtual

Clears pending key buffer.

Implements cdc::hal::IKeypad.

Definition at line 593 of file TCA9535Keypad.cpp.

Referenced by recoverFromSleep().

◆ getName()

const char * cdc::hal::TCA9535Keypad::getName ( ) const
inlineoverridevirtual

Get service name (for logging/debugging)

Implements cdc::core::IService.

Definition at line 140 of file TCA9535Keypad.cpp.

◆ getNextKey()

Key cdc::hal::TCA9535Keypad::getNextKey ( )
overridevirtual

Retrieves next buffered key press.

Returns
Next key or KEY_NONE.

Implements cdc::hal::IKeypad.

Definition at line 358 of file TCA9535Keypad.cpp.

◆ getState()

core::ServiceState cdc::hal::TCA9535Keypad::getState ( ) const
inlineoverridevirtual

Get current service state

Implements cdc::core::IService.

Definition at line 139 of file TCA9535Keypad.cpp.

◆ hasKey()

bool cdc::hal::TCA9535Keypad::hasKey ( ) const
overridevirtual

Returns whether key buffer currently contains entries.

Returns
true when a key is available.

Implements cdc::hal::IKeypad.

Definition at line 366 of file TCA9535Keypad.cpp.

References hasKey().

Referenced by hasKey().

◆ init()

bool cdc::hal::TCA9535Keypad::init ( )
overridevirtual

◆ isKeyPressed()

bool cdc::hal::TCA9535Keypad::isKeyPressed ( Key key) const
overridevirtual

Checks whether specified key is currently pressed.

Parameters
keyKey to test.
Returns
true when key is active.

Implements cdc::hal::IKeypad.

Definition at line 346 of file TCA9535Keypad.cpp.

References cdc::hal::KEY_MASK_ALL, cdc::hal::KEY_STATE_INVALID, and cdc::hal::keyToMask().

◆ poll()

void cdc::hal::TCA9535Keypad::poll ( )
inlineoverridevirtual

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

Implements cdc::hal::IKeypad.

Definition at line 143 of file TCA9535Keypad.cpp.

◆ prepareForSleep()

void cdc::hal::TCA9535Keypad::prepareForSleep ( )
overridevirtual

Prepares keypad interrupt handling for system sleep entry.

Implements cdc::hal::IKeypad.

Definition at line 545 of file TCA9535Keypad.cpp.

References EXP_IRQ_PIN, LOG_D, and TAG.

◆ recoverFromSleep()

void cdc::hal::TCA9535Keypad::recoverFromSleep ( )
overridevirtual

Restores keypad operation after wakeup.

Implements cdc::hal::IKeypad.

Definition at line 558 of file TCA9535Keypad.cpp.

References anyKeyDown(), clearBuffer(), EXP_IRQ_PIN, LOG_D, and TAG.

◆ setCallback()

void cdc::hal::TCA9535Keypad::setCallback ( KeyCallback callback)
inlineoverridevirtual

Set callback for key events

Parameters
callbackFunction to call on key press/release

Implements cdc::hal::IKeypad.

Definition at line 148 of file TCA9535Keypad.cpp.

◆ setDeferShortPress()

void cdc::hal::TCA9535Keypad::setDeferShortPress ( uint32_t source,
bool enabled )
inlineoverridevirtual

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 from cdc::hal::IKeypad.

Definition at line 152 of file TCA9535Keypad.cpp.

◆ setKeyRepeat()

void cdc::hal::TCA9535Keypad::setKeyRepeat ( uint16_t initial_ms,
uint16_t period_ms )
inlineoverridevirtual

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 from cdc::hal::IKeypad.

Definition at line 156 of file TCA9535Keypad.cpp.

◆ setLongPressCallback()

void cdc::hal::TCA9535Keypad::setLongPressCallback ( LongPressCallback callback)
inlineoverridevirtual

Implements cdc::hal::IKeypad.

Definition at line 150 of file TCA9535Keypad.cpp.

◆ setLongPressEnabled()

void cdc::hal::TCA9535Keypad::setLongPressEnabled ( bool enabled,
uint32_t thresholdMs )
overridevirtual

Enables/disables long-press detection and sets threshold.

Parameters
enabledLong-press enable state.
thresholdMsThreshold in milliseconds.

Implements cdc::hal::IKeypad.

Definition at line 388 of file TCA9535Keypad.cpp.

◆ setPanicChordCallback()

void cdc::hal::TCA9535Keypad::setPanicChordCallback ( PanicChordCallback callback)
inlineoverridevirtual

Implements cdc::hal::IKeypad.

Definition at line 151 of file TCA9535Keypad.cpp.

◆ start()

bool cdc::hal::TCA9535Keypad::start ( )
overridevirtual

Starts keypad service state.

Returns
true if service is started after the call.

Implements cdc::core::IService.

Definition at line 309 of file TCA9535Keypad.cpp.

References cdc::core::INITIALIZED, cdc::core::STARTED, and cdc::core::STOPPED.

◆ stop()

void cdc::hal::TCA9535Keypad::stop ( )
overridevirtual

Stops keypad service state.

Implements cdc::core::IService.

Definition at line 321 of file TCA9535Keypad.cpp.

References cdc::core::STARTED, and cdc::core::STOPPED.


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