MyButton Library
Loading...
Searching...
No Matches
MyButton Class Reference

Public Types

enum  Action { NO_PRESS = 0 , CLICK , DOUBLE_CLICK , LONG_PRESS }
 

Public Member Functions

void ARDUINO_ISR_ATTR buttonISR ()
 This function is only internally invoked.
 
 MyButton (int pin)
 Construct a new My Button object from pin. No interrupt is attached by default. If you want to use interrupt, call MyButton::useInterrupt()
 
bool useInterrupt ()
 Attempt to set an interrupt to use with the MyButton object.
 
bool usingInterrupt () const
 Check whether the MyButton object is configured to accept interrupts.
 
Action check ()
 This method must be called as often as possible in the loop() function.
 
bool on (Action action, ButtonPressCallback cb)
 Sets a callback/lambda for button gesture (Action)
 

Constructor & Destructor Documentation

◆ MyButton()

MyButton::MyButton ( int pin)

Construct a new My Button object from pin. No interrupt is attached by default. If you want to use interrupt, call MyButton::useInterrupt()

Parameters
pin

Member Function Documentation

◆ check()

MyButton::Action MyButton::check ( )

This method must be called as often as possible in the loop() function.

Returns
Action

◆ on()

bool MyButton::on ( MyButton::Action action,
ButtonPressCallback cb )

Sets a callback/lambda for button gesture (Action)

Parameters
action
cb
Returns
true on success

◆ useInterrupt()

bool MyButton::useInterrupt ( )

Attempt to set an interrupt to use with the MyButton object.

Returns
true on success

◆ usingInterrupt()

bool MyButton::usingInterrupt ( ) const

Check whether the MyButton object is configured to accept interrupts.

Returns
true
false

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