Commanders
Arduino buttons/bus library
|
#include "ButtonsCommanderSwitchTwoPins.hpp"
Public Member Functions | |
ButtonsCommanderSwitchTwoPins () | |
void | begin (unsigned long inId1, int inPin1, unsigned long inId2, int inPin2) |
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 |
Additional Inherited Members | |
![]() | |
unsigned long | Id |
A switch can be used in a A/B way. In this case only two Arduino pins are connected to the switch. The event raised is always of type COMMANDERS_EVENT_MOVE and data is COMMANDERS_MOVE_ON or COMMANDERS_MOVE_OFF, but the id used depends on the activated pin. Two events are always thrown by Commanders : the activation of one pin, and the disactvation of the other !
Events thrown:
reason | id | type | data
------------------------—|---------—|--------------------—|-----------------— pin1 state to HIGH | button id1 | COMMANDERS_EVENT_MOVE | COMMANDERS_MOVE_ON previous pin2 state to LOW | button id2 | COMMANDERS_EVENT_MOVE | COMMANDERS_MOVE_OFF pin2 state to HIGH | button id2 | COMMANDERS_EVENT_MOVE | COMMANDERS_MOVE_ON previous pin1 state to LOW | button id1 | COMMANDERS_EVENT_MOVE | COMMANDERS_MOVE_OFF
Definition at line 24 of file ButtonsCommanderSwitchTwoPins.hpp.
ButtonsCommanderSwitchTwoPins::ButtonsCommanderSwitchTwoPins | ( | ) |
Default constructor.
Definition at line 11 of file ButtonsCommanderSwitchTwoPins.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 28 of file ButtonsCommanderSwitchTwoPins.cpp.
void ButtonsCommanderSwitchTwoPins::begin | ( | unsigned long | inId1, |
int | inPin1, | ||
unsigned long | inId2, | ||
int | inPin2 | ||
) |
Initialize the instance.
inId1 | id of the first position. |
inPin1 | Arduino pin connected to the switch button for the first position. |
inId2 | id of the second position. |
inPin2 | Arduino pin connected to the switch button for the second position. |
Definition at line 17 of file ButtonsCommanderSwitchTwoPins.cpp.
|
inline |
Gets the right id according to the activated pin.
Definition at line 55 of file ButtonsCommanderSwitchTwoPins.hpp.
|
virtual |
Main loop function.
Reimplemented from ButtonsCommanderButton.
Definition at line 53 of file ButtonsCommanderSwitchTwoPins.cpp.