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 | List of all members
SlowExpanderEncoderAdapter Class Reference

Description

A very basic IEncoderAdapter for slow GPIO Expanders.

This encoder adapter only checks for a single state change instead of the usual four in a quadrature encoder. This may provide more reliable events for where encoder movement is slow and/or the loop() cannot keep up.

#include <SlowExpanderEncoderAdapter.h>

Inheritance diagram for SlowExpanderEncoderAdapter:
Inheritance graph
[legend]

Public Member Functions

 SlowExpanderEncoderAdapter (uint8_t encoderPinA, uint8_t encoderPinB, GpioExpanderAdapter &expander)
 Construct a ExpanderEncoderAdapter. More...
 
bool begin () override
 For compatibility with the Arduino library convention. More...
 
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...
 

Constructor & Destructor Documentation

◆ SlowExpanderEncoderAdapter()

SlowExpanderEncoderAdapter::SlowExpanderEncoderAdapter ( uint8_t  encoderPinA,
uint8_t  encoderPinB,
GpioExpanderAdapter expander 
)
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

Member Function Documentation

◆ begin()

bool SlowExpanderEncoderAdapter::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.

◆ getPosition()

virtual int32_t SlowExpanderEncoderAdapter::getPosition ( void  )
inlineoverridevirtual

Get the current position of the encoder.

Returns
int32_t

Implements IEncoderAdapter.

◆ setPosition()

virtual void SlowExpanderEncoderAdapter::setPosition ( int32_t  pos)
inlinevirtual

Set the a new position of the encoder. For some libraries this may only allow it to be set to 0.

Parameters
posThe desired new position.

Implements IEncoderAdapter.


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