IoAbstraction
Public Member Functions | List of all members
HwStateRotaryEncoder Class Reference

#include <SwitchInput.h>

Inheritance diagram for HwStateRotaryEncoder:
AbstractHwRotaryEncoder RotaryEncoder

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
 
EncoderListenerencoderListener
 
notify
 
uint8_t flags
 
EncoderUserIntention intent
 

Detailed Description

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.

See also
setupRotaryEncoderWithInterrupt

Constructor & Destructor Documentation

◆ HwStateRotaryEncoder() [1/2]

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.

Parameters
pinAthe A pin of the encoder
pinBthe B pin of the encoder
callbackthe function callback to be called when triggered
accelerationModethe amount of acceleration to use

◆ HwStateRotaryEncoder() [2/2]

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.

Parameters
pinAthe A pin of the encoder
pinBthe B pin of the encoder
listenerthe OO listener extending from EncoderListener
accelerationModethe amount of acceleration to use

Member Function Documentation

◆ encoderChanged()

void HwStateRotaryEncoder::encoderChanged ( )
overridevirtual

internal method not for external use..

Reimplemented from RotaryEncoder.


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