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 | Protected Attributes | Static Protected Attributes | List of all members
BaseTableEncoderAdapter Class Referenceabstract

Description

A base class for encoder adapters that uses a quadrature encoder table to determine posion changes from pins.

#include <BaseTableEncoderAdapter.h>

Inheritance diagram for BaseTableEncoderAdapter:
Inheritance graph
[legend]

Public Member Functions

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

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

Protected Attributes

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

static constexpr int8_t table [16]
 

Member Function Documentation

◆ getPosition()

virtual int32_t BaseTableEncoderAdapter::getPosition ( void  )
inlineoverridevirtual

Get the current position of the encoder.

Returns
int32_t

Implements IEncoderAdapter.

◆ readPin()

virtual uint8_t BaseTableEncoderAdapter::readPin ( uint8_t  pin) const
protectedpure virtual

Concrete implementations must provide a method to read pin values.

Parameters
pin
Returns
uint8_t

Implemented in ExpanderEncoderAdapter.

◆ setPosition()

virtual void BaseTableEncoderAdapter::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.

Member Data Documentation

◆ table

constexpr int8_t BaseTableEncoderAdapter::table
staticconstexprprotected
Initial value:
= {
0, 1, -1, 0,
-1, 0, 0, 1,
1, 0, 0, -1,
0, -1, 1, 0
}

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