AbleButtons V0.2.0
Lightweight button library for Arduino.
 
Loading...
Searching...
No Matches
able::ButtonList< Button > Class Template Reference

Template for a list of buttons of the same type. More...

#include <ButtonList.h>

Public Member Functions

template<size_t n>
 ButtonList (Button *(&buttons)[n])
 Create a list of buttons. More...
 
 ButtonList (Button **buttons, size_t len)
 Create a list of buttons. More...
 
void begin ()
 Initialise all the buttons. More...
 
void handle ()
 Handle all the buttons. More...
 
bool resetClicked ()
 Reset clicked state of all buttons, returning true if any were clicked. More...
 
bool resetDoubleClicked ()
 Reset double-clicked state of all buttons, returning true if any were double-clicked. More...
 
Buttonbutton (uint8_t id) const
 For CallbackButtons (which each have an id), return a pointer to the first button matching the id (or a null pointer if the id is not found). More...
 
bool allPressed () const
 Determine if all of the buttons are currently pressed. More...
 
bool anyPressed () const
 Determine if any of the buttons are currently pressed. More...
 
bool allHeld () const
 Determine if all of the buttons are currently held. More...
 
bool anyHeld () const
 Determine if any of the buttons are currently held. More...
 
bool allIdle () const
 Determine if all of the buttons are currently idle. More...
 
bool anyIdle () const
 Determine if any of the buttons are currently idle. More...
 
bool allClicked () const
 Determine if all of the buttons have been clicked. More...
 
bool anyClicked () const
 Determine if all of the buttons have been clicked. More...
 
bool allDoubleClicked () const
 Determine if all of the buttons have been double-clicked. More...
 
bool anyDoubleClicked () const
 Determine if any of the buttons have been double-clicked. More...
 

Detailed Description

template<typename Button>
class able::ButtonList< Button >

Template for a list of buttons of the same type.

Allows a set of buttons to be controlled together. NB: You cannot mix different button types in the same button list. Use separate lists to manage collections of pulldown, and pull-up resistors, buttons and clickers) s in the same list (use separate lists).

Definition at line 20 of file ButtonList.h.

Constructor & Destructor Documentation

◆ ButtonList() [1/2]

template<typename Button >
template<size_t n>
able::ButtonList< Button >::ButtonList ( Button *(&)  buttons[n])
inline

Create a list of buttons.

Makes beginning and handling of a set of buttons easier.

Parameters
buttonsThe array of buttons to manage together.

Definition at line 33 of file ButtonList.h.

◆ ButtonList() [2/2]

template<typename Button >
able::ButtonList< Button >::ButtonList ( Button **  buttons,
size_t  len 
)
inline

Create a list of buttons.

Makes beginning and handling of a set of buttons easier.

Parameters
buttonsThe array of buttons to manage together.
lenThe number of buttons in the list.

Definition at line 42 of file ButtonList.h.

Member Function Documentation

◆ allClicked()

template<typename Button >
bool able::ButtonList< Button >::allClicked ( ) const
inline

Determine if all of the buttons have been clicked.

Returns
True if all pressed, else false.

Definition at line 228 of file ButtonList.h.

◆ allDoubleClicked()

template<typename Button >
bool able::ButtonList< Button >::allDoubleClicked ( ) const
inline

Determine if all of the buttons have been double-clicked.

Returns
True if all double-clicked, else false.

Definition at line 258 of file ButtonList.h.

◆ allHeld()

template<typename Button >
bool able::ButtonList< Button >::allHeld ( ) const
inline

Determine if all of the buttons are currently held.

Returns
True if all held, else false.

Definition at line 168 of file ButtonList.h.

◆ allIdle()

template<typename Button >
bool able::ButtonList< Button >::allIdle ( ) const
inline

Determine if all of the buttons are currently idle.

Returns
True if all idle, else false.

Definition at line 198 of file ButtonList.h.

◆ allPressed()

template<typename Button >
bool able::ButtonList< Button >::allPressed ( ) const
inline

Determine if all of the buttons are currently pressed.

Returns
True if all pressed, else false.

Definition at line 138 of file ButtonList.h.

◆ anyClicked()

template<typename Button >
bool able::ButtonList< Button >::anyClicked ( ) const
inline

Determine if all of the buttons have been clicked.

Returns
True if any clicked, else false.

Definition at line 243 of file ButtonList.h.

◆ anyDoubleClicked()

template<typename Button >
bool able::ButtonList< Button >::anyDoubleClicked ( ) const
inline

Determine if any of the buttons have been double-clicked.

Returns
True if any double-clicked, else false.

Definition at line 273 of file ButtonList.h.

◆ anyHeld()

template<typename Button >
bool able::ButtonList< Button >::anyHeld ( ) const
inline

Determine if any of the buttons are currently held.

Returns
True if any held, else false.

Definition at line 183 of file ButtonList.h.

◆ anyIdle()

template<typename Button >
bool able::ButtonList< Button >::anyIdle ( ) const
inline

Determine if any of the buttons are currently idle.

Returns
True if any idle, else false.

Definition at line 213 of file ButtonList.h.

◆ anyPressed()

template<typename Button >
bool able::ButtonList< Button >::anyPressed ( ) const
inline

Determine if any of the buttons are currently pressed.

Returns
True if any pressed, else false.

Definition at line 153 of file ButtonList.h.

◆ begin()

template<typename Button >
void able::ButtonList< Button >::begin ( )
inline

Initialise all the buttons.

Called from setup() of an Arduino program.

Definition at line 53 of file ButtonList.h.

◆ button()

template<typename Button >
Button * able::ButtonList< Button >::button ( uint8_t  id) const
inline

For CallbackButtons (which each have an id), return a pointer to the first button matching the id (or a null pointer if the id is not found).

When using the button, always check if the return value is non-zero.

  Button *btn = btnList.button(id);
  if(btn) {
    // Use btn...
  } else {
    // Id not found in list...
  }
Parameters
idThe identifier of the button to find in the list.
Returns
The first id-matching button, or a null pointer.

Definition at line 122 of file ButtonList.h.

◆ handle()

template<typename Button >
void able::ButtonList< Button >::handle ( )
inline

Handle all the buttons.

Called in the loop() of an Arduino program to monitor all button states and dispatch any callback events if required.

Definition at line 63 of file ButtonList.h.

◆ resetClicked()

template<typename Button >
bool able::ButtonList< Button >::resetClicked ( )
inline

Reset clicked state of all buttons, returning true if any were clicked.

Returns
True if any clicked, else false.

Definition at line 74 of file ButtonList.h.

◆ resetDoubleClicked()

template<typename Button >
bool able::ButtonList< Button >::resetDoubleClicked ( )
inline

Reset double-clicked state of all buttons, returning true if any were double-clicked.

Returns
True if any double-clicked, else false.

Definition at line 90 of file ButtonList.h.


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