SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
TouchDrvInterface Class Referenceabstract

Abstract base class for touch screen drivers. More...

#include <TouchDrvInterface.hpp>

Inheritance diagram for TouchDrvInterface:
[legend]

Classes

struct  TouchConfig
 
struct  TouchPinsCfg
 

Public Types

using HomeButtonCallback = void(*)(void *user_data)
 Callback type for home button events.
 

Public Member Functions

 TouchDrvInterface ()
 Construct a new TouchDrvInterface object.
 
virtual ~TouchDrvInterface ()=default
 Destroy the TouchDrvInterface object.
 
virtual bool begin (SensorCommCustom::CustomCallback callback, SensorCommCustomHal::CustomHalCallback hal_callback, uint8_t addr)
 Initialize the touch driver with custom communication callbacks.
 
virtual void setGpioCallback (SensorHalCustom::CustomMode mode_cb, SensorHalCustom::CustomWrite write_cb, SensorHalCustom::CustomRead read_cb)
 Set custom GPIO callbacks for pin control (e.g., reset, interrupt).
 
virtual uint8_t getSupportTouchPoint ()
 Get the maximum number of touch points supported by the hardware.
 
virtual void getResolution (uint16_t &x, uint16_t &y)
 Get the raw resolution (maximum coordinate values) of the touch panel.
 
virtual uint16_t getResolutionX ()
 Get the raw maximum X coordinate of the touch panel.
 
virtual uint16_t getResolutionY ()
 Get the raw maximum Y coordinate of the touch panel.
 
virtual bool initImpl (uint8_t param)=0
 Device-specific initialization implementation (pure virtual).
 
virtual void reset ()
 Reset the touch controller.
 
virtual void sleep ()=0
 Put the touch controller into low-power sleep mode (pure virtual).
 
virtual void wakeup ()
 Wake the touch controller from sleep mode (pure virtual).
 
virtual uint8_t getPoint (int16_t *x_array, int16_t *y_array, uint8_t get_point=1) __attribute__((deprecated("use getTouchPoints instead of getPoint")))
 Retrieve touch point coordinates (deprecated).
 
virtual const TouchPointsgetTouchPoints ()=0
 Get the current touch points (pure virtual).
 
virtual bool isPressed (uint32_t filter_ms=0)
 Check if any touch point is currently pressed.
 
virtual const char * getModelName ()=0
 Get the human-readable model name of the touch controller.
 
virtual uint32_t getChipID ()
 Get the chip identifier (e.g., ID register value).
 
virtual void setPins (int rst, int irq)
 Set the hardware reset and interrupt pin numbers.
 
virtual const TouchPinsCfggetTouchPinsCfg () const
 Get the current touch pins configuration.
 
virtual void setSwapXY (bool swap)
 Enable or disable swapping of X and Y coordinates.
 
virtual bool isSwapXY () const
 Check if X and Y coordinates are swapped.
 
virtual void setMirrorXY (bool mirrorX, bool mirrorY)
 Enable or disable mirroring of X and/or Y coordinates.
 
virtual bool isMirrorX () const
 Check if X coordinates are mirrored.
 
virtual bool isMirrorY () const
 Check if Y coordinates are mirrored.
 
virtual void setMaxCoordinates (uint16_t x, uint16_t y)
 Set the maximum coordinate values used for mirroring.
 
virtual void getMaxCoordinates (uint16_t &x, uint16_t &y)
 Get the maximum coordinates used for mirroring.
 
virtual uint16_t getMaxX ()
 Get the maximum X coordinate (e.g., display width).
 
virtual uint16_t getMaxY ()
 Get the maximum Y coordinate (e.g., display height).
 
virtual bool isScalingEnabled ()
 Check if coordinate scaling is enabled.
 
virtual void setResolution (uint16_t width, uint16_t height)
 Set the raw resolution of the touch panel (physical maximum coordinates).
 
virtual void setTargetResolution (uint16_t width, uint16_t height)
 Set the target display resolution to map touch coordinates to screen pixels.
 
virtual void updateXY (TouchPoints &points) const
 Apply coordinate transformations (swap, scale, mirror) to all touch points.
 
virtual void setHomeButtonCallback (HomeButtonCallback cb, void *user_data)
 Register a callback for home button events.
 
virtual void setCenterButtonCoordinate (int16_t x, int16_t y)
 Set the expected screen coordinates of a hardware home button.
 
- Public Member Functions inherited from I2CDeviceWithHal
bool begin (SensorCommCustom::CustomCallback cb, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
 Initialize the sensor using custom callback interface.
 
- Public Member Functions inherited from DeviceBeginCommon
virtual ~DeviceBeginCommon ()
 
uint8_t getAddress () const
 
uint8_t getInterface () const
 
- Public Member Functions inherited from SensorCommWrapper
 SensorCommWrapper ()=default
 
int readReg (uint8_t reg) const
 
int readRegBuff (uint8_t reg, uint8_t *buf, size_t len) const
 
int readBuff (uint8_t *buf, size_t len) const
 
int writeReg (uint8_t reg, uint8_t val)
 
int writeRegBuff (uint8_t reg, uint8_t *buf, size_t len)
 
int writeBuff (uint8_t *buf, size_t len)
 
int writeThenRead (const uint8_t *write_buffer, size_t write_len, uint8_t *read_buffer, size_t read_len)
 
bool setRegBit (uint8_t reg, uint8_t bit)
 
bool clrRegBit (uint8_t reg, uint8_t bit)
 
bool getRegBit (uint8_t reg, uint8_t bit)
 
int updateBits (uint8_t reg, uint8_t mask, uint8_t value_shifted)
 
void setAddress (uint8_t address)
 
void setAck (bool enable)
 
- Public Member Functions inherited from SensorCommInterface
virtual ~SensorCommInterface ()=default
 

Protected Attributes

SensorHalCustom::CustomMode _halModeCallback
 Custom GPIO mode callback.
 
SensorHalCustom::CustomWrite _halWriteCallback
 Custom GPIO write callback.
 
SensorHalCustom::CustomRead _halReadCallback
 Custom GPIO read callback.
 
uint32_t _chipID
 Chip identification value.
 
HomeButtonCallback _HButtonCallback
 Home button callback function.
 
void * _userData
 User data for home button callback.
 
uint8_t _maxTouchPoints
 Maximum supported touch points.
 
int16_t _center_btn_x
 X coordinate of home button center.
 
int16_t _center_btn_y
 Y coordinate of home button center.
 
uint32_t _lastPulse
 Timestamp of the last touch event.
 
TouchPinsCfg _pinsCfg
 Configuration for reset and interrupt pins.
 
TouchConfig _touchConfig
 Configuration for coordinate transformations.
 
TouchPoints _touchPoints
 Touch points data.
 
- Protected Attributes inherited from DeviceBeginCommon
std::unique_ptr< SensorCommBasecomm
 
std::unique_ptr< SensorHalhal
 
std::unique_ptr< SensorCommStaticstaticComm
 
uint8_t _addr = 0
 
uint8_t _iface = COMM_CUSTOM
 

Additional Inherited Members

- Protected Member Functions inherited from I2CDeviceWithHal
bool ensureValid () const override
 Ensure the communication interface is valid.
 
- Protected Member Functions inherited from DeviceBeginCommon
 DeviceBeginCommon ()=default
 
virtual SensorCommBasegetComm () const override
 
virtual void beforeBegin ()
 
virtual void afterInitSuccess (uint8_t param)
 
virtual void onBeginFail ()
 
bool fail ()
 
void clearCommState ()
 
template<typename CreateComm >
bool beginLifecycle (uint8_t addr, uint8_t iface, uint8_t initParam, CreateComm createComm)
 

Detailed Description

Abstract base class for touch screen drivers.

This class provides a common interface for initializing, configuring, and reading touch data from various touch controller chips. It also handles coordinate transformations (swap, mirror, scaling) and optional home button callbacks.

Definition at line 46 of file touch/TouchDrvInterface.hpp.

Member Typedef Documentation

◆ HomeButtonCallback

using TouchDrvInterface::HomeButtonCallback = void(*)(void *user_data)

Callback type for home button events.

Parameters
user_dataPointer to user-defined data passed during callback registration.

Definition at line 76 of file touch/TouchDrvInterface.hpp.

Constructor & Destructor Documentation

◆ TouchDrvInterface()

TouchDrvInterface::TouchDrvInterface ( )
inline

Construct a new TouchDrvInterface object.

Initializes member variables to default values. Does not allocate any hardware resources.

Definition at line 84 of file touch/TouchDrvInterface.hpp.

◆ ~TouchDrvInterface()

virtual TouchDrvInterface::~TouchDrvInterface ( )
virtualdefault

Destroy the TouchDrvInterface object.

Deinitializes the communication interface if it was created.

References I2CDeviceWithHal::begin().

Member Function Documentation

◆ begin()

virtual bool TouchDrvInterface::begin ( SensorCommCustom::CustomCallback  callback,
SensorCommCustomHal::CustomHalCallback  hal_callback,
uint8_t  addr 
)
inlinevirtual

Initialize the touch driver with custom communication callbacks.

Use this method when you need to provide your own low-level I2C/SPI-like communication functions (e.g., for non-standard buses or simulated interfaces).

Parameters
callbackCustom callback for basic communication operations.
hal_callbackCustom callback for hardware abstraction layer (GPIO) operations.
addrI2C slave address (ignored if not applicable).
Return values
trueInitialization successful.
falseInitialization failed.

Reimplemented in TouchDrvCSTXXX.

Definition at line 166 of file touch/TouchDrvInterface.hpp.

References I2CDeviceWithHal::begin(), and hal_callback().

Referenced by beginPower(), setup(), and setupTouchDrv().

◆ getChipID()

virtual uint32_t TouchDrvInterface::getChipID ( )
inlinevirtual

Get the chip identifier (e.g., ID register value).

Returns
uint32_t Chip ID.

Reimplemented in TouchDrvCSTXXX, and TouchDrvGT911.

Definition at line 353 of file touch/TouchDrvInterface.hpp.

References _chipID.

Referenced by setup().

◆ getMaxCoordinates()

virtual void TouchDrvInterface::getMaxCoordinates ( uint16_t &  x,
uint16_t &  y 
)
inlinevirtual

Get the maximum coordinates used for mirroring.

Parameters
&xReference to store the maximum X coordinate.
&yReference to store the maximum Y coordinate.
Return values
None

Definition at line 443 of file touch/TouchDrvInterface.hpp.

References _touchConfig, x, TouchDrvInterface::TouchConfig::xMax, y, and TouchDrvInterface::TouchConfig::yMax.

◆ getMaxX()

virtual uint16_t TouchDrvInterface::getMaxX ( )
inlinevirtual

Get the maximum X coordinate (e.g., display width).

Note

Return values
MaximumX coordinate.

Definition at line 453 of file touch/TouchDrvInterface.hpp.

References _touchConfig, and TouchDrvInterface::TouchConfig::xMax.

◆ getMaxY()

virtual uint16_t TouchDrvInterface::getMaxY ( )
inlinevirtual

Get the maximum Y coordinate (e.g., display height).

Return values
MaximumY coordinate.

Definition at line 459 of file touch/TouchDrvInterface.hpp.

References _touchConfig, and TouchDrvInterface::TouchConfig::yMax.

◆ getModelName()

virtual const char * TouchDrvInterface::getModelName ( )
pure virtual

Get the human-readable model name of the touch controller.

Returns
const char* String describing the chip model (e.g., "FT6336").

Implemented in TouchDrvCHSC5816, TouchDrvCST226, TouchDrvCST3530, TouchDrvCST816, TouchDrvCST92xx, TouchDrvCSTXXX, TouchDrvFT6X36, TouchDrvGT911, TouchDrvGT9895, and TouchDrvHI8561.

Referenced by setupTouchDrv().

◆ getPoint()

virtual uint8_t TouchDrvInterface::getPoint ( int16_t *  x_array,
int16_t *  y_array,
uint8_t  get_point = 1 
)
inlinevirtual

Retrieve touch point coordinates (deprecated).

Deprecated:
Use getTouchPoints() instead, which returns a richer TouchPoints object.
Parameters
[out]x_arrayPointer to array to store X coordinates.
[out]y_arrayPointer to array to store Y coordinates.
get_pointNumber of points to retrieve (max).
Returns
uint8_t Actual number of touch points detected.

Reimplemented in TouchDrvCST226, TouchDrvCST3530, TouchDrvCST816, TouchDrvCST92xx, TouchDrvFT6X36, TouchDrvGT911, and TouchDrvGT9895.

Definition at line 288 of file touch/TouchDrvInterface.hpp.

References TouchPoints::getPoint(), TouchPoints::getPointCount(), getTouchPoints(), TouchPoints::hasPoints(), i, TouchPoint::x, and TouchPoint::y.

◆ getResolution()

virtual void TouchDrvInterface::getResolution ( uint16_t &  x,
uint16_t &  y 
)
inlinevirtual

Get the raw resolution (maximum coordinate values) of the touch panel.

Parameters
[out]xReference to store the maximum X coordinate.
[out]yReference to store the maximum Y coordinate.

Reimplemented in TouchDrvCSTXXX.

Definition at line 206 of file touch/TouchDrvInterface.hpp.

References _touchConfig, TouchDrvInterface::TouchConfig::resolutionX, TouchDrvInterface::TouchConfig::resolutionY, x, and y.

◆ getResolutionX()

virtual uint16_t TouchDrvInterface::getResolutionX ( )
inlinevirtual

Get the raw maximum X coordinate of the touch panel.

Returns
uint16_t Maximum X coordinate.

Reimplemented in TouchDrvCSTXXX.

Definition at line 216 of file touch/TouchDrvInterface.hpp.

References _touchConfig, and TouchDrvInterface::TouchConfig::resolutionX.

Referenced by setup().

◆ getResolutionY()

virtual uint16_t TouchDrvInterface::getResolutionY ( )
inlinevirtual

Get the raw maximum Y coordinate of the touch panel.

Returns
uint16_t Maximum Y coordinate.

Reimplemented in TouchDrvCSTXXX.

Definition at line 225 of file touch/TouchDrvInterface.hpp.

References _touchConfig, and TouchDrvInterface::TouchConfig::resolutionY.

Referenced by setup().

◆ getSupportTouchPoint()

virtual uint8_t TouchDrvInterface::getSupportTouchPoint ( )
inlinevirtual

Get the maximum number of touch points supported by the hardware.

Returns
uint8_t Maximum number of simultaneous touches.

Reimplemented in TouchDrvCSTXXX.

Definition at line 196 of file touch/TouchDrvInterface.hpp.

References _maxTouchPoints.

Referenced by setup().

◆ getTouchPinsCfg()

virtual const TouchPinsCfg & TouchDrvInterface::getTouchPinsCfg ( ) const
inlinevirtual

Get the current touch pins configuration.

Returns
const TouchPinsCfg& Reference to the touch pins configuration.

Definition at line 376 of file touch/TouchDrvInterface.hpp.

References _pinsCfg.

◆ getTouchPoints()

virtual const TouchPoints & TouchDrvInterface::getTouchPoints ( )
pure virtual

Get the current touch points (pure virtual).

Returns
const TouchPoints& Reference to an object containing all detected touch points, their coordinates, and additional metadata.

Implemented in TouchDrvCHSC5816, TouchDrvCST226, TouchDrvCST3530, TouchDrvCST816, TouchDrvCST92xx, TouchDrvCSTXXX, TouchDrvFT6X36, TouchDrvGT911, TouchDrvGT9895, and TouchDrvHI8561.

Referenced by getPoint(), isPressed(), and loop().

◆ initImpl()

virtual bool TouchDrvInterface::initImpl ( uint8_t  param)
pure virtual

Device-specific initialization implementation (pure virtual).

This method must be implemented by derived classes to perform hardware-specific initialization, such as reading chip ID, configuring registers, and setting up default behavior.

Parameters
paramReserved parameters for future use (e.g., I2C address, configuration flags).
Return values
trueInitialization successful.
falseInitialization failed.

Implements DeviceBeginCommon.

◆ isMirrorX()

virtual bool TouchDrvInterface::isMirrorX ( ) const
inlinevirtual

Check if X coordinates are mirrored.

Returns
true if X is mirrored, false otherwise.

Definition at line 413 of file touch/TouchDrvInterface.hpp.

References _touchConfig, and TouchDrvInterface::TouchConfig::mirrorX.

◆ isMirrorY()

virtual bool TouchDrvInterface::isMirrorY ( ) const
inlinevirtual

Check if Y coordinates are mirrored.

Returns
true if Y is mirrored, false otherwise.

Definition at line 420 of file touch/TouchDrvInterface.hpp.

References _touchConfig, and TouchDrvInterface::TouchConfig::mirrorY.

◆ isPressed()

virtual bool TouchDrvInterface::isPressed ( uint32_t  filter_ms = 0)
inlinevirtual

Check if any touch point is currently pressed.

Note
The isPressed method is suitable for screens with an interrupt pin connected, using the interrupt level to detect whether a touch is pressed. For devices without an interrupt pin connected, simply call getTouchPoints.
Parameters
filter_msOptional debounce/filter time in milliseconds. If > 0, the function will only return true if a touch has been detected continuously for at least this duration.
Return values
trueAt least one touch point detected.
falseNo touch detected.

Reimplemented in TouchDrvCSTXXX.

Definition at line 323 of file touch/TouchDrvInterface.hpp.

References _lastPulse, _pinsCfg, getTouchPoints(), DeviceBeginCommon::hal, TouchPoints::hasPoints(), TouchDrvInterface::TouchPinsCfg::irqPin, and TouchDrvInterface::TouchPinsCfg::irqTriggerLevel.

Referenced by loop().

◆ isScalingEnabled()

virtual bool TouchDrvInterface::isScalingEnabled ( )
inlinevirtual

Check if coordinate scaling is enabled.

Return values
trueif scaling is enabled, false otherwise.

Definition at line 465 of file touch/TouchDrvInterface.hpp.

References _touchConfig, and TouchDrvInterface::TouchConfig::scalingEnabled.

◆ isSwapXY()

virtual bool TouchDrvInterface::isSwapXY ( ) const
inlinevirtual

Check if X and Y coordinates are swapped.

Returns
true if coordinates are swapped, false otherwise.

Definition at line 392 of file touch/TouchDrvInterface.hpp.

References _touchConfig, and TouchDrvInterface::TouchConfig::swapXY.

◆ reset()

virtual void TouchDrvInterface::reset ( )
inlinevirtual

◆ setCenterButtonCoordinate()

virtual void TouchDrvInterface::setCenterButtonCoordinate ( int16_t  x,
int16_t  y 
)
inlinevirtual

Set the expected screen coordinates of a hardware home button.

Note
This feature is hardware-dependent and not all touch panels support it. It's only available on specific hardware. Please refer to the sample program for your specific model for details.
Parameters
xX coordinate of the button center.
yY coordinate of the button center.

Reimplemented in TouchDrvCSTXXX.

Definition at line 586 of file touch/TouchDrvInterface.hpp.

References _center_btn_x, _center_btn_y, x, and y.

◆ setGpioCallback()

virtual void TouchDrvInterface::setGpioCallback ( SensorHalCustom::CustomMode  mode_cb,
SensorHalCustom::CustomWrite  write_cb,
SensorHalCustom::CustomRead  read_cb 
)
inlinevirtual

Set custom GPIO callbacks for pin control (e.g., reset, interrupt).

These callbacks will be used by the HAL to manipulate GPIO pins. Must be called before begin() if custom GPIO handling is required.

Parameters
mode_cbCallback to set pin mode (input/output).
write_cbCallback to write a digital value to a pin.
read_cbCallback to read a digital value from a pin.

Definition at line 183 of file touch/TouchDrvInterface.hpp.

References _halModeCallback, _halReadCallback, and _halWriteCallback.

Referenced by setupTouchDrv().

◆ setHomeButtonCallback()

virtual void TouchDrvInterface::setHomeButtonCallback ( HomeButtonCallback  cb,
void *  user_data 
)
inlinevirtual

Register a callback for home button events.

The callback will be invoked when a touch event occurs near the center button area (coordinates set via setCenterButtonCoordinate()).

Parameters
cbFunction pointer to the callback.
user_dataPointer to user-defined data passed to the callback.

Reimplemented in TouchDrvCSTXXX.

Definition at line 571 of file touch/TouchDrvInterface.hpp.

References _HButtonCallback, and _userData.

Referenced by setup().

◆ setMaxCoordinates()

virtual void TouchDrvInterface::setMaxCoordinates ( uint16_t  x,
uint16_t  y 
)
inlinevirtual

Set the maximum coordinate values used for mirroring.

These values define the reference range when mirroring is enabled. If you also use scaling, consider using setTargetResolution() instead, which automatically sets these maxima.

Parameters
xMaximum X coordinate (e.g., display width).
yMaximum Y coordinate (e.g., display height).

Reimplemented in TouchDrvCSTXXX.

Definition at line 432 of file touch/TouchDrvInterface.hpp.

References _touchConfig, x, TouchDrvInterface::TouchConfig::xMax, y, and TouchDrvInterface::TouchConfig::yMax.

◆ setMirrorXY()

virtual void TouchDrvInterface::setMirrorXY ( bool  mirrorX,
bool  mirrorY 
)
inlinevirtual

Enable or disable mirroring of X and/or Y coordinates.

Mirroring is applied after scaling, using the maximum coordinates set via setMaxCoordinates() or setTargetResolution().

Parameters
mirrorXtrue to mirror X (flip horizontally).
mirrorYtrue to mirror Y (flip vertically).

Reimplemented in TouchDrvCSTXXX.

Definition at line 403 of file touch/TouchDrvInterface.hpp.

References _touchConfig, TouchDrvInterface::TouchConfig::mirrorX, and TouchDrvInterface::TouchConfig::mirrorY.

◆ setPins()

virtual void TouchDrvInterface::setPins ( int  rst,
int  irq 
)
inlinevirtual

Set the hardware reset and interrupt pin numbers.

These pins will be used by the driver for hardware control. Must be called before begin() if the pins are connected.

Parameters
rstReset pin number (negative value if not used).
irqInterrupt pin number (negative value if not used).

Definition at line 366 of file touch/TouchDrvInterface.hpp.

References _pinsCfg, TouchDrvInterface::TouchPinsCfg::irqPin, and TouchDrvInterface::TouchPinsCfg::rstPin.

Referenced by setup(), setupTouchDrv(), and touch_drv_init().

◆ setResolution()

virtual void TouchDrvInterface::setResolution ( uint16_t  width,
uint16_t  height 
)
inlinevirtual

Set the raw resolution of the touch panel (physical maximum coordinates).

This should be called if the touch controller does not provide its resolution automatically. These values are used to compute scaling factors when setTargetResolution() is called.

Parameters
widthMaximum X coordinate reported by the touch controller.
heightMaximum Y coordinate reported by the touch controller.

Definition at line 476 of file touch/TouchDrvInterface.hpp.

References _touchConfig, TouchDrvInterface::TouchConfig::resolutionX, and TouchDrvInterface::TouchConfig::resolutionY.

◆ setSwapXY()

virtual void TouchDrvInterface::setSwapXY ( bool  swap)
inlinevirtual

Enable or disable swapping of X and Y coordinates.

Parameters
swaptrue to swap X and Y, false to keep original order.

Reimplemented in TouchDrvCSTXXX.

Definition at line 383 of file touch/TouchDrvInterface.hpp.

References _touchConfig, and TouchDrvInterface::TouchConfig::swapXY.

◆ setTargetResolution()

virtual void TouchDrvInterface::setTargetResolution ( uint16_t  width,
uint16_t  height 
)
inlinevirtual

Set the target display resolution to map touch coordinates to screen pixels.

This function calculates scaling factors based on the previously set raw resolution (via setResolution()). If raw resolution is not set (both zero), scaling is disabled. It also stores the target dimensions as maximum coordinates for mirroring.

Parameters
widthTarget display width in pixels.
heightTarget display height in pixels.

Definition at line 491 of file touch/TouchDrvInterface.hpp.

References _touchConfig, TouchDrvInterface::TouchConfig::resolutionX, TouchDrvInterface::TouchConfig::resolutionY, TouchDrvInterface::TouchConfig::scaleX, TouchDrvInterface::TouchConfig::scaleY, TouchDrvInterface::TouchConfig::scalingEnabled, TouchDrvInterface::TouchConfig::xMax, and TouchDrvInterface::TouchConfig::yMax.

◆ sleep()

virtual void TouchDrvInterface::sleep ( )
pure virtual

Put the touch controller into low-power sleep mode (pure virtual).

Note
If the device does not have a hardware reset pin connected, it may not be possible to wake it from sleep without power cycling.

Implemented in TouchDrvCHSC5816, TouchDrvCST226, TouchDrvCST3530, TouchDrvCST816, TouchDrvCST92xx, TouchDrvCSTXXX, TouchDrvFT6X36, TouchDrvGT911, TouchDrvGT9895, and TouchDrvHI8561.

◆ updateXY()

virtual void TouchDrvInterface::updateXY ( TouchPoints points) const
inlinevirtual

Apply coordinate transformations (swap, scale, mirror) to all touch points.

Transformations are applied in the following order:

  1. Swap X and Y (if _touchConfig.swapXY is true).
  2. Scale from raw to target resolution (if _touchConfig.scalingEnabled is true).
  3. Mirror X (if _touchConfig.mirrorX true) using _touchConfig.xMax as the maximum X value.
  4. Mirror Y (if _touchConfig.mirrorY true) using _touchConfig.yMax as the maximum Y value.
  5. Clamp coordinates to [0, _touchConfig.xMax] and [0, _touchConfig.yMax].
Parameters
pointsThe TouchPoints object to transform (modified in-place).

Definition at line 516 of file touch/TouchDrvInterface.hpp.

References _touchConfig, TouchPoints::getPoint(), TouchPoints::getPointCount(), i, TouchDrvInterface::TouchConfig::mirrorX, TouchDrvInterface::TouchConfig::mirrorY, TouchDrvInterface::TouchConfig::scaleX, TouchDrvInterface::TouchConfig::scaleY, TouchDrvInterface::TouchConfig::scalingEnabled, TouchDrvInterface::TouchConfig::swapXY, TouchPoint::x, TouchDrvInterface::TouchConfig::xMax, TouchPoint::y, and TouchDrvInterface::TouchConfig::yMax.

Referenced by TouchDrvCHSC5816::getTouchPoints(), TouchDrvCST226::getTouchPoints(), TouchDrvCST3530::getTouchPoints(), TouchDrvCST816::getTouchPoints(), TouchDrvCST92xx::getTouchPoints(), TouchDrvFT6X36::getTouchPoints(), TouchDrvGT911::getTouchPoints(), TouchDrvGT9895::getTouchPoints(), and TouchDrvHI8561::getTouchPoints().

◆ wakeup()

virtual void TouchDrvInterface::wakeup ( )
inlinevirtual

Wake the touch controller from sleep mode (pure virtual).

Note
Most touch devices cannot be woken up by commands when they are in deep sleep; they are usually woken up by pulling the reset button low. This method can be overridden by subclasses, and the default is to call the reset method.

Reimplemented in TouchDrvCST3530, TouchDrvCSTXXX, TouchDrvGT911, and TouchDrvGT9895.

Definition at line 273 of file touch/TouchDrvInterface.hpp.

References reset().

Member Data Documentation

◆ _center_btn_x

int16_t TouchDrvInterface::_center_btn_x
protected

X coordinate of home button center.

Definition at line 603 of file touch/TouchDrvInterface.hpp.

Referenced by TouchDrvCST816::getTouchPoints(), and setCenterButtonCoordinate().

◆ _center_btn_y

int16_t TouchDrvInterface::_center_btn_y
protected

Y coordinate of home button center.

Definition at line 604 of file touch/TouchDrvInterface.hpp.

Referenced by TouchDrvCST816::getTouchPoints(), and setCenterButtonCoordinate().

◆ _chipID

◆ _halModeCallback

SensorHalCustom::CustomMode TouchDrvInterface::_halModeCallback
protected

Custom GPIO mode callback.

Definition at line 595 of file touch/TouchDrvInterface.hpp.

Referenced by setGpioCallback().

◆ _halReadCallback

SensorHalCustom::CustomRead TouchDrvInterface::_halReadCallback
protected

Custom GPIO read callback.

Definition at line 597 of file touch/TouchDrvInterface.hpp.

Referenced by setGpioCallback().

◆ _halWriteCallback

SensorHalCustom::CustomWrite TouchDrvInterface::_halWriteCallback
protected

Custom GPIO write callback.

Definition at line 596 of file touch/TouchDrvInterface.hpp.

Referenced by setGpioCallback().

◆ _HButtonCallback

◆ _lastPulse

uint32_t TouchDrvInterface::_lastPulse
protected

Timestamp of the last touch event.

Definition at line 605 of file touch/TouchDrvInterface.hpp.

Referenced by isPressed().

◆ _maxTouchPoints

uint8_t TouchDrvInterface::_maxTouchPoints
protected

Maximum supported touch points.

Definition at line 602 of file touch/TouchDrvInterface.hpp.

Referenced by getSupportTouchPoint().

◆ _pinsCfg

◆ _touchConfig

◆ _touchPoints

◆ _userData


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