|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
#include <TouchDrvCSTXXX.hpp>
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 TouchPoints & | getTouchPoints () 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 TouchPinsCfg & | getTouchPinsCfg () 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 SensorCommBase * | getComm () 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< SensorCommBase > | comm |
| std::unique_ptr< SensorHal > | hal |
| std::unique_ptr< SensorCommStatic > | staticComm |
| uint8_t | _addr = 0 |
| uint8_t | _iface = COMM_CUSTOM |
Definition at line 52 of file touch/TouchDrvCSTXXX.hpp.
| TouchDrvCSTXXX::TouchDrvCSTXXX | ( | ) |
Constructor for the touch driver.
| None |
Definition at line 42 of file TouchDrvCSTXXX.cpp.
|
default |
Destructor for the touch driver.
| None |
|
overridevirtual |
Initialize the touch driver for custom communication.
| callback | The custom callback function for communication. |
| hal_callback | The custom HAL callback function for hardware abstraction. |
| addr | The I2C address of the touch driver. |
| True | if successful, false otherwise. |
Reimplemented from TouchDrvInterface.
Definition at line 78 of file TouchDrvCSTXXX.cpp.
References hal_callback().
Referenced by setup(), and touch_drv_init().
| void TouchDrvCSTXXX::disableAutoSleep | ( | ) |
Disable automatic sleep.
| None |
Definition at line 166 of file TouchDrvCSTXXX.cpp.
References disableAutoSleep(), and TouchDrv_CST8XX.
Referenced by disableAutoSleep(), and touch_drv_init().
| void TouchDrvCSTXXX::enableAutoSleep | ( | ) |
Enable automatic sleep.
| None |
Definition at line 174 of file TouchDrvCSTXXX.cpp.
References enableAutoSleep(), and TouchDrv_CST8XX.
Referenced by enableAutoSleep().
|
overridevirtual |
Get the chip ID.
| The | chip ID. |
Reimplemented from TouchDrvInterface.
Definition at line 108 of file TouchDrvCSTXXX.cpp.
Referenced by setup().
|
overridevirtual |
Get the model name.
| The | model name. |
Implements TouchDrvInterface.
Definition at line 103 of file TouchDrvCSTXXX.cpp.
Referenced by setup(), and touch_drv_init().
|
overridevirtual |
Gets the touch point coordinates.
| &x | The X coordinate of the touch point |
| &y | The Y coordinate of the touch point |
| None |
Reimplemented from TouchDrvInterface.
Definition at line 130 of file TouchDrvCSTXXX.cpp.
|
overridevirtual |
Gets the touch point resolution.
| None |
Reimplemented from TouchDrvInterface.
Definition at line 142 of file TouchDrvCSTXXX.cpp.
Referenced by setup().
|
overridevirtual |
Gets the touch point resolution.
| None |
Reimplemented from TouchDrvInterface.
Definition at line 137 of file TouchDrvCSTXXX.cpp.
Referenced by setup().
|
overridevirtual |
Gets the number of supported touch points.
| The | number of supported touch points. |
Reimplemented from TouchDrvInterface.
Definition at line 125 of file TouchDrvCSTXXX.cpp.
Referenced by setup().
|
overridevirtual |
Get the touch points.
| The | touch points. |
Implements TouchDrvInterface.
Definition at line 92 of file TouchDrvCSTXXX.cpp.
References TouchDrvInterface::_touchPoints.
Referenced by loop(), and touch_drv_isr_handler().
|
overridevirtual |
Check if any touch point is currently pressed.
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. | filter_ms | Optional 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. |
| true | At least one touch point detected. |
| false | No touch detected. |
Reimplemented from TouchDrvInterface.
Definition at line 97 of file TouchDrvCSTXXX.cpp.
|
overridevirtual |
Reset the touch driver.
| None |
Reimplemented from TouchDrvInterface.
Definition at line 86 of file TouchDrvCSTXXX.cpp.
|
overridevirtual |
Set the center button coordinate.
| x | The X coordinate of the center button |
| y | The Y coordinate of the center button |
| 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().
|
overridevirtual |
Set the home button callback.
| cb | The callback function to set |
| *user_data | Pointer to user data to pass to the callback function |
| 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().
|
overridevirtual |
Set the maximum coordinates.
| x | The maximum X coordinate |
| y | The maximum Y coordinate |
| None |
Reimplemented from TouchDrvInterface.
Definition at line 194 of file TouchDrvCSTXXX.cpp.
|
overridevirtual |
Set the mirror XY flag.
| mirrorX | True to mirror X coordinates, false otherwise. |
| mirrorY | True to mirror Y coordinates, false otherwise. |
| None |
Reimplemented from TouchDrvInterface.
Definition at line 188 of file TouchDrvCSTXXX.cpp.
|
overridevirtual |
Set the swap XY flag.
| swap | True to swap X and Y coordinates, false otherwise. |
| None |
Reimplemented from TouchDrvInterface.
Definition at line 182 of file TouchDrvCSTXXX.cpp.
| void TouchDrvCSTXXX::setTouchDrvModel | ( | TouchDrvType | model | ) |
Set the touch driver model.
| model | The touch driver model to set [TouchDrv_CST226, TouchDrv_CST8XX, TouchDrv_CST92XX, TouchDrv_CST3530]. |
| None |
Definition at line 45 of file TouchDrvCSTXXX.cpp.
|
overridevirtual |
Puts the touch driver to sleep.
| None |
Implements TouchDrvInterface.
Definition at line 113 of file TouchDrvCSTXXX.cpp.
|
overridevirtual |
Wake up the touch driver.
| None |
Reimplemented from TouchDrvInterface.
Definition at line 119 of file TouchDrvCSTXXX.cpp.