Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. /*
  2.   ButtonDebounce.h - Library for Button Debounce.
  3.   Created by Maykon L. Capellari, September 30, 2017.
  4.   Released into the public domain.
  5. */
  6. #ifndef ButtonDebounce_h
  7. #define ButtonDebounce_h
  8.  
  9. #include "Arduino.h"
  10.  
  11. typedef std::function<void(const int)> ButtonCallback;
  12.  
  13. class ButtonDebounce{
  14.   private:
  15.     int _pin;
  16.     unsigned long _delay;
  17.     unsigned long _lastDebounceTime;
  18.     unsigned long _lastChangeTime;
  19.     int _lastStateBtn;
  20.     ButtonCallback _callBack = NULL;
  21.     bool isTimeToUpdate();
  22.   public:
  23.     ButtonDebounce(int pin, unsigned long delay);
  24.     void update();
  25.     int state();
  26.     void setCallback(ButtonCallback);
  27. };
  28.  
  29. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement