Class eva::Button¶
template <class TReader>
Button with press/release and click detection.More...
#include <evaButton.h>
Inherits the following classes: eva::Switch
Inherited by the following classes: eva::ScrollButton
Public Functions¶
| Type | Name |
|---|---|
| Button * | enable (bool enabled) Enables or disables the button. |
Public Functions inherited from eva::Switch¶
See eva::Switch
| Type | Name |
|---|---|
| Switch (IHandler * listener=nullptr, unsigned char eventMask=0, Args... args) Constructs a Switch . |
|
| Switch * | enable (bool enabled) Enables or disables the switch. |
| signed short | getValue () Gets the current level code. |
| bool | isEnabled () const Checks if the switch is enabled. |
| Switch * | setListener (IHandler * listener, unsigned char eventMask) Sets the event listener for this switch. |
Public Functions inherited from eva::Tickable¶
See eva::Tickable
| Type | Name |
|---|---|
| Tickable () |
|
| Tickable (const Tickable &) = delete |
|
| Tickable (Tickable &&) = delete |
|
| Tickable & | operator= (const Tickable &) = delete |
| Tickable & | operator= (Tickable &&) = delete |
| virtual | ~Tickable () |
Public Static Functions inherited from eva::Tickable¶
See eva::Tickable
| Type | Name |
|---|---|
| void | tac () Triggers tick on this and all linked tickables. |
Protected Attributes¶
| Type | Name |
|---|---|
| unsigned long | pressTime = 0 |
Protected Attributes inherited from eva::Switch¶
See eva::Switch
| Type | Name |
|---|---|
| bool | enabled |
| unsigned char | eventMask |
| unsigned char | levelCode = 0 |
| IHandler * | listener = nullptr |
Protected Functions¶
| Type | Name |
|---|---|
| bool | checkLongPress (unsigned long now) |
| void | handleActivating (unsigned long now) |
| void | handleDeactivating (unsigned char wasLevelCode) |
| void | handleLongPress () |
Protected Functions inherited from eva::Switch¶
See eva::Switch
| Type | Name |
|---|---|
| bool | checkActivating (unsigned char wasLevelCode) inactive or different -> active |
| bool | checkChanging (unsigned char wasLevelCode) |
| bool | checkDeactivating (unsigned char wasLevelCode) active -> inactive or different state |
| void | handleActivating () |
| void | handleChanging () |
| void | handleDeactivating (unsigned char wasLevelCode) |
| void | notify (unsigned short eventType, signed short eventCode) |
| bool | updateState () |
Detailed Description¶
Extends Switch with timing-based events: short click and long click. For basic active/inactive behavior, use Switch directly.
The class works with any reader that returns numeric codes: * 0 means "no button pressed" * Positive values identify specific buttons
Events include both the event type and the button code in argsMask, allowing identification of which specific button triggered the event: in addition to Switch - ON_SHORTCLICK, ON_LONGCLICK, ON_LONGPRESS.
Long click threshold is fixed at 750ms.
Template parameters:
TReaderInput reader type that returns numeric codes (0 = no button, >0 = button identifier)
See also: Switch Base class for active/inactive state management
See also: PinButton Digital pin button with debouncing (typical use)
See also: PullUpButton Pull-up button convenience alias
See also: PinMultiButton Multiple buttons on one ADC pin
Public Functions Documentation¶
function enable¶
Enables or disables the button.
inline Button * eva::Button::enable (
bool enabled
)
Overridden to clear timing state when disabled.
Parameters:
enabledTrue to enable, false to disable
Returns:
Pointer to this for method chaining
Protected Attributes Documentation¶
variable pressTime¶
unsigned long eva::Button< TReader >::pressTime;
Protected Functions Documentation¶
function checkLongPress¶
inline bool eva::Button::checkLongPress (
unsigned long now
)
function handleActivating¶
inline void eva::Button::handleActivating (
unsigned long now
)
function handleDeactivating¶
inline void eva::Button::handleDeactivating (
unsigned char wasLevelCode
)
function handleLongPress¶
inline void eva::Button::handleLongPress ()
The documentation for this class was generated from the following file src/evaButton.h