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

#include <TouchDrvCSTXXX.hpp>

Inheritance diagram for TouchDrvCSTXXX:
[legend]

Public Member Functions

 TouchDrvCSTXXX ()
 Constructor for the touch driver.
 
 ~TouchDrvCSTXXX ()=default
 Destructor for the touch driver.
 
void setTouchDrvModel (TouchDrvType model)
 Set the touch driver model.
 
bool begin (SensorCommCustom::CustomCallback callback, SensorCommCustomHal::CustomHalCallback hal_callback, uint8_t addr) override
 Initialize the touch driver for custom communication.
 
void reset () override
 Reset the touch driver.
 
void sleep () override
 Puts the touch driver to sleep.
 
void wakeup () override
 Wake up the touch driver.
 
const TouchPointsgetTouchPoints () override
 Get the touch points.
 
bool isPressed (uint32_t filter_ms=0) override
 Check if any touch point is currently pressed.
 
const char * getModelName () override
 Get the model name.
 
uint32_t getChipID () override
 Get the chip ID.
 
void setCenterButtonCoordinate (int16_t x, int16_t y) override
 Set the center button coordinate.
 
void setHomeButtonCallback (TouchDrvInterface::HomeButtonCallback callback, void *user_data=NULL) override
 Set the home button callback.
 
void disableAutoSleep ()
 Disable automatic sleep.
 
void enableAutoSleep ()
 Enable automatic sleep.
 
void setSwapXY (bool swap) override
 Set the swap XY flag.
 
void setMirrorXY (bool mirrorX, bool mirrorY) override
 Set the mirror XY flag.
 
void setMaxCoordinates (uint16_t x, uint16_t y) override
 Set the maximum coordinates.
 
uint8_t getSupportTouchPoint () override
 Gets the number of supported touch points.
 
void getResolution (uint16_t &x, uint16_t &y) override
 Gets the touch point coordinates.
 
uint16_t getResolutionX () override
 Gets the touch point resolution.
 
uint16_t getResolutionY () override
 Gets the touch point resolution.
 
- Public Member Functions inherited from TouchDrvInterface
 TouchDrvInterface ()
 Construct a new TouchDrvInterface object.
 
virtual ~TouchDrvInterface ()=default
 Destroy the TouchDrvInterface object.
 
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 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 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 bool isSwapXY () const
 Check if X and Y coordinates are swapped.
 
virtual bool isMirrorX () const
 Check if X coordinates are mirrored.
 
virtual bool isMirrorY () const
 Check if Y coordinates are mirrored.
 
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.
 
- 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
 

Additional Inherited Members

- Public Types inherited from TouchDrvInterface
using HomeButtonCallback = void(*)(void *user_data)
 Callback type for home button events.
 
- 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)
 
- Protected Attributes inherited from TouchDrvInterface
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
 

Detailed Description

Definition at line 52 of file touch/TouchDrvCSTXXX.hpp.

Constructor & Destructor Documentation

◆ TouchDrvCSTXXX()

TouchDrvCSTXXX::TouchDrvCSTXXX ( )

Constructor for the touch driver.

Return values
None

Definition at line 42 of file TouchDrvCSTXXX.cpp.

◆ ~TouchDrvCSTXXX()

TouchDrvCSTXXX::~TouchDrvCSTXXX ( )
default

Destructor for the touch driver.

Return values
None

Member Function Documentation

◆ begin()

bool TouchDrvCSTXXX::begin ( SensorCommCustom::CustomCallback  callback,
SensorCommCustomHal::CustomHalCallback  hal_callback,
uint8_t  addr 
)
overridevirtual

Initialize the touch driver for custom communication.

Note
This function initializes the touch driver with the specified custom callbacks.
Parameters
callbackThe custom callback function for communication.
hal_callbackThe custom HAL callback function for hardware abstraction.
addrThe I2C address of the touch driver.
Return values
Trueif successful, false otherwise.

Reimplemented from TouchDrvInterface.

Definition at line 78 of file TouchDrvCSTXXX.cpp.

References hal_callback().

Referenced by setup(), and touch_drv_init().

◆ disableAutoSleep()

void TouchDrvCSTXXX::disableAutoSleep ( )

Disable automatic sleep.

Note
This function will disable automatic sleep for the touch driver,only for CST328
Return values
None

Definition at line 166 of file TouchDrvCSTXXX.cpp.

References disableAutoSleep(), and TouchDrv_CST8XX.

Referenced by disableAutoSleep(), and touch_drv_init().

◆ enableAutoSleep()

void TouchDrvCSTXXX::enableAutoSleep ( )

Enable automatic sleep.

Note
This function will enable automatic sleep for the touch driver,only for CST328
Return values
None

Definition at line 174 of file TouchDrvCSTXXX.cpp.

References enableAutoSleep(), and TouchDrv_CST8XX.

Referenced by enableAutoSleep().

◆ getChipID()

uint32_t TouchDrvCSTXXX::getChipID ( )
overridevirtual

Get the chip ID.

Note
This function will retrieve the chip ID from the touch driver.
Return values
Thechip ID.

Reimplemented from TouchDrvInterface.

Definition at line 108 of file TouchDrvCSTXXX.cpp.

Referenced by setup().

◆ getModelName()

const char * TouchDrvCSTXXX::getModelName ( )
overridevirtual

Get the model name.

Note
This function will retrieve the model name from the touch driver.
Return values
Themodel name.

Implements TouchDrvInterface.

Definition at line 103 of file TouchDrvCSTXXX.cpp.

Referenced by setup(), and touch_drv_init().

◆ getResolution()

void TouchDrvCSTXXX::getResolution ( uint16_t &  x,
uint16_t &  y 
)
overridevirtual

Gets the touch point coordinates.

Note
This function retrieves the touch point coordinates from the touch driver.
Parameters
&xThe X coordinate of the touch point
&yThe Y coordinate of the touch point
Return values
None

Reimplemented from TouchDrvInterface.

Definition at line 130 of file TouchDrvCSTXXX.cpp.

References x, and y.

◆ getResolutionX()

uint16_t TouchDrvCSTXXX::getResolutionX ( )
overridevirtual

Gets the touch point resolution.

Note
This function retrieves the touch point resolution from the touch driver.
Return values
None

Reimplemented from TouchDrvInterface.

Definition at line 142 of file TouchDrvCSTXXX.cpp.

Referenced by setup().

◆ getResolutionY()

uint16_t TouchDrvCSTXXX::getResolutionY ( )
overridevirtual

Gets the touch point resolution.

Note
This function retrieves the touch point resolution from the touch driver.
Return values
None

Reimplemented from TouchDrvInterface.

Definition at line 137 of file TouchDrvCSTXXX.cpp.

Referenced by setup().

◆ getSupportTouchPoint()

uint8_t TouchDrvCSTXXX::getSupportTouchPoint ( )
overridevirtual

Gets the number of supported touch points.

Note
This function retrieves the number of touch points supported by the touch driver.
Return values
Thenumber of supported touch points.

Reimplemented from TouchDrvInterface.

Definition at line 125 of file TouchDrvCSTXXX.cpp.

Referenced by setup().

◆ getTouchPoints()

const TouchPoints & TouchDrvCSTXXX::getTouchPoints ( )
overridevirtual

Get the touch points.

Note
This function will retrieve the touch points from the touch driver.
Return values
Thetouch points.

Implements TouchDrvInterface.

Definition at line 92 of file TouchDrvCSTXXX.cpp.

References TouchDrvInterface::_touchPoints.

Referenced by loop(), and touch_drv_isr_handler().

◆ isPressed()

bool TouchDrvCSTXXX::isPressed ( uint32_t  filter_ms = 0)
overridevirtual

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 from TouchDrvInterface.

Definition at line 97 of file TouchDrvCSTXXX.cpp.

◆ reset()

void TouchDrvCSTXXX::reset ( )
overridevirtual

Reset the touch driver.

Note
This function will reset the touch driver by toggling the reset pin.
Return values
None

Reimplemented from TouchDrvInterface.

Definition at line 86 of file TouchDrvCSTXXX.cpp.

◆ setCenterButtonCoordinate()

void TouchDrvCSTXXX::setCenterButtonCoordinate ( int16_t  x,
int16_t  y 
)
overridevirtual

Set the center button coordinate.

Note
This function will set the center button coordinate for the touch driver.
Parameters
xThe X coordinate of the center button
yThe Y coordinate of the center button
Return values
None

Reimplemented from TouchDrvInterface.

Definition at line 148 of file TouchDrvCSTXXX.cpp.

References setCenterButtonCoordinate(), TouchDrv_CST8XX, x, and y.

Referenced by setCenterButtonCoordinate(), and touch_drv_init().

◆ setHomeButtonCallback()

void TouchDrvCSTXXX::setHomeButtonCallback ( TouchDrvInterface::HomeButtonCallback  callback,
void *  user_data = NULL 
)
overridevirtual

Set the home button callback.

Note
This function will set the callback function for the home button.
Parameters
cbThe callback function to set
*user_dataPointer to user data to pass to the callback function
Return values
None

Reimplemented from TouchDrvInterface.

Definition at line 156 of file TouchDrvCSTXXX.cpp.

References setHomeButtonCallback(), TouchDrv_CST226, and TouchDrv_CST8XX.

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

◆ setMaxCoordinates()

void TouchDrvCSTXXX::setMaxCoordinates ( uint16_t  x,
uint16_t  y 
)
overridevirtual

Set the maximum coordinates.

Note
This function will set the maximum coordinates for the touch driver.
Parameters
xThe maximum X coordinate
yThe maximum Y coordinate
Return values
None

Reimplemented from TouchDrvInterface.

Definition at line 194 of file TouchDrvCSTXXX.cpp.

References x, and y.

◆ setMirrorXY()

void TouchDrvCSTXXX::setMirrorXY ( bool  mirrorX,
bool  mirrorY 
)
overridevirtual

Set the mirror XY flag.

Note
This function will set the mirror XY flag for the touch driver.
Parameters
mirrorXTrue to mirror X coordinates, false otherwise.
mirrorYTrue to mirror Y coordinates, false otherwise.
Return values
None

Reimplemented from TouchDrvInterface.

Definition at line 188 of file TouchDrvCSTXXX.cpp.

◆ setSwapXY()

void TouchDrvCSTXXX::setSwapXY ( bool  swap)
overridevirtual

Set the swap XY flag.

Note
This function will set the swap XY flag for the touch driver.
Parameters
swapTrue to swap X and Y coordinates, false otherwise.
Return values
None

Reimplemented from TouchDrvInterface.

Definition at line 182 of file TouchDrvCSTXXX.cpp.

◆ setTouchDrvModel()

void TouchDrvCSTXXX::setTouchDrvModel ( TouchDrvType  model)

Set the touch driver model.

Note
This function sets the touch driver model to be used.
Parameters
modelThe touch driver model to set [TouchDrv_CST226, TouchDrv_CST8XX, TouchDrv_CST92XX, TouchDrv_CST3530].
Return values
None

Definition at line 45 of file TouchDrvCSTXXX.cpp.

◆ sleep()

void TouchDrvCSTXXX::sleep ( )
overridevirtual

Puts the touch driver to sleep.

Note
This function puts the touch driver into sleep mode. If the device does not have a reset pin connected, it cannot be woken up after being put into sleep mode and must be powered on again.
Return values
None

Implements TouchDrvInterface.

Definition at line 113 of file TouchDrvCSTXXX.cpp.

◆ wakeup()

void TouchDrvCSTXXX::wakeup ( )
overridevirtual

Wake up the touch driver.

Note
This function will wake up the touch driver from sleep mode.
Return values
None

Reimplemented from TouchDrvInterface.

Definition at line 119 of file TouchDrvCSTXXX.cpp.


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