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

#include <SwitchInput.h>

Inheritance diagram for HardwareRotaryEncoder:
AbstractHwRotaryEncoder RotaryEncoder

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
 
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. 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.

See also
setupRotaryEncoderWithInterrupt

Constructor & Destructor Documentation

◆ HardwareRotaryEncoder() [1/2]

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.

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

◆ HardwareRotaryEncoder() [2/2]

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.

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 HardwareRotaryEncoder::encoderChanged ( )
overridevirtual

internal method not for external use..

Reimplemented from RotaryEncoder.


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