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 unsigned long loopOnePin(unsigned long inId, GPIO_pin_t inPin, unsigned long inPreviousId, unsigned long inDebounceDelay,
68  byte *inpLastPinState, unsigned long *inpLastDebounceTime, bool inSendEvent = true);
69 
70 #ifdef COMMANDERS_PRINT_COMMANDERS
71 
74  void printCommander();
75 #endif
76 };
77 
78 //-------------------------------------------------------------------
79 #endif
80 #endif
81 #endif
unsigned long GetId() const
EventPin * AddEvent(unsigned long inId, int inPin, COMMANDERS_EVENT_TYPE inEvent = COMMANDERS_EVENT_MOVEPOSITIONID, int inData = 0)
static unsigned long loopOnePin(unsigned long inId, GPIO_pin_t inPin, unsigned long inPreviousId, unsigned long inDebounceDelay, byte *inpLastPinState, unsigned long *inpLastDebounceTime, bool inSendEvent = true)
unsigned long LastDebounceTime
COMMANDERS_EVENT_TYPE Event
COMMANDERS_EVENT_TYPE
Definition: Events.h:25
unsigned long Id