InputEvents v1.4.0
An easy to use but comprehensive Event Library for Buttons, Encoders, Encoder Buttons, Analog Inputs, Joysticks and Switches.
Bounce2PinAdapter.h
1#ifndef Bounce2PinAdapter_h
2#define Bounce2PinAdapter_h
3
4#include "DebounceAdapter.h"
5#include "Bounce2.h"
14
15 public:
16
17 Bounce2PinAdapter(byte pin)
18 : buttonPin(pin)
19 , bounce(new Bounce())
20 { }
21
22
23 void begin() {
24 delayMicroseconds(2000); //Delay
25 bounce->attach(buttonPin, INPUT_PULLUP);
26 }
27
28 bool read() {
29 bounce->update();
30 return bounce->read();
31 }
32
33 private:
34 byte buttonPin;
35 Bounce* bounce;
36
37
38};
39
40#endif
A PinAdapter for the Bounce2 library. Note: this is not a DebounceAdapter as Bounce2 can only read th...
Definition: Bounce2PinAdapter.h:13
void begin()
Initialise the pin adapter. Must be safe for repeated calls (Idempotent)
Definition: Bounce2PinAdapter.h:23
bool read()
Read the current state of the pin.
Definition: Bounce2PinAdapter.h:28
The interface specification for button, encoder button and switch pins.
Definition: PinAdapter.h:8