10#ifndef EVENT_JOYSTICK_H
11#define EVENT_JOYSTICK_H
14#include "EventAnalog.h"
32 #if defined(FUNCTIONAL_SUPPORTED)
76 EventJoystick(
byte analogX,
byte analogY, uint8_t adcBits=10);
116 #if defined(FUNCTIONAL_SUPPORTED)
118 template <
typename T>
122 (instance->*method)(et, ie);
300#ifndef FUNCTIONAL_SUPPORTED
The EventAnalog class is for analog inputs - slice an analog range into configurable number of increm...
Definition: EventAnalog.h:30
The EventJoystick class contains two EventAnalog inputs configured as a joystick.
Definition: EventJoystick.h:28
EventAnalog x
The EventAnalog for the X axis.
Definition: EventJoystick.h:152
void begin()
Initialise the EventButton.
Definition: EventJoystick.cpp:26
void enableAutoCalibrate(bool allow=true)
If enableAutoCalibrate is set to true (the default), will do auto calibration, setting the minValue a...
Definition: EventJoystick.cpp:109
void onDisabled() override
Can be ovrriden by derived classes but base method must be called.
Definition: EventJoystick.cpp:138
CallbackFunction callbackFunction
The callback function member.
Definition: EventJoystick.h:47
void setNumIncrements(uint8_t numIncr=10)
Split the analog range into this number of slices. The default is 10.
Definition: EventJoystick.cpp:77
std::function< void(InputEventType et, EventJoystick &ie)> CallbackFunction
If std::function is supported, this creates the callback type.
Definition: EventJoystick.h:36
void onEnabled() override
Can be ovrriden by derived classes but base method must be called.
Definition: EventJoystick.cpp:132
void unsetCallback() override
Unset a previously set callback function or method.
Definition: EventJoystick.cpp:60
void setOuterBoundary(uint16_t width=100)
Used to allow maximum increments to be reached 'on the diagonal'.
Definition: EventJoystick.cpp:97
EventJoystick(byte analogX, byte analogY, uint8_t adcBits=10)
Construct anEventJoystick input.
Definition: EventJoystick.cpp:13
void onInputYCallback(InputEventType et, EventInputBase &ie)
Definition: EventJoystick.cpp:52
bool isIdle()
Return true if no activity on both EventAnalog axis for longer than setIdleTimeout() - irrespective o...
Definition: EventJoystick.cpp:115
void setNumNegativeIncrements(uint8_t numIncr=10)
Normally increments are set with setNumIncrements() but you can also set the negative and positive si...
Definition: EventJoystick.cpp:82
EventAnalog y
The EventAnalog for the Y axis.
Definition: EventJoystick.h:157
void onInputCallback(InputEventType et, EventInputBase &ie)
Definition: EventJoystick.cpp:34
void setCallback(T *instance, void(T::*method)(InputEventType, EventJoystick &))
Set the Callback function to a class method.
Definition: EventJoystick.h:119
void setCentreBoundary(uint16_t width=200)
Used to create a central 'dead zone' on the joystick.
Definition: EventJoystick.cpp:92
bool isEnabled()
Returns true if enabled (or if either of the EventAnalg axis are enabled)
Definition: EventJoystick.cpp:107
void setRateLimit(uint16_t ms)
Limit the rate at which events are fired.
Definition: EventJoystick.cpp:120
void setStartValues()
Will set the X and Y start values as the current position.
Definition: EventJoystick.cpp:71
void setNumPositiveIncrements(uint8_t numIncr=10)
Normally increments are set with setNumIncrements() but you can also set the negative and positive si...
Definition: EventJoystick.cpp:87
void update()
Update the state from both X and Y pin inputs.
Definition: EventJoystick.cpp:65
void setCallback(CallbackFunction f)
Set the Callback function.
Definition: EventJoystick.h:102
void onIdle() override
Can be ovrriden by derived classes but base method must be called.
Definition: EventJoystick.h:58
bool hasChanged()
Returns true of the position of either EventAnalog axis has changed since previous update()
Definition: EventJoystick.cpp:102
void invoke(InputEventType et) override
Override of the EventInputBase::invoke() virtual method.
Definition: EventJoystick.cpp:126
void onInputXCallback(InputEventType et, EventInputBase &ie)
Definition: EventJoystick.cpp:44