Commanders
Arduino buttons/bus library
ButtonsCommanderAnalogPushes.hpp
1 //-------------------------------------------------------------------
2 #ifndef __buttonsCommanderAnalogPushes_H__
3 #define __buttonsCommanderAnalogPushes_H__
4 //-------------------------------------------------------------------
5 
6 #include <Commanders.h>
7 #ifndef NO_BUTTONSCOMMANDER
8 #ifndef NO_BUTTONSCOMMANDERANALOGPUSHES
9 #include "ButtonsCommanderAnalogPushesItem.hpp"
10 
50 {
51 private:
52  int analogPin; // Number of the pushbutton analog pin. This is a normal number, not an arduino2 GPIO_pin_t.
53  uint8_t number; // Number of buttons
54  uint8_t lastButtonPressed; // last button pressed number
55  int lastButtonState; // the previous reading from the input pin
56  int readingTolerancy; // if the value is between 'button value-tolerance' and 'button value+tolerance' , this is good !
57 
58  // List of items which must be allocated by the constructor.
59  unsigned char size;
61 
62  unsigned long lastDebounceTime; // the last time the output pin was toggled
63  unsigned long debounceDelay; // the debounce time; increase if the output flickers
64 
65 public:
68 
76  void begin(int inButtonPin, uint8_t inNumber, unsigned long *inpIds, int *inpButtonValues, int inTolerancy = 20);
78  unsigned long loop();
80  void EndLoop();
82  ButtonsCommanderAnalogPushesItem *GetItem(uint8_t inNumber) { return &(this->pButtons[inNumber]); }
84  ButtonsCommanderButton* GetFromId(unsigned long inId);
85 
87  inline uint8_t GetLastButtonPressed() const { return this->lastButtonPressed; }
88 #ifdef COMMANDERS_PRINT_COMMANDERS
89 
92  void printCommander();
93 #endif
94 };
95 
96 //-------------------------------------------------------------------
97 #endif
98 #endif
99 #endif
ButtonsCommanderButton * GetFromId(unsigned long inId)
ButtonsCommanderAnalogPushesItem * GetItem(uint8_t inNumber)
void begin(int inButtonPin, uint8_t inNumber, unsigned long *inpIds, int *inpButtonValues, int inTolerancy = 20)