Class to abstract away all physical input implementatio to enable multiple input types Default return should be PRESS_NONE.
More...
#include <InputInterface.h>
|
InputAction | _debounceOrHeld (InputAction currentAction) |
| Call this from the derived class' check() method to debounce and detect if the input is a hold vs. press.
|
|
InputAction | _calculateInputAction (int touchX, int touchY, int displayWidth, int displayHeight) |
| This method is designed to take an input from a touch screen display and determine which "button" has been touched according to the coordinates of the touch. This assumes the touch screen has been calibrated correctly.
|
|
Class to abstract away all physical input implementatio to enable multiple input types Default return should be PRESS_NONE.
◆ ~InputInterface()
virtual InputInterface::~InputInterface |
( |
| ) |
|
|
virtualdefault |
◆ _calculateInputAction()
InputAction InputInterface::_calculateInputAction |
( |
int |
touchX, |
|
|
int |
touchY, |
|
|
int |
displayWidth, |
|
|
int |
displayHeight |
|
) |
| |
|
protected |
This method is designed to take an input from a touch screen display and determine which "button" has been touched according to the coordinates of the touch. This assumes the touch screen has been calibrated correctly.
The display is divided as such:
- The entire left third of the display is the left button
- The entire right third of the display is the right button
- The top third of the resulting centre of the display is the up button
- The bottom third of the resulting centre of the display is the down button
- The centre third of both width and height is the centre button
- Parameters
-
touchX | The X coordinate of the touch |
touchY | The Y coordinate of the touch |
displayWidth | Display width in pixels |
displayHeight | Display height in pixels |
- Returns
- A valid InputAction PRESS type
◆ _debounceOrHeld()
Call this from the derived class' check() method to debounce and detect if the input is a hold vs. press.
- Parameters
-
currentAction | The InputAction needing to be interpreted |
- Returns
- Determined InputAction - either debounced press, held, or none
◆ begin()
virtual void InputInterface::begin |
( |
| ) |
|
|
pure virtual |
Perform any initial once off setup or configuration here and call only once.
Implemented in TFT_eSPITouch.
◆ check()
virtual void InputInterface::check |
( |
| ) |
|
|
pure virtual |
◆ forceCalibration()
void InputInterface::forceCalibration |
( |
| ) |
|
Force a touch screen into calibration mode, even if existing calibration is valid.
◆ isCalibrating()
bool InputInterface::isCalibrating |
( |
| ) |
|
Test if this InputInterface is undergoing calibration as required by touch screens.
- Returns
- true|false
◆ needsDisplay()
int InputInterface::needsDisplay |
( |
| ) |
|
Test if this InputInterface requires a display instance - needed for TFT_eSPI as it shares the instance.
- Returns
- Display ID of the required display - -1 if not required
◆ setCallback()
Set the instance for callbacks when users trigger an input action.
- Parameters
-
callback | Class instance derived from the CallbackInterface class Must call the method onInputAction(InputAction); |
◆ setDebounceDelay()
void InputInterface::setDebounceDelay |
( |
unsigned long |
delay | ) |
|
Set the debounce delay.
- Parameters
-
delay | Debounce delay in milliseconds (default 50ms) |
◆ setDisplay()
◆ setHoldThreshold()
void InputInterface::setHoldThreshold |
( |
unsigned long |
threshold | ) |
|
Set the threshold for detecting an input is held.
- Parameters
-
threshold | Threshold in milliseconds (default 500ms) |
◆ setLogger()
void InputInterface::setLogger |
( |
Logger * |
logger | ) |
|
Set the logger instance to use for diagnostic logging.
- Parameters
-
logger | Pointer to the Logger instance to use |
◆ _callback
Pointer to the instance for callbacks Must implement updateScreen() and onInputAction() methods.
◆ _debounceDelay
unsigned long InputInterface::_debounceDelay = 50 |
|
protected |
Inputs must remain constant for this amount of time to be valid.
◆ _display
◆ _forceCalibration
bool InputInterface::_forceCalibration = false |
|
protected |
Flag to force calibration for touch screens if it's required.
◆ _holdThreshold
unsigned long InputInterface::_holdThreshold = 500 |
|
protected |
Inputs constant for longer than this threshold change from PRESS to HOLD.
◆ _isCalibrating
bool InputInterface::_isCalibrating = false |
|
protected |
Flag if the input interface is undergoing calibration - needed for touch screens.
◆ _isHolding
bool InputInterface::_isHolding = false |
|
protected |
Flag to help determining if input is held.
◆ _lastAction
Set initial InputAction for comparisons in determining debounce or hold.
◆ _lastDebounceTime
unsigned long InputInterface::_lastDebounceTime = 0 |
|
protected |
Time of the last debounce.
◆ _logger
Logger* InputInterface::_logger = nullptr |
|
protected |
Pointer to the Logger instance for derived classes to use.
◆ _needsDisplay
int InputInterface::_needsDisplay = -1 |
|
protected |
Display ID if this input interface requires a display instance - needed for TFT_eSPI as it shares the instance.
The documentation for this class was generated from the following files: