|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
#include <TouchDrvCST92xx.hpp>
Public Types | |
| enum | CST92_RunMode { MODE_NORMAL = (0x00) , MODE_LOW_POWER = (0X01) , MODE_DEEP_SLEEP = (0X02) , MODE_WAKEUP = (0x03) , MODE_DEBUG_DIFF = (0x04) , MODE_DEBUG_RAWDATA = (0X05) , MODE_FACTORY = (0x06) , MODE_DEBUG_INFO = (0x07) , MODE_UPDATE_FW = (0x08) , MODE_FACTORY_HIGH_DRV = (0x10) , MODE_FACTORY_LOW_DRV = (0x11) , MODE_FACTORY_SHORT = (0x12) , MODE_LPSCAN = (0x13) } |
Public Types inherited from TouchDrvInterface | |
| using | HomeButtonCallback = void(*)(void *user_data) |
| Callback type for home button events. | |
Public Member Functions | |
| TouchDrvCST92xx () | |
| Constructor for the touch driver. | |
| ~TouchDrvCST92xx ()=default | |
| Destructor for the touch driver. | |
| void | sleep () override |
| Puts the touch driver to sleep. | |
| const TouchPoints & | getTouchPoints () override |
| Get the touch points. | |
| const char * | getModelName () override |
| Get the model name. | |
| void | setCoverScreenCallback (HomeButtonCallback cb, void *user_data=NULL) |
| Set the cover screen callback. | |
| 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). | |
Public Member Functions inherited from TouchDrvInterface | |
| 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 void | reset () |
| Reset the touch controller. | |
| virtual void | wakeup () |
| Wake the touch controller from sleep mode (pure virtual). | |
| virtual bool | isPressed (uint32_t filter_ms=0) |
| Check if any touch point is currently pressed. | |
| 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 TouchPinsCfg & | getTouchPinsCfg () 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 | |
| int | _slave_addr |
| uint16_t | chipType |
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 |
Static Protected Attributes | |
| static constexpr uint16_t | CST9220_CHIP_ID = (0x9220) |
| static constexpr uint16_t | CST9217_CHIP_ID = (0x9217) |
| static constexpr uint16_t | REG_READ = (0xD000) |
| static constexpr uint16_t | REG_DEBUG_MODE = (0xD101) |
| static constexpr uint16_t | REG_SLEEP_MODE = (0xD105) |
| static constexpr uint16_t | REG_DIS_LOW_POWER_SCAN_MODE = (0xD106) |
| static constexpr uint16_t | REG_NORMAL_MODE = (0xD109) |
| static constexpr uint16_t | REG_RAW_MODE = (0xD10A) |
| static constexpr uint16_t | REG_DIFF_MODE = (0xD10D) |
| static constexpr uint16_t | REG_BASE_LINE_MODE = (0xD10E) |
| static constexpr uint16_t | REG_LOW_POWER_MODE = (0xD10F) |
| static constexpr uint16_t | REG_FACTORY_MODE = (0xD114) |
| static constexpr uint8_t | CST92XX_BOOT_ADDRESS = (0x5A) |
| static constexpr uint8_t | CST92XX_ACK = (0xAB) |
| static constexpr uint32_t | CST92XX_MEM_SIZE = (0x007F80) |
| static constexpr uint8_t | MAX_FINGER_NUM = (2) |
| static constexpr uint8_t | PROGRAM_PAGE_SIZE = (128) |
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 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) |
Definition at line 38 of file TouchDrvCST92xx.hpp.
Definition at line 42 of file TouchDrvCST92xx.hpp.
| TouchDrvCST92xx::TouchDrvCST92xx | ( | ) |
Constructor for the touch driver.
| None |
Definition at line 34 of file TouchDrvCST92xx.cpp.
|
default |
Destructor for the touch driver.
| None |
|
overridevirtual |
Get the model name.
| The | model name. |
Implements TouchDrvInterface.
Definition at line 105 of file TouchDrvCST92xx.cpp.
References TouchDrvInterface::_chipID, CST9217_CHIP_ID, and CST9220_CHIP_ID.
Referenced by setup().
|
inlinevirtual |
Retrieve touch point coordinates (deprecated).
getTouchPoints() instead, which returns a richer TouchPoints object.| [out] | x_array | Pointer to array to store X coordinates. |
| [out] | y_array | Pointer to array to store Y coordinates. |
| get_point | Number of points to retrieve (max). |
Reimplemented from TouchDrvInterface.
Definition at line 288 of file touch/TouchDrvInterface.hpp.
|
overridevirtual |
Get the touch points.
| A | reference to the touch points. |
Implements TouchDrvInterface.
Definition at line 38 of file TouchDrvCST92xx.cpp.
References TouchDrvInterface::_HButtonCallback, sensorlib::_highByte(), sensorlib::_lowByte(), TouchDrvInterface::_touchPoints, TouchDrvInterface::_userData, TouchPoints::addPoint(), addrToBeBuf(), TouchPoints::clear(), CST92XX_ACK, TouchPoint::event, TouchPoints::getPoint(), i, MAX_FINGER_NUM, REG_READ, TouchDrvInterface::updateXY(), SensorCommWrapper::writeBuff(), SensorCommWrapper::writeThenRead(), x, and y.
Referenced by loop().
| void TouchDrvCST92xx::setCoverScreenCallback | ( | HomeButtonCallback | cb, |
| void * | user_data = NULL |
||
| ) |
Set the cover screen callback.
| cb | The callback function to be set |
| *user_data | Pointer to user data to be passed to the callback function |
| None |
Definition at line 137 of file TouchDrvCST92xx.cpp.
References TouchDrvInterface::_HButtonCallback, and TouchDrvInterface::_userData.
Referenced by setup().
|
overridevirtual |
Puts the touch driver to sleep.
| None |
Implements TouchDrvInterface.
Definition at line 118 of file TouchDrvCST92xx.cpp.
References TouchDrvInterface::_pinsCfg, addrToBeBuf(), DeviceBeginCommon::hal, TouchDrvInterface::TouchPinsCfg::irqPin, MODE_DEBUG_INFO, REG_SLEEP_MODE, TouchDrvInterface::TouchPinsCfg::rstPin, and SensorCommWrapper::writeBuff().
|
protected |
Definition at line 111 of file TouchDrvCST92xx.hpp.
|
protected |
Definition at line 112 of file TouchDrvCST92xx.hpp.
|
staticconstexprprotected |
Definition at line 115 of file TouchDrvCST92xx.hpp.
Referenced by getModelName().
|
staticconstexprprotected |
Definition at line 114 of file TouchDrvCST92xx.hpp.
Referenced by getModelName().
|
staticconstexprprotected |
Definition at line 129 of file TouchDrvCST92xx.hpp.
Referenced by getTouchPoints().
|
staticconstexprprotected |
Definition at line 128 of file TouchDrvCST92xx.hpp.
|
staticconstexprprotected |
Definition at line 130 of file TouchDrvCST92xx.hpp.
|
staticconstexprprotected |
Definition at line 132 of file TouchDrvCST92xx.hpp.
Referenced by getTouchPoints().
|
staticconstexprprotected |
Definition at line 133 of file TouchDrvCST92xx.hpp.
|
staticconstexprprotected |
Definition at line 124 of file TouchDrvCST92xx.hpp.
|
staticconstexprprotected |
Definition at line 118 of file TouchDrvCST92xx.hpp.
|
staticconstexprprotected |
Definition at line 123 of file TouchDrvCST92xx.hpp.
|
staticconstexprprotected |
Definition at line 120 of file TouchDrvCST92xx.hpp.
|
staticconstexprprotected |
Definition at line 126 of file TouchDrvCST92xx.hpp.
|
staticconstexprprotected |
Definition at line 125 of file TouchDrvCST92xx.hpp.
|
staticconstexprprotected |
Definition at line 121 of file TouchDrvCST92xx.hpp.
|
staticconstexprprotected |
Definition at line 122 of file TouchDrvCST92xx.hpp.
|
staticconstexprprotected |
Definition at line 117 of file TouchDrvCST92xx.hpp.
Referenced by getTouchPoints().
|
staticconstexprprotected |
Definition at line 119 of file TouchDrvCST92xx.hpp.
Referenced by sleep().