33#include "../SensorBuildOpt.h"
34#if !SENSORLIB_EXCLUDE_TOUCH_CSTXXX
41static constexpr uint8_t CSTXXX_SLAVE_ADDRESS = (0x15);
42static constexpr uint8_t CST328_SLAVE_ADDRESS = (0x1A);
86 bool begin(TwoWire &wire, uint8_t addr,
int sda,
int scl)
override;
87#elif defined(ESP_PLATFORM)
88#if defined(SENSORLIB_USE_I2C_LEGACY)
98 bool begin(i2c_port_t port_num, uint8_t addr,
int sda = -1,
int scl = -1)
override;
107 bool begin(i2c_master_bus_handle_t handle, uint8_t addr)
override;
121 uint8_t addr)
override;
128 void reset()
override;
137 void sleep()
override;
162 bool isPressed(uint32_t filter_ms = 0)
override;
225 void setMirrorXY(
bool mirrorX,
bool mirrorY)
override;
270 bool initImpl(uint8_t)
override
275 using DriverCreator = std::unique_ptr<TouchDrvInterface> (*)();
277 static constexpr uint8_t driverCreatorMaxNum = 4;
278 static DriverCreator driverCreators[driverCreatorMaxNum];
280 std::unique_ptr<TouchDrvInterface> createDriver(
TouchDrvType type)
282 if (type < driverCreatorMaxNum) {
283 return driverCreators[type]();
288 template<
typename... Args>
289 bool beginImpl(Args&&... args)
292 i < driverCreatorMaxNum; ++
i) {
295 if (_drv && _drv->begin(std::forward<Args>(args)...)) {
306 static_assert(
sizeof(driverCreators) /
sizeof(driverCreators[0]) == TOUCH_DRV_TYPE_VALID_COUNT,
307 "driverCreators size mismatch");
311 std::unique_ptr<TouchDrvInterface> _drv;
uint32_t(*)(Operation op, void *param1, void *param2) CustomHalCallback
bool(*)(uint8_t addr, uint8_t reg, uint8_t *buf, size_t len, bool writeReg, bool isWrite) CustomCallback
void sleep() override
Puts the touch driver to sleep.
TouchDrvCSTXXX()
Constructor for the touch driver.
uint16_t getResolutionY() override
Gets the touch point resolution.
~TouchDrvCSTXXX()=default
Destructor for the touch driver.
void setSwapXY(bool swap) override
Set the swap XY flag.
uint8_t getSupportTouchPoint() override
Gets the number of supported touch points.
void reset() override
Reset the touch driver.
void setHomeButtonCallback(TouchDrvInterface::HomeButtonCallback callback, void *user_data=NULL) override
Set the home button callback.
bool begin(SensorCommCustom::CustomCallback callback, SensorCommCustomHal::CustomHalCallback hal_callback, uint8_t addr) override
Initialize the touch driver for custom communication.
const char * getModelName() override
Get the model name.
const TouchPoints & getTouchPoints() override
Get the touch points.
void wakeup() override
Wake up the touch driver.
void disableAutoSleep()
Disable automatic sleep.
uint32_t getChipID() override
Get the chip ID.
void getResolution(uint16_t &x, uint16_t &y) override
Gets the touch point coordinates.
void enableAutoSleep()
Enable automatic sleep.
void setCenterButtonCoordinate(int16_t x, int16_t y) override
Set the center button coordinate.
uint16_t getResolutionX() override
Gets the touch point resolution.
void setMaxCoordinates(uint16_t x, uint16_t y) override
Set the maximum coordinates.
void setTouchDrvModel(TouchDrvType model)
Set the touch driver model.
void setMirrorXY(bool mirrorX, bool mirrorY) override
Set the mirror XY flag.
Abstract base class for touch screen drivers.
void(*)(void *user_data) HomeButtonCallback
Callback type for home button events.
Container for touch point data and optional gesture information.
uint32_t hal_callback(SensorCommCustomHal::Operation op, void *param1, void *param2)