Commanders
Arduino buttons/bus library
|
#include "ButtonsCommanderSwitch.hpp"
Public Member Functions | |
ButtonsCommanderSwitch () | |
void | begin () |
EventPin * | AddEvent (unsigned long inId, int inPin, COMMANDERS_EVENT_TYPE inEvent = COMMANDERS_EVENT_MOVEPOSITIONID, int inData = 0) |
void | beforeFirstLoop () |
unsigned long | loop () |
unsigned long | GetId (GPIO_pin_t inPin) const |
![]() | |
ButtonsCommanderButton (unsigned long inId) | |
unsigned long | GetId () const |
virtual ButtonsCommanderButton * | GetFromId (unsigned long inId) |
virtual int | GetPosition () const |
virtual void | EndLoop () |
void | SetNextButton (ButtonsCommanderButton *inpButton) |
ButtonsCommanderButton * | GetNextButton () const |
Static Public Member Functions | |
static unsigned long | loopOnePin (GPIO_pin_t inPin, unsigned long inId, unsigned long inPreviousId, unsigned long *apDebounceDelay, GPIO_pin_t *apLastSelectedPin, int *apLastButtonState, unsigned long *apLastDebounceTime, bool inSendEvent = true) |
Additional Inherited Members | |
![]() | |
unsigned long | Id |
This class describes a switch with a variable number of pins/positions. The common cases are handled by ButtonsCommanderSwitchOnePin and ButtonsCommanderSwitchTwoPins, but if you have a switch with any other number of positions, this class is for you !
Events thrown:
reason | id | type | data
-----------------------—|-----------------—|--------------------—|-----------------— pin state to HIGH | button id pin | COMMANDERS_EVENT_MOVE | COMMANDERS_MOVE_ON previous pin state to LOW | button id prev pin | COMMANDERS_EVENT_MOVE | COMMANDERS_MOVE_OFF
Definition at line 33 of file ButtonsCommanderSwitch.hpp.
ButtonsCommanderSwitch::ButtonsCommanderSwitch | ( | ) |
Default constructor.
Definition at line 11 of file ButtonsCommanderSwitch.cpp.
EventPin * ButtonsCommanderSwitch::AddEvent | ( | unsigned long | inId, |
int | inPin, | ||
COMMANDERS_EVENT_TYPE | inEvent = COMMANDERS_EVENT_MOVEPOSITIONID , |
||
int | inData = 0 |
||
) |
Each position of the switch can be defined with an Arduino pin, and an event definition... In this case of switch, there is an event when one pin is activated, but there is no OFF event for the inactivated pin.
inId | id of the position. |
inPin | Arduino pin connected to the button. |
inEvent | Event type used when the pin is activated. Default COMMANDERS_EVENT_MOVEPOSITIONID. |
inData | Associated data when the pin is activated. Default 0. |
Definition at line 60 of file ButtonsCommanderSwitch.cpp.
|
virtual |
This function will be called after sketch Setup(), but before the first call to loop(). It will be called only one time.
Reimplemented from ButtonsCommanderButton.
Definition at line 126 of file ButtonsCommanderSwitch.cpp.
void ButtonsCommanderSwitch::begin | ( | ) |
Initialize the instance.
Definition at line 25 of file ButtonsCommanderSwitch.cpp.
unsigned long ButtonsCommanderSwitch::GetId | ( | GPIO_pin_t | inPin | ) | const |
Gets the right id according to the activated pin.
Definition at line 46 of file ButtonsCommanderSwitch.cpp.
|
virtual |
Main loop function.
Reimplemented from ButtonsCommanderButton.
Definition at line 149 of file ButtonsCommanderSwitch.cpp.
|
static |
Check if a pin has changed its state, and send an event if necessary.
Definition at line 72 of file ButtonsCommanderSwitch.cpp.