Commanders
Arduino buttons/bus library
ButtonsCommanderSwitch.hpp
1 //-------------------------------------------------------------------
2 #ifndef __buttonsCommanderSwitch_H__
3 #define __buttonsCommanderSwitch_H__
4 //-------------------------------------------------------------------
5 
6 #include <Commanders.h>
7 #ifndef NO_BUTTONSCOMMANDER
8 #ifndef NO_BUTTONSCOMMANDERSWITCH
9 #include "Chain.hpp"
10 
11 //-------------------------------------------------------------------
12 
14 struct EventPin
15 {
16  GPIO_pin_t Pin;
17  unsigned long Id;
19  int Data;
21  unsigned long LastDebounceTime;
22 };
23 
36 {
37  private:
38  unsigned long debounceDelay; // the debounce time; increase if the output flickers
40  GPIO_pin_t lastSelectedPin;
41 
42 public:
45 
47  void begin();
55  EventPin *AddEvent(unsigned long inId, int inPin, COMMANDERS_EVENT_TYPE inEvent = COMMANDERS_EVENT_MOVEPOSITIONID, int inData = 0);
58  void beforeFirstLoop();
60  unsigned long loop();
62  unsigned long GetId(GPIO_pin_t inPin, COMMANDERS_EVENT_TYPE *apEvent = NULL, int *apData = NULL) const;
63 
67  static bool HavePinStateChanged(GPIO_pin_t inPin, unsigned long inDebounceDelay, byte *inpCurrentPinState, unsigned long *inpLastDebounceTime);
68 
69 #ifdef COMMANDERS_PRINT_COMMANDERS
70 
73  void printCommander();
74 #endif
75 };
76 
77 //-------------------------------------------------------------------
78 #endif
79 #endif
80 #endif
static bool HavePinStateChanged(GPIO_pin_t inPin, unsigned long inDebounceDelay, byte *inpCurrentPinState, unsigned long *inpLastDebounceTime)
EventPin * AddEvent(unsigned long inId, int inPin, COMMANDERS_EVENT_TYPE inEvent = COMMANDERS_EVENT_MOVEPOSITIONID, int inData = 0)
unsigned long GetId() const
unsigned long LastDebounceTime
COMMANDERS_EVENT_TYPE Event
COMMANDERS_EVENT_TYPE
Definition: Events.h:25
unsigned long Id