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

#include <JoystickSwitchInput.h>

Inheritance diagram for JoystickSwitchInput:
RotaryEncoder

Public Member Functions

 JoystickSwitchInput (AnalogDevice *analogDevice, pinid_t analogPin, EncoderCallbackFn callback)
 
 JoystickSwitchInput (AnalogDevice *analogDevice, pinid_t analogPin, EncoderListener *listener)
 
void setAccelerationParameters (float initialDelayPeriod, float decreaseDivisor)
 
void setTolerance (float midPoint_, float tolerance_)
 
int nextInterval (int forceApplied)
 
void exec () 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 ()
 

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

This class provides encoder functionality based on an analog joystick. Where up and down increase and reduce the value proportionally to how far down they are pressed.

Normally prefer to create an instance using setupAnalogJoystickEncoder in this case there is nothing else to do.

Advanced usages: If you prefer to construct yourself, or want to use more than one encoder, then ensure that you create a task that runs once every 500millis and calls exec.

Constructor & Destructor Documentation

◆ JoystickSwitchInput() [1/2]

JoystickSwitchInput::JoystickSwitchInput ( AnalogDevice analogDevice,
pinid_t  analogPin,
EncoderCallbackFn  callback 
)
inline

Constructor that initialises the class for use, prefer to use the set up method setupAnalogJoystickEncoder in simple cases.

Parameters
analogDevicethe pointer to the analog AnalogDevice for example: &analog
analogPinthe pin on which the joystick analog pin is connected to
callbackthe callback to provide updates to when the value changes.

◆ JoystickSwitchInput() [2/2]

JoystickSwitchInput::JoystickSwitchInput ( AnalogDevice analogDevice,
pinid_t  analogPin,
EncoderListener listener 
)
inline

Constructor that initialises the class for use, prefer to use the set up method setupAnalogJoystickEncoder in simple cases.

Parameters
analogDevicethe pointer to the analog AnalogDevice for example: &analog
analogPinthe pin on which the joystick analog pin is connected to
listenerthe OO listener class implementation extending from EncoderListener.

Member Function Documentation

◆ setAccelerationParameters()

void JoystickSwitchInput::setAccelerationParameters ( float  initialDelayPeriod,
float  decreaseDivisor 
)
inline

Provide alternative parameters for the initial repeat delay and the amount by which it divides downward toward the maximum speed for the amount the joystick is moved.

Parameters
initialDelayPeriod
decreaseDivisor

◆ setTolerance()

void JoystickSwitchInput::setTolerance ( float  midPoint_,
float  tolerance_ 
)
inline

Use this for situations where the tolerance of the joystick slightly off. IE the mid point is not exactly half or the tolerance is not sufficiently large to ignore deviations in the voltage level.

Parameters
midPoint_the new midpoint to use.
tolerance_the size change to ignore around midpoint.

◆ exec()

void JoystickSwitchInput::exec ( )
inlineoverride

Called by taskManager on a frequent basis. Ususally about every 250-500 millis


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