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 
25 {
26  private:
27  GPIO_pin_t Pin1;
28  GPIO_pin_t Pin2;
29  // unsigned long Id1; / use base id instead...
30  unsigned long Id2;
31 
32  unsigned long debounceDelay; // the debounce time; increase if the output flickers
33  GPIO_pin_t lastSelectedPin;
34 
35  int lastButtonState; // the previous reading from the current input pin
36  unsigned long lastDebounceTime; // the last time the current output pin was toggled
37 
38 public:
41 
48  void begin(unsigned long inId1, int inPin1, unsigned long inId2, int inPin2);
51  void beforeFirstLoop();
53  unsigned long loop();
55  inline unsigned long GetId(GPIO_pin_t inPin) const { return inPin == this->Pin1 ? this->Id : (inPin == this->Pin2 ? this->Id2 : UNDEFINED_ID); }
56 
57 #ifdef COMMANDERS_PRINT_COMMANDERS
58 
61  void printCommander();
62 #endif
63 };
64 
65 //-------------------------------------------------------------------
66 #endif
67 #endif
68 #endif
#define UNDEFINED_ID
Definition: Events.h:38
unsigned long GetId(GPIO_pin_t inPin) const
void begin(unsigned long inId1, int inPin1, unsigned long inId2, int inPin2)