InputEvents v1.5.2
An easy to use but comprehensive Event Library for Buttons, Encoders, Encoder Buttons, Analog Inputs, Joysticks and Switches.
GpioExpanderAdapter.h
1#ifndef GpioExpanderAdapter_h
2#define GpioExpanderAdapter_h
3
4#include "Arduino.h"
5
11
12 public:
17 virtual void begin() = 0;
18
25 virtual void update() = 0;
26
33 virtual bool read(byte pin) = 0;
34
38 virtual void attachPin(byte pin, int mode = INPUT_PULLUP) = 0;
39
48 void write(byte pin, bool state) {}
49
56 bool canWrite() { return false; }
57
58 virtual ~GpioExpanderAdapter() = default;
59
60};
61
62#endif
The base class/interface specification for GPIO expanders.
Definition: GpioExpanderAdapter.h:10
virtual bool read(byte pin)=0
Returns the state of a pin on the expander.
virtual void begin()=0
Initialize the expander. (Idempotent)
virtual void update()=0
Read the state of all pins on the expander.
virtual void attachPin(byte pin, int mode=INPUT_PULLUP)=0
Use it to configure individual pin mode, if expander allows it. Not all of them do.
bool canWrite()
Returns true if the concrete GpioExpanderAdapter has implemented the write() method.
Definition: GpioExpanderAdapter.h:56
void write(byte pin, bool state)
Optionally implemented by concrete GpioExpanderAdapters if they support writing to pins.
Definition: GpioExpanderAdapter.h:48