|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
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 | |
Concrete TCA9535 keypad implementation
Definition at line 131 of file TCA9535Keypad.cpp.
|
default |
|
overridevirtual |
Returns whether any keypad key is physically held down.
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().
|
overridevirtual |
Clears pending key buffer.
Implements cdc::hal::IKeypad.
Definition at line 593 of file TCA9535Keypad.cpp.
Referenced by recoverFromSleep().
|
inlineoverridevirtual |
Get service name (for logging/debugging)
Implements cdc::core::IService.
Definition at line 140 of file TCA9535Keypad.cpp.
|
overridevirtual |
Retrieves next buffered key press.
Implements cdc::hal::IKeypad.
Definition at line 358 of file TCA9535Keypad.cpp.
|
inlineoverridevirtual |
Get current service state
Implements cdc::core::IService.
Definition at line 139 of file TCA9535Keypad.cpp.
|
overridevirtual |
Returns whether key buffer currently contains entries.
Implements cdc::hal::IKeypad.
Definition at line 366 of file TCA9535Keypad.cpp.
References hasKey().
Referenced by hasKey().
|
overridevirtual |
Initializes keypad hardware, ISR, and worker task.
Implements cdc::core::IService.
Definition at line 215 of file TCA9535Keypad.cpp.
References cdc::core::ERROR, EXP_IRQ_PIN, EXPANDER_ADDR, cdc::hal::getI2cBus0(), cdc::core::INITIALIZED, LOG_E, LOG_I, cdc::hal::REG_CONFIG_0, cdc::hal::REG_CONFIG_1, cdc::hal::REG_OUTPUT_0, cdc::hal::REG_OUTPUT_1, cdc::hal::REG_POLARITY_0, cdc::hal::REG_POLARITY_1, cdc::core::STARTED, TAG, cdc::hal::TASK_PRIORITY, cdc::hal::TASK_STACK_SIZE, and cdc::core::UNINITIALIZED.
|
overridevirtual |
Checks whether specified key is currently pressed.
| key | Key to test. |
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().
|
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.
|
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.
|
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.
|
inlineoverridevirtual |
Set callback for key events
| callback | Function to call on key press/release |
Implements cdc::hal::IKeypad.
Definition at line 148 of file TCA9535Keypad.cpp.
|
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.
| source | One of the DEFER_SRC_* bits identifying the requester. |
| enabled | Whether that source requests deferred short-press. |
Reimplemented from cdc::hal::IKeypad.
Definition at line 152 of file TCA9535Keypad.cpp.
|
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).
| initial_ms | Delay before the first repeat. |
| period_ms | Interval between subsequent repeats; 0 disables. |
Reimplemented from cdc::hal::IKeypad.
Definition at line 156 of file TCA9535Keypad.cpp.
|
inlineoverridevirtual |
Implements cdc::hal::IKeypad.
Definition at line 150 of file TCA9535Keypad.cpp.
|
overridevirtual |
Enables/disables long-press detection and sets threshold.
| enabled | Long-press enable state. |
| thresholdMs | Threshold in milliseconds. |
Implements cdc::hal::IKeypad.
Definition at line 388 of file TCA9535Keypad.cpp.
|
inlineoverridevirtual |
Implements cdc::hal::IKeypad.
Definition at line 151 of file TCA9535Keypad.cpp.
|
overridevirtual |
Starts keypad service state.
Implements cdc::core::IService.
Definition at line 309 of file TCA9535Keypad.cpp.
References cdc::core::INITIALIZED, cdc::core::STARTED, and cdc::core::STOPPED.
|
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.