#include <SwitchInput.h>
Public Member Functions | |
HwStateRotaryEncoder (pinid_t pinA, pinid_t pinB, EncoderCallbackFn callback, HWAccelerationMode accelerationMode=HWACCEL_REGULAR, EncoderType=FULL_CYCLE) | |
HwStateRotaryEncoder (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. It is based on a state machine of valid possible states, and should handle quarter turn encoders properly. Interrupt mode is not mandatory, but be aware that without interrupts the polling is approximately every 2 milliseconds.
HwStateRotaryEncoder::HwStateRotaryEncoder | ( | 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 |
HwStateRotaryEncoder::HwStateRotaryEncoder | ( | 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..
Reimplemented from RotaryEncoder.