PushButton.h 694 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * PushButton.h
  3. *
  4. * Created: 18/11/2014 19:33:33
  5. * Author: Richard
  6. */
  7. #ifndef PUSHBUTTON_H_
  8. #define PUSHBUTTON_H_
  9. #include <Bounce2.h>
  10. #include "Button.h"
  11. #define PRESSED_WHEN_HIGH B0
  12. #define PRESSED_WHEN_LOW B1
  13. #define ENABLE_INTERNAL_PULLUP B10
  14. // Define button configuration callback
  15. typedef void (*PushButtonConfigurationCallback)(Bounce&);
  16. class PushButton : public Button {
  17. private:
  18. Bounce bouncer;
  19. void init(uint8_t, uint8_t);
  20. uint8_t _button_pressed_value;
  21. protected:
  22. boolean _update_button_state();
  23. public:
  24. PushButton(uint8_t);
  25. PushButton(uint8_t, uint8_t);
  26. void configureButton(PushButtonConfigurationCallback);
  27. };
  28. #endif /* PUSHBUTTON_H_ */