InputEvents v1.6.0
An easy to use but comprehensive Event Library for Buttons, Encoders, Encoder Buttons, Analog Inputs, Joysticks and Switches.
ExpanderEncoderAdapter.h
1#ifndef INPUT_EVENTS_EXPANDER_ENCODER_ADAPTER_H
2#define INPUT_EVENTS_EXPANDER_ENCODER_ADAPTER_H
3
4
5#include "BaseTableEncoderAdapter.h"
6#include "GpioExpanderAdapter/GpioExpanderAdapter.h"
7
9
10
11public:
12
21 ExpanderEncoderAdapter( uint8_t encoderPinA, uint8_t encoderPinB, GpioExpanderAdapter& expander, bool externalUpdate=false )
22 : expanderAdapter(&expander)
23 {
24 _pinA = encoderPinA;
25 _pinB = encoderPinB;
26 _externalUpdate = externalUpdate;
27 }
28
29 bool begin() override {
30 expanderAdapter->attachPin(_pinA);
31 expanderAdapter->attachPin(_pinB);
32 return true;
33 }
34
35protected:
36
37 uint8_t readPin(uint8_t pin) const override {
38 return expanderAdapter->read(pin);
39 }
40
41
42private:
43 GpioExpanderAdapter* expanderAdapter;
44
45};
46
47
48
49#endif
A base class for encoder adapters that uses a quadrature encoder table to determine posion changes fr...
Definition: BaseTableEncoderAdapter.h:11
bool _externalUpdate
Some implementations may allow the update via an interupt.
Definition: BaseTableEncoderAdapter.h:63
Definition: ExpanderEncoderAdapter.h:8
ExpanderEncoderAdapter(uint8_t encoderPinA, uint8_t encoderPinB, GpioExpanderAdapter &expander, bool externalUpdate=false)
Construct a ExpanderEncoderAdapter.
Definition: ExpanderEncoderAdapter.h:21
uint8_t readPin(uint8_t pin) const override
Concrete implementations must provide a method to read pin values.
Definition: ExpanderEncoderAdapter.h:37
bool begin() override
For compatibility with the Arduino library convention.
Definition: ExpanderEncoderAdapter.h:29
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 attachPin(byte pin, int mode=INPUT_PULLUP)=0
Use it to configure individual pin mode, if expander allows it. Not all of them do.