InputEvents v1.4.0
An easy to use but comprehensive Event Library for Buttons, Encoders, Encoder Buttons, Analog Inputs, Joysticks and Switches.
VirtualPinAdapter.h
1#ifndef VirtualPinAdapter_h
2#define VirtualPinAdapter_h
3
4#include <Arduino.h>
5#include "PinAdapter.h"
6
12
13 public:
19 VirtualPinAdapter(bool pressedState = LOW)
20 : pressedState(pressedState)
21 { }
22
26 void begin() {
27 state = !pressedState;
28 }
29
36 bool read() {
37 return state;
38 }
39
43 void press() {
44 state = pressedState;
45 }
46
50 void release() {
51 state = !pressedState;
52 }
53
59 void setState(bool newState) {
60 state = newState;
61 }
62
63 private:
64 bool pressedState = LOW;
65 bool state = HIGH;
66
67};
68
69#endif
The interface specification for button, encoder button and switch pins.
Definition: PinAdapter.h:8
A PinAdapter that can set state programtically.
Definition: VirtualPinAdapter.h:11
void begin()
Sets the iniial state.
Definition: VirtualPinAdapter.h:26
void setState(bool newState)
Directly set the state.
Definition: VirtualPinAdapter.h:59
bool read()
Returns the current state.
Definition: VirtualPinAdapter.h:36
void release()
Set the state to 'not pressedState'.
Definition: VirtualPinAdapter.h:50
void press()
Set the state to pressedState.
Definition: VirtualPinAdapter.h:43
VirtualPinAdapter(bool pressedState=LOW)
Construct a VirtualPinAdapter.
Definition: VirtualPinAdapter.h:19