Commanders
Arduino buttons/bus library
ButtonsCommanderSwitchTwoPins.hpp
1 //-------------------------------------------------------------------
2 #ifndef __buttonsCommanderSwitchTwoPins_H__
3 #define __buttonsCommanderSwitchTwoPins_H__
4 //-------------------------------------------------------------------
5 
6 #include <Commanders.h>
7 #ifndef NO_BUTTONSCOMMANDER
8 #ifndef NO_BUTTONSCOMMANDERSWITCH
9 
26 {
27  private:
28  GPIO_pin_t Pin1;
29  GPIO_pin_t Pin2;
30  // unsigned long Id1; / use base id instead...
31  unsigned long Id2;
32 
33  unsigned long debounceDelay; // the debounce time; increase if the output flickers
34 
35  byte lastButtonState1;
36  unsigned long lastDebounceTime1;
37  byte lastButtonState2;
38  unsigned long lastDebounceTime2;
39 
40 public:
43 
50  void begin(unsigned long inId1, int inPin1, unsigned long inId2, int inPin2);
53  void beforeFirstLoop();
55  unsigned long loop();
57  inline unsigned long GetId(GPIO_pin_t inPin) const { return inPin == this->Pin1 ? this->Id : (inPin == this->Pin2 ? this->Id2 : UNDEFINED_ID); }
58 
59 #ifdef COMMANDERS_PRINT_COMMANDERS
60 
63  void printCommander();
64 #endif
65 };
66 
67 //-------------------------------------------------------------------
68 #endif
69 #endif
70 #endif
#define UNDEFINED_ID
Definition: Events.h:38
unsigned long Id
Definition: ButtonsCommanderButton.hpp:19
unsigned long GetId(GPIO_pin_t inPin) const
Definition: ButtonsCommanderSwitchTwoPins.hpp:57
unsigned long loop()
Definition: ButtonsCommanderSwitchTwoPins.cpp:53
void begin(unsigned long inId1, int inPin1, unsigned long inId2, int inPin2)
Definition: ButtonsCommanderSwitchTwoPins.cpp:16
ButtonsCommanderSwitchTwoPins()
Definition: ButtonsCommanderSwitchTwoPins.cpp:11
Definition: ButtonsCommanderButton.hpp:15
Definition: ButtonsCommanderSwitchTwoPins.hpp:25
void beforeFirstLoop()
Definition: ButtonsCommanderSwitchTwoPins.cpp:31