IoAbstraction
Public Member Functions | Protected Member Functions | List of all members
EncoderUpDownButtons Class Reference

#include <SwitchInput.h>

Inheritance diagram for EncoderUpDownButtons:
RotaryEncoder SwitchListener

Public Member Functions

 EncoderUpDownButtons (pinid_t pinUp, pinid_t pinDown, EncoderCallbackFn callback, uint8_t speed=20)
 
 EncoderUpDownButtons (pinid_t pinUp, pinid_t pinDown, EncoderListener *listener, uint8_t speed=20)
 
 EncoderUpDownButtons (pinid_t pinUp, pinid_t pinDown, pinid_t pinBack, pinid_t pinNext, SwitchListener *passThrough, EncoderCallbackFn callback, uint8_t speed=20)
 
 EncoderUpDownButtons (pinid_t pinUp, pinid_t pinDown, pinid_t pinBack, pinid_t pinNext, SwitchListener *passThrough, EncoderListener *listener, uint8_t speed=20)
 
void onPressed (pinid_t pin, bool held) override
 
void onReleased (pinid_t pin, bool held) override
 
- 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)
 
virtual void encoderChanged ()
 
bool didLastSyncSucceed ()
 
void setUserIntention (EncoderUserIntention intention)
 
EncoderUserIntention getUserIntention ()
 
void runCallback (int newVal)
 
bsize_t getMaximumValue ()
 

Protected Member Functions

pinid_t getIncrementPin ()
 
pinid_t getDecrementPin ()
 
pinid_t getBackPin ()
 
pinid_t getNextPin ()
 

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 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 emulation of a rotary encoder using switches for up and down.

See also
setupUpDownButtonEncoder

Constructor & Destructor Documentation

◆ EncoderUpDownButtons() [1/4]

EncoderUpDownButtons::EncoderUpDownButtons ( pinid_t  pinUp,
pinid_t  pinDown,
EncoderCallbackFn  callback,
uint8_t  speed = 20 
)

Create an up down encoder based on two buttons, for up and down. This is a helper that wraps calls to switches and handles the up and down events. This version takes a function callback for change notification.

Parameters
pinUpthe pin to use for up
pinDownthe pin to use for down
callbackthe function callback when the encoder changes
speedthe speed of repeat functions on the keys

◆ EncoderUpDownButtons() [2/4]

EncoderUpDownButtons::EncoderUpDownButtons ( pinid_t  pinUp,
pinid_t  pinDown,
EncoderListener listener,
uint8_t  speed = 20 
)

Create an up down encoder based on two buttons, for up and down. This is a helper that wraps calls to switches and handles the up and down events. This version takes an OO listener for change notification.

Parameters
pinUpthe pin to use for up
pinDownthe pin to use for down
callbackthe function callback when the encoder changes
speedthe speed of repeat functions on the keys

◆ EncoderUpDownButtons() [3/4]

EncoderUpDownButtons::EncoderUpDownButtons ( pinid_t  pinUp,
pinid_t  pinDown,
pinid_t  pinBack,
pinid_t  pinNext,
SwitchListener passThrough,
EncoderCallbackFn  callback,
uint8_t  speed = 20 
)

Create an up down encoder based on two buttons, for up and down. This is a helper that wraps calls to switches and handles the up and down events. This version takes a function callback for change notification. Next and back are passed through to the passthrough callback so you can processes these commands. Calling the rotate meaning turns the encoder so that next and back function as up and down instead of the regular function keys. However, for the passthrough callback the original next and back pin numbers are sent, so outside of the encoder, no extra logic is needed.

Parameters
pinUpthe pin to use for up
pinDownthe pin to use for down
pinBackthe pin to use for back
pinNextthe pin to use for next
passThroughthe passthrough listener on which this class will convey next and back key presses
callbackthe function callback when the encoder changes
speedthe speed of repeat functions on the keys

◆ EncoderUpDownButtons() [4/4]

EncoderUpDownButtons::EncoderUpDownButtons ( pinid_t  pinUp,
pinid_t  pinDown,
pinid_t  pinBack,
pinid_t  pinNext,
SwitchListener passThrough,
EncoderListener listener,
uint8_t  speed = 20 
)

Create an up down encoder based on four buttons, for up and down. This is a helper that wraps calls to switches and handles the up and down events. This version takes an OO listener for change notification. The next and back are passed through to the passthrough callback so you can processes these commands. Calling the rotate meaning turns the encoder so that next and back function as up and down instead of the regular function keys. However, for the passthrough callback the original next and back pin numbers are sent, so outside of the encoder, no extra logic is needed.

Parameters
pinUpthe pin to use for up
pinDownthe pin to use for down
pinBackthe pin to use for back
pinNextthe pin to use for next
passThroughthe passthrough listener on which this class will convey next and back key presses
listenerthe OO interface implementation for when encoder changes
speedthe speed of repeat functions on the keys

Member Function Documentation

◆ onPressed()

void EncoderUpDownButtons::onPressed ( pinid_t  pin,
bool  held 
)
overridevirtual

called when a key is pressed or held down

Parameters
pinthe pin number
heldtrue if held down

Implements SwitchListener.

◆ onReleased()

void EncoderUpDownButtons::onReleased ( pinid_t  pin,
bool  held 
)
overridevirtual

called when a key is released

Parameters
pinthe key number
heldtrue if key was held down

Implements SwitchListener.


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