EX-Display
EX-Display
Loading...
Searching...
No Matches
TFT_eSPITouch Class Reference

Display class for TFT_eSPI touch screens. More...

#include <TFT_eSPITouch.h>

Inheritance diagram for TFT_eSPITouch:
[legend]
Collaboration diagram for TFT_eSPITouch:
[legend]

Public Member Functions

 TFT_eSPITouch (int displayId)
 Constructor for the TFT_eSPITouch instance.
 
void begin () override
 Perform any initial once off setup or configuration here and call only once.
 
void check () override
 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.
 
- Public Member Functions inherited from InputInterface
void setCallback (CallbackInterface *callback)
 Set the instance for callbacks when users trigger an input action.
 
void setLogger (Logger *logger)
 Set the logger instance to use for diagnostic logging.
 
bool isCalibrating ()
 Test if this InputInterface is undergoing calibration as required by touch screens.
 
int needsDisplay ()
 Test if this InputInterface requires a display instance - needed for TFT_eSPI as it shares the instance.
 
void setDisplay (DisplayInterface *display)
 Set the DisplayInterface for this input if required.
 
void setDebounceDelay (unsigned long delay)
 Set the debounce delay.
 
void setHoldThreshold (unsigned long threshold)
 Set the threshold for detecting an input is held.
 
void forceCalibration ()
 Force a touch screen into calibration mode, even if existing calibration is valid.
 
virtual ~InputInterface ()=default
 Destructor for an InputInterface.
 

Static Public Member Functions

static TFT_eSPITouchcreate (int displayId)
 Static method to enable the compiler to generate create commands from myDevices.h entries.
 

Private Member Functions

bool _calibrated ()
 Test if valid calibration data is available for this touch interface.
 
bool _doCalibration ()
 Run the TFT_eSPI calibration sequence.
 
bool _setupSPIFFS ()
 Ensure SPIFFS filesystem is up and running.
 
void _displayCalibrationError (TFT_eSPIDisplay *display)
 Display calibration error on screen and pause for 5 seconds.
 

Private Attributes

TFT_eSPI * _tft
 
const char _calibrationFile [20]
 

Additional Inherited Members

- Protected Member Functions inherited from InputInterface
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.
 
- Protected Attributes inherited from InputInterface
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.
 

Detailed Description

Display class for TFT_eSPI touch screens.

Constructor & Destructor Documentation

◆ TFT_eSPITouch()

TFT_eSPITouch::TFT_eSPITouch ( int  displayId)

Constructor for the TFT_eSPITouch instance.

Parameters
displayIdID of the display to retrieve the TFT_eSPI instance from

Member Function Documentation

◆ _calibrated()

bool TFT_eSPITouch::_calibrated ( )
private

Test if valid calibration data is available for this touch interface.

Returns
true|false
Here is the caller graph for this function:

◆ _displayCalibrationError()

void TFT_eSPITouch::_displayCalibrationError ( TFT_eSPIDisplay display)
private

Display calibration error on screen and pause for 5 seconds.

Parameters
displayPointer to the TFT_eSPIDisplay instance to use
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _doCalibration()

bool TFT_eSPITouch::_doCalibration ( )
private

Run the TFT_eSPI calibration sequence.

Returns
true if successful and saved, otherwise false
Here is the caller graph for this function:

◆ _setupSPIFFS()

bool TFT_eSPITouch::_setupSPIFFS ( )
private

Ensure SPIFFS filesystem is up and running.

Returns
true|false
Here is the call graph for this function:
Here is the caller graph for this function:

◆ begin()

void TFT_eSPITouch::begin ( )
overridevirtual

Perform any initial once off setup or configuration here and call only once.

Implements InputInterface.

Here is the call graph for this function:

◆ check()

void TFT_eSPITouch::check ( )
overridevirtual

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.

Here is the call graph for this function:

◆ create()

TFT_eSPITouch * TFT_eSPITouch::create ( int  displayId)
static

Static method to enable the compiler to generate create commands from myDevices.h entries.

Parameters
displayIdID of the display to retrieve the TFT_eSPI instance from
Returns
Pointer to the new TFT_eSPITouch instance

Member Data Documentation

◆ _calibrationFile

const char TFT_eSPITouch::_calibrationFile[20]
private

◆ _tft

TFT_eSPI* TFT_eSPITouch::_tft
private

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