#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, COMMANDERS_EVENT_TYPE *apEvent = NULL, int *apData = NULL) 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 bool | HavePinStateChanged (GPIO_pin_t inPin, unsigned long inDebounceDelay, byte *inpCurrentPinState, unsigned long *inpLastDebounceTime) |
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 |
---|---|---|---|
event pin state to HIGH | event id | Event Type | Event Data |
event pin state to LOW | nothing | |
Definition at line 35 of file ButtonsCommanderSwitch.hpp.
ButtonsCommanderSwitch::ButtonsCommanderSwitch | ( | ) |
Default constructor.
Definition at line 12 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 65 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 121 of file ButtonsCommanderSwitch.cpp.
void ButtonsCommanderSwitch::begin | ( | ) |
Initialize the instance.
Definition at line 26 of file ButtonsCommanderSwitch.cpp.
unsigned long ButtonsCommanderSwitch::GetId | ( | GPIO_pin_t | inPin, |
COMMANDERS_EVENT_TYPE * | apEvent = NULL , |
||
int * | apData = NULL |
||
) | const |
Gets the right id according to the activated pin.
Definition at line 45 of file ButtonsCommanderSwitch.cpp.
|
static |
Check if a pin has changed its state, and send an event if necessary.
Definition at line 79 of file ButtonsCommanderSwitch.cpp.
|
virtual |
Main loop function.
Reimplemented from ButtonsCommanderButton.
Definition at line 142 of file ButtonsCommanderSwitch.cpp.