#include <SwitchInput.h>
Public Member Functions | |
HardwareRotaryEncoder (pinid_t pinA, pinid_t pinB, EncoderCallbackFn callback, HWAccelerationMode accelerationMode=HWACCEL_REGULAR, EncoderType=FULL_CYCLE) | |
HardwareRotaryEncoder (pinid_t pinA, pinid_t pinB, EncoderListener *listener, HWAccelerationMode accelerationMode=HWACCEL_REGULAR, EncoderType=FULL_CYCLE) | |
void | encoderChanged () override |
Public Member Functions inherited from AbstractHwRotaryEncoder | |
AbstractHwRotaryEncoder (EncoderCallbackFn callback) | |
AbstractHwRotaryEncoder (EncoderListener *listener) | |
void | setAccelerationMode (HWAccelerationMode mode) |
void | setEncoderType (EncoderType et) |
Public Member Functions inherited from RotaryEncoder | |
RotaryEncoder (EncoderCallbackFn callback) | |
RotaryEncoder (EncoderListener *listener) | |
void | changePrecision (uint16_t maxValue, int currentValue, bool rolloverOnMax=false, int step=1) |
void | replaceCallback (EncoderCallbackFn callbackFn) |
void | replaceCallbackListener (EncoderListener *callbackFn) |
int | getCurrentReading () const |
void | setCurrentReading (int reading) |
void | increment (int8_t incVal) |
bool | didLastSyncSucceed () |
void | setUserIntention (EncoderUserIntention intention) |
EncoderUserIntention | getUserIntention () |
void | runCallback (int newVal) |
bsize_t | getMaximumValue () |
Additional Inherited Members | |
Protected Types inherited from RotaryEncoder | |
enum | EncoderFlagBits { LAST_SYNC_STATUS =0 , WRAP_AROUND_MODE , OO_LISTENER_CALLBACK , LAST_ENCODER_DIRECTION_UP } |
Protected Member Functions inherited from AbstractHwRotaryEncoder | |
void | initialiseBase (pinid_t pinA, pinid_t pinB, HWAccelerationMode accelerationMode, EncoderType) |
int | amountFromChange (unsigned long change) |
void | handleChangeRaw (bool increase) |
Protected Attributes inherited from AbstractHwRotaryEncoder | |
unsigned long | lastChange |
pinid_t | pinA |
pinid_t | pinB |
HWAccelerationMode | accelerationMode |
EncoderType | encoderType |
Protected Attributes inherited from RotaryEncoder | |
uint16_t | maximumValue |
uint16_t | currentReading |
uint8_t | stepSize |
union { | |
EncoderCallbackFn | callback |
EncoderListener * | encoderListener |
} | notify |
uint8_t | flags |
EncoderUserIntention | intent |
An implementation of RotaryEncoder that supports the most common types of rotary encoder, needed no additional hardware in most cases. For single encoders registered with switches see the helper method. This is now only used by switches helper functions when legacy mode is enabled using TC_LEGACY_ENCODER. For all new cases we recommend using HwStateRotaryEncoder instead.
HardwareRotaryEncoder::HardwareRotaryEncoder | ( | pinid_t | pinA, |
pinid_t | pinB, | ||
EncoderCallbackFn | callback, | ||
HWAccelerationMode | accelerationMode = HWACCEL_REGULAR , |
||
EncoderType | encoderType = FULL_CYCLE |
||
) |
Create an instance of a hardware rotary encoder specifying the A and B pin, the acceleration parameters and encoder type. It is your responsibility to register this encoder with switches using setEncoder(n, encoderPtr) if you use the constructor.
pinA | the A pin of the encoder |
pinB | the B pin of the encoder |
callback | the function callback to be called when triggered |
accelerationMode | the amount of acceleration to use |
HardwareRotaryEncoder::HardwareRotaryEncoder | ( | pinid_t | pinA, |
pinid_t | pinB, | ||
EncoderListener * | listener, | ||
HWAccelerationMode | accelerationMode = HWACCEL_REGULAR , |
||
EncoderType | encoderType = FULL_CYCLE |
||
) |
Create an instance of a hardware rotary encoder specifiying the A and B pin, the acceleration parameters and encoder type. It is your responsibility to register this encoder with switches using setEncoder(n, encoderPtr) if you use the constructor. This constructor takes an OO listener instead of a callback function, the listener implements EncoderListener.
pinA | the A pin of the encoder |
pinB | the B pin of the encoder |
listener | the OO listener extending from EncoderListener |
accelerationMode | the amount of acceleration to use |
|
overridevirtual |
internal method not for external use..
Calculate the new state from signals A and B.
Signal A and B form a quadrature signal pattern like this:
Signal A: __|¯¯|__|¯¯|__ (HIGH/LOW alternating) Signal B: _|¯¯|__|¯¯|__|_ (90 degrees phase-shifted from A)
Each combination of A and B represents one of four states:
Transitions between these states determine the direction of rotation:
The new state is calculated by combining the values of signals A and B:
Reimplemented from RotaryEncoder.