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;
20 };
21 
34 {
35  private:
36  unsigned long debounceDelay; // the debounce time; increase if the output flickers
38  GPIO_pin_t lastSelectedPin;
39 
40  int lastButtonState; // the previous reading from the current input pin
41  unsigned long lastDebounceTime; // the last time the current output pin was toggled
42 
43 public:
46 
48  void begin();
56  EventPin *AddEvent(unsigned long inId, int inPin, COMMANDERS_EVENT_TYPE inEvent = COMMANDERS_EVENT_MOVEPOSITIONID, int inData = 0);
59  void beforeFirstLoop();
61  unsigned long loop();
63  unsigned long GetId(GPIO_pin_t inPin) const;
64 
68  static unsigned long loopOnePin(GPIO_pin_t inPin, unsigned long inId, unsigned long inPreviousId,
69  unsigned long *apDebounceDelay, GPIO_pin_t *apLastSelectedPin,
70  int *apLastButtonState, unsigned long *apLastDebounceTime, bool inSendEvent = true);
71 
72 #ifdef COMMANDERS_PRINT_COMMANDERS
73 
76  void printCommander();
77 #endif
78 };
79 
80 //-------------------------------------------------------------------
81 #endif
82 #endif
83 #endif
static unsigned long loopOnePin(GPIO_pin_t inPin, unsigned long inId, unsigned long inPreviousId, unsigned long *apDebounceDelay, GPIO_pin_t *apLastSelectedPin, int *apLastButtonState, unsigned long *apLastDebounceTime, bool inSendEvent = true)
EventPin * AddEvent(unsigned long inId, int inPin, COMMANDERS_EVENT_TYPE inEvent = COMMANDERS_EVENT_MOVEPOSITIONID, int inData = 0)
COMMANDERS_EVENT_TYPE Event
COMMANDERS_EVENT_TYPE
Definition: Events.h:25
unsigned long Id
unsigned long GetId() const