InputEvents v1.6.0
An easy to use but comprehensive Event Library for Buttons, Encoders, Encoder Buttons, Analog Inputs, Joysticks and Switches.
Public Member Functions | Protected Member Functions | List of all members
ExpanderEncoderAdapter Class Reference
Inheritance diagram for ExpanderEncoderAdapter:
Inheritance graph
[legend]

Public Member Functions

 ExpanderEncoderAdapter (uint8_t encoderPinA, uint8_t encoderPinB, GpioExpanderAdapter &expander, bool externalUpdate=false)
 Construct a ExpanderEncoderAdapter. More...
 
bool begin () override
 For compatibility with the Arduino library convention. More...
 
- Public Member Functions inherited from BaseTableEncoderAdapter
virtual int32_t getPosition () override
 Get the current position of the encoder. More...
 
virtual void setPosition (int32_t pos)
 Set the a new position of the encoder. For some libraries this may only allow it to be set to 0. More...
 
virtual void update ()
 Update position using the table.
 
- Public Member Functions inherited from IEncoderAdapter
virtual ~IEncoderAdapter ()=default
 Destructor to ensure predictable behavious if derived classes are destroyed.
 
virtual bool begin (void)=0
 For compatibility with the Arduino library convention. More...
 
virtual int32_t getPosition (void)=0
 Get the current position as reported by the encoder class. More...
 
virtual void setPosition (int32_t pos)=0
 Set the a new position of the encoder. For some libraries this may only allow it to be set to 0. More...
 

Protected Member Functions

uint8_t readPin (uint8_t pin) const override
 Concrete implementations must provide a method to read pin values. More...
 
virtual uint8_t readPin (uint8_t pin) const =0
 Concrete implementations must provide a method to read pin values. More...
 

Additional Inherited Members

- Protected Attributes inherited from BaseTableEncoderAdapter
uint8_t _pinA
 
uint8_t _pinB
 
uint8_t _prevState = 0
 
int32_t _position = 0
 
bool _externalUpdate = false
 Some implementations may allow the update via an interupt.
 
- Static Protected Attributes inherited from BaseTableEncoderAdapter
static constexpr int8_t table [16]
 

Constructor & Destructor Documentation

◆ ExpanderEncoderAdapter()

ExpanderEncoderAdapter::ExpanderEncoderAdapter ( uint8_t  encoderPinA,
uint8_t  encoderPinB,
GpioExpanderAdapter expander,
bool  externalUpdate = false 
)
inline

Construct a ExpanderEncoderAdapter.

Parameters
encoderPinAThe pin on the expander biard for the encoder A pin
encoderPinBThe pin on the expander biard for the encoder B pin
expanderPassed by reference because the GpioExpanderAdapter::update() is always called from loop() or interrupt
externalUpdateDefault is false and this class's update() is called in getPosition(). If true, ExpanderEncoderAdapter::update() must be called called from interrupt or loop().

Member Function Documentation

◆ begin()

bool ExpanderEncoderAdapter::begin ( )
inlineoverridevirtual

For compatibility with the Arduino library convention.

Must be implemented (but can be empty) as some libraries require it. Can return a boolean to indicate if initialisation has failed.

Returns
true The initialisation was successful.
false The initialisation was failed.

Implements IEncoderAdapter.

◆ readPin()

uint8_t ExpanderEncoderAdapter::readPin ( uint8_t  pin) const
inlineoverrideprotectedvirtual

Concrete implementations must provide a method to read pin values.

Parameters
pin
Returns
uint8_t

Implements BaseTableEncoderAdapter.


The documentation for this class was generated from the following file: