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
PjrcEncoderAdapter Class Reference

Description

An adapter for PJRC's Encoder.

One of the best (and most popular) encoder libraries. Initially written for Teensy but now suppoers many other boards. Repo: https://github.com/PaulStoffregen/Encoder Unfortunately the releases are a little behind the repository updates, so if your board is not working with the latest library release, try downloading from github and installing locally.

#include <PjrcEncoderAdapter.h>

Inheritance diagram for PjrcEncoderAdapter:
Inheritance graph
[legend]

Public Member Functions

 PjrcEncoderAdapter (uint8_t encoderPin1, uint8_t encoderPin2)
 Construct a new Pjrc Encoder Adapter object. An Encoder instance will be created for you. More...
 
 ~PjrcEncoderAdapter ()
 Destructor to ensure the PJRC encoder is deleted.
 
bool begin (void)
 In Encoder < v1.4.4 begin is not used but when v1.4.5 is released we will use it to initialise the encoder in setup for better compatibility with some boards. More...
 
int32_t getPosition (void)
 Get the current position as reported by the Encoder class. More...
 
void setPosition (int32_t pos)
 Set the a new position of the encoder. This can be any value in the int32_t range. More...
 
- 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

◆ PjrcEncoderAdapter()

PjrcEncoderAdapter::PjrcEncoderAdapter ( uint8_t  encoderPin1,
uint8_t  encoderPin2 
)
inline

Construct a new Pjrc Encoder Adapter object. An Encoder instance will be created for you.

Parameters
encoderPin1The first encoder pin (sometimes known as pin A)
encoderPin2The second encoder pin (sometimes known as pin B)

Member Function Documentation

◆ begin()

bool PjrcEncoderAdapter::begin ( void  )
inlinevirtual

In Encoder < v1.4.4 begin is not used but when v1.4.5 is released we will use it to initialise the encoder in setup for better compatibility with some boards.

Returns
true
false

Implements IEncoderAdapter.

◆ getPosition()

int32_t PjrcEncoderAdapter::getPosition ( void  )
inlinevirtual

Get the current position as reported by the Encoder class.

Returns
int32_t The position. May be positive or negative.

Implements IEncoderAdapter.

◆ setPosition()

void PjrcEncoderAdapter::setPosition ( int32_t  pos)
inlinevirtual

Set the a new position of the encoder. This can be any value in the int32_t range.

Parameters
posThe desired new position.

Implements IEncoderAdapter.


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