Mock touch screen input class using debounce and hold methods and calculating touch position to determine the "button" area of the screen that's been touched.
More...
#include <MockTouchScreenInput.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.
|
|
CallbackInterface * | _callback = nullptr |
| Pointer to the instance for callbacks Must implement updateScreen() and onInputAction() methods.
|
|
Logger * | _logger = nullptr |
| Pointer to the Logger instance for derived classes to use.
|
|
bool | _isCalibrating = false |
| Flag if the input interface is undergoing calibration - needed for touch screens.
|
|
int | _needsDisplay = -1 |
| Display ID if this input interface requires a display instance - needed for TFT_eSPI as it shares the instance.
|
|
DisplayInterface * | _display = nullptr |
| Pointer to the DisplayInterface if this input requires it.
|
|
unsigned long | _lastDebounceTime = 0 |
| Time of the last debounce.
|
|
unsigned long | _debounceDelay = 50 |
| Inputs must remain constant for this amount of time to be valid.
|
|
unsigned long | _holdThreshold = 500 |
| Inputs constant for longer than this threshold change from PRESS to HOLD.
|
|
InputAction | _lastAction = InputAction::PRESS_NONE |
| Set initial InputAction for comparisons in determining debounce or hold.
|
|
bool | _isHolding = false |
| Flag to help determining if input is held.
|
|
bool | _forceCalibration = false |
| Flag to force calibration for touch screens if it's required.
|
|
Mock touch screen input class using debounce and hold methods and calculating touch position to determine the "button" area of the screen that's been touched.
Use setTouch(int touchX, int touchY) and setScreenResolution(int width, int height) to set the screen dimensions and simulate user touches (default 320 x 240). Call setDebounceHold(bool debounceHold) to enable and disable debounce tests as well as touch position (default false). Call check() before/after time advances to test debounce and hold.
◆ check()
void MockTouchScreenInput::check |
( |
| ) |
|
|
inlineoverridevirtual |
Call this method at least once per main loop to monitor for input actions Any actions should call the callback set in the _callback attribute.
Implements InputInterface.
◆ MOCK_METHOD()
MockTouchScreenInput::MOCK_METHOD |
( |
void |
, |
|
|
begin |
, |
|
|
() |
, |
|
|
(override) |
|
|
) |
| |
◆ setDebounceHold()
void MockTouchScreenInput::setDebounceHold |
( |
bool |
debounceHold | ) |
|
|
inline |
◆ setIsCalibrating()
void MockTouchScreenInput::setIsCalibrating |
( |
bool |
isCalibrating | ) |
|
|
inline |
◆ setNeedsDisplay()
void MockTouchScreenInput::setNeedsDisplay |
( |
int |
displayId | ) |
|
|
inline |
◆ setScreenResolution()
void MockTouchScreenInput::setScreenResolution |
( |
int |
width, |
|
|
int |
height |
|
) |
| |
|
inline |
◆ setTouch()
void MockTouchScreenInput::setTouch |
( |
int |
touchX, |
|
|
int |
touchY |
|
) |
| |
|
inline |
◆ _debounceHold
bool MockTouchScreenInput::_debounceHold = false |
|
private |
◆ _screenHeight
int MockTouchScreenInput::_screenHeight = 240 |
|
private |
◆ _screenWidth
int MockTouchScreenInput::_screenWidth = 320 |
|
private |
◆ _touchX
int MockTouchScreenInput::_touchX = 0 |
|
private |
◆ _touchY
int MockTouchScreenInput::_touchY = 0 |
|
private |
The documentation for this class was generated from the following file: