RSeries astromech firmware
PushButton Class Reference

#include <core/PushButton.h>

+ Inheritance diagram for PushButton:
+ Collaboration diagram for PushButton:

Public Types

typedef void(* CallbackFunction) (void)
 
typedef void(* ParameterizedCallbackFunction) (void *)
 

Public Member Functions

 PushButton (const int pin, const bool activeLow=true, const bool pullupActive=true)
 Initialize the PushButton. More...
 
void setDebounceTicks (const int ticks)
 set # millisec after safe click is assumed. More...
 
void setClickTicks (const int ticks)
 set # millisec after single click is assumed. More...
 
void setPressTicks (const int ticks)
 set # millisec after press is assumed. More...
 
void attachClick (CallbackFunction callback)
 Attach an event to be called when a single click is detected. More...
 
void attachClick (ParameterizedCallbackFunction callback, void *param)
 Attach an event to be called when a single click is detected. More...
 
void attachDoubleClick (CallbackFunction callback)
 Attach an event to be called after a double click is detected. More...
 
void attachDoubleClick (ParameterizedCallbackFunction callback, void *param)
 Attach an event to be called after a double click is detected. More...
 
void attachMultiClick (CallbackFunction callback)
 Attach an event to be called after a multi click is detected. More...
 
void attachMultiClick (ParameterizedCallbackFunction callback, void *param)
 Attach an event to be called after a multi click is detected. More...
 
void attachLongPressStart (CallbackFunction callback)
 Attach an event to fire when the button is pressed and held down. More...
 
void attachLongPressStart (ParameterizedCallbackFunction callback, void *param)
 Attach an event to fire when the button is pressed and held down. More...
 
void attachLongPressStop (CallbackFunction callback)
 Attach an event to fire as soon as the button is released after a long press. More...
 
void attachLongPressStop (ParameterizedCallbackFunction callback, void *param)
 Attach an event to fire as soon as the button is released after a long press. More...
 
void attachDuringLongPress (CallbackFunction callback)
 Attach an event to fire periodically while the button is held down. More...
 
void attachDuringLongPress (ParameterizedCallbackFunction callback, void *param)
 Attach an event to fire periodically while the button is held down. More...
 
virtual void setup () override
 Subclasses must implement this function to perform any necessary setup that cannot happen in the constructor. More...
 
virtual void animate () override
 Call this function every some milliseconds for checking the input level at the initialized digital pin. More...
 
void reset (void)
 Reset the button state machine. More...
 
int getNumberClicks (void) const
 Returns number of clicks in any case: single or multiple clicks. More...
 
bool isIdle () const
 
bool isLongPressed () const
 
- Public Member Functions inherited from SetupEvent
 SetupEvent ()
 Default Constructor. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from SetupEvent
static void ready ()
 Calls setup() for each created AnimatedEvent subclass. More...
 

Member Typedef Documentation

◆ CallbackFunction

typedef void(* PushButton::CallbackFunction) (void)

◆ ParameterizedCallbackFunction

typedef void(* PushButton::ParameterizedCallbackFunction) (void *)

Constructor & Destructor Documentation

◆ PushButton()

PushButton::PushButton ( const int  pin,
const bool  activeLow = true,
const bool  pullupActive = true 
)
inline

Initialize the PushButton.

Parameters
pinThe pin to be used for input from a momentary button.
activeLowSet to true when the input level is LOW when the button is pressed, Default is true.
pullupActiveActivate the internal pullup when available. Default is true.

Member Function Documentation

◆ animate()

virtual void PushButton::animate ( )
inlineoverridevirtual

Call this function every some milliseconds for checking the input level at the initialized digital pin.

Implements AnimatedEvent.

◆ attachClick() [1/2]

void PushButton::attachClick ( CallbackFunction  callback)
inline

Attach an event to be called when a single click is detected.

Parameters
callbackThis function will be called when the event has been detected.

◆ attachClick() [2/2]

void PushButton::attachClick ( ParameterizedCallbackFunction  callback,
void *  param 
)
inline

Attach an event to be called when a single click is detected.

Parameters
callbackThis function will be called when the event has been detected.

◆ attachDoubleClick() [1/2]

void PushButton::attachDoubleClick ( CallbackFunction  callback)
inline

Attach an event to be called after a double click is detected.

Parameters
callbackThis function will be called when the event has been detected.

◆ attachDoubleClick() [2/2]

void PushButton::attachDoubleClick ( ParameterizedCallbackFunction  callback,
void *  param 
)
inline

Attach an event to be called after a double click is detected.

Parameters
callbackThis function will be called when the event has been detected.

◆ attachDuringLongPress() [1/2]

void PushButton::attachDuringLongPress ( CallbackFunction  callback)
inline

Attach an event to fire periodically while the button is held down.

Parameters
callback

◆ attachDuringLongPress() [2/2]

void PushButton::attachDuringLongPress ( ParameterizedCallbackFunction  callback,
void *  param 
)
inline

Attach an event to fire periodically while the button is held down.

Parameters
callback

◆ attachLongPressStart() [1/2]

void PushButton::attachLongPressStart ( CallbackFunction  callback)
inline

Attach an event to fire when the button is pressed and held down.

Parameters
callback

◆ attachLongPressStart() [2/2]

void PushButton::attachLongPressStart ( ParameterizedCallbackFunction  callback,
void *  param 
)
inline

Attach an event to fire when the button is pressed and held down.

Parameters
callback

◆ attachLongPressStop() [1/2]

void PushButton::attachLongPressStop ( CallbackFunction  callback)
inline

Attach an event to fire as soon as the button is released after a long press.

Parameters
callback

◆ attachLongPressStop() [2/2]

void PushButton::attachLongPressStop ( ParameterizedCallbackFunction  callback,
void *  param 
)
inline

Attach an event to fire as soon as the button is released after a long press.

Parameters
callback

◆ attachMultiClick() [1/2]

void PushButton::attachMultiClick ( CallbackFunction  callback)
inline

Attach an event to be called after a multi click is detected.

Parameters
callbackThis function will be called when the event has been detected.

◆ attachMultiClick() [2/2]

void PushButton::attachMultiClick ( ParameterizedCallbackFunction  callback,
void *  param 
)
inline

Attach an event to be called after a multi click is detected.

Parameters
callbackThis function will be called when the event has been detected.

◆ getNumberClicks()

int PushButton::getNumberClicks ( void  ) const
inline

Returns number of clicks in any case: single or multiple clicks.

Returns
number of clicks in any case: single or multiple clicks

◆ isIdle()

bool PushButton::isIdle ( ) const
inline
Returns
true if we are currently handling button press flow (This allows power sensitive applications to know when it is safe to power down the main CPU)

◆ isLongPressed()

bool PushButton::isLongPressed ( ) const
inline
Returns
true when a long press is detected

◆ reset()

void PushButton::reset ( void  )
inline

Reset the button state machine.

◆ setClickTicks()

void PushButton::setClickTicks ( const int  ticks)
inline

set # millisec after single click is assumed.

◆ setDebounceTicks()

void PushButton::setDebounceTicks ( const int  ticks)
inline

set # millisec after safe click is assumed.

◆ setPressTicks()

void PushButton::setPressTicks ( const int  ticks)
inline

set # millisec after press is assumed.

◆ setup()

virtual void PushButton::setup ( )
inlineoverridevirtual

Subclasses must implement this function to perform any necessary setup that cannot happen in the constructor.

Implements SetupEvent.


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