Commanders
Arduino buttons/bus library
ButtonsCommanderPush.hpp
1 //-------------------------------------------------------------------
2 #ifndef __buttonsCommanderPush_H__
3 #define __buttonsCommanderPush_H__
4 //-------------------------------------------------------------------
5 
6 #include <Commanders.h>
7 #ifndef NO_BUTTONSCOMMANDER
8 #ifndef NO_BUTTONSCOMMANDERPUSH
9 #include "Chain.hpp"
10 
12 struct Event
13 {
14  unsigned long Id;
16  int Data;
17 };
18 
30 {
31  private:
32  GPIO_pin_t buttonPin; // the number of the pushbutton pin
33  byte lastButtonState; // the previous reading from the input pin
34 
35  unsigned long lastDebounceTime; // the last time the output pin was toggled
36  unsigned long debounceDelay; // the debounce time; increase if the output flickers
37 
39 
40  public:
43 
50  void begin(unsigned long inId, int inButtonPin, COMMANDERS_EVENT_TYPE inEventType = COMMANDERS_EVENT_MOVEPOSITIONID, int inData = 0);
59  void AddEvent(unsigned long inId, COMMANDERS_EVENT_TYPE inEventType = COMMANDERS_EVENT_MOVEPOSITIONID, int inData = 0);
61  unsigned long loop();
62 
66  inline int GetPin() const { return GPIO_to_Arduino_pin(this->buttonPin); }
70  inline GPIO_pin_t GetDIO2Pin() const { return this->buttonPin; }
71 
72 #ifdef COMMANDERS_PRINT_COMMANDERS
73 
76  void printCommander();
77 #endif
78 };
79 
80 //-------------------------------------------------------------------
81 #endif
82 #endif
83 #endif
GPIO_pin_t GetDIO2Pin() const
void begin(unsigned long inId, int inButtonPin, COMMANDERS_EVENT_TYPE inEventType = COMMANDERS_EVENT_MOVEPOSITIONID, int inData = 0)
void AddEvent(unsigned long inId, COMMANDERS_EVENT_TYPE inEventType = COMMANDERS_EVENT_MOVEPOSITIONID, int inData = 0)
COMMANDERS_EVENT_TYPE EventType
COMMANDERS_EVENT_TYPE
Definition: Events.h:25
unsigned long Id