![]() |
InputEvents v1.6.0
An easy to use but comprehensive Event Library for Buttons, Encoders, Encoder Buttons, Analog Inputs, Joysticks and Switches.
|
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>

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... | |
|
inline |
Construct a new Pjrc Encoder Adapter object. An Encoder instance will be created for you.
| encoderPin1 | The first encoder pin (sometimes known as pin A) |
| encoderPin2 | The second encoder pin (sometimes known as pin B) |
|
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.
Implements IEncoderAdapter.
|
inlinevirtual |
Get the current position as reported by the Encoder class.
Implements IEncoderAdapter.
|
inlinevirtual |
Set the a new position of the encoder. This can be any value in the int32_t range.
| pos | The desired new position. |
Implements IEncoderAdapter.