32#include "../SensorBuildOpt.h"
33#if !SENSORLIB_EXCLUDE_TOUCH_COMMON
89 _touchConfig({
false,
false,
false,
false, 0, 0, 0, 0, 1.0f, 1.0f})
112 virtual bool begin(TwoWire &wire, uint8_t addr,
int sda = -1,
int scl = -1)
117#elif defined(ESP_PLATFORM)
119#if defined(SENSORLIB_USE_I2C_LEGACY)
131 virtual bool begin(i2c_port_t port_num, uint8_t addr,
int sda,
int scl)
146 virtual bool begin(i2c_master_bus_handle_t handle, uint8_t addr)
292 if (x_array ==
nullptr || y_array ==
nullptr) {
297 for (
int i = 0;
i < pointsToCopy;
i++) {
330 uint32_t now =
hal->millis();
522 for (uint8_t
i = 0;
i < count; ++
i) {
616 virtual void afterCommReady()
override
636 virtual void initGpioPins()
std::unique_ptr< SensorHal > hal
bool begin(SensorCommCustom::CustomCallback cb, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr)
Initialize the sensor using custom callback interface.
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(*)(uint8_t pin, uint8_t mode) CustomMode
Set pin mode (INPUT/OUTPUT, etc.)
void(*)(uint8_t pin, uint8_t level) CustomWrite
Set pin level (0/1)
uint8_t(*)(uint8_t pin) CustomRead
Read pin level.
Abstract base class for touch screen drivers.
uint32_t _chipID
Chip identification value.
TouchConfig _touchConfig
Configuration for coordinate transformations.
virtual bool isSwapXY() const
Check if X and Y coordinates are swapped.
virtual bool isMirrorX() const
Check if X coordinates are mirrored.
virtual void getResolution(uint16_t &x, uint16_t &y)
Get the raw resolution (maximum coordinate values) of the touch panel.
virtual bool isScalingEnabled()
Check if coordinate scaling is enabled.
virtual uint16_t getMaxX()
Get the maximum X coordinate (e.g., display width).
virtual void setMaxCoordinates(uint16_t x, uint16_t y)
Set the maximum coordinate values used for mirroring.
void(*)(void *user_data) HomeButtonCallback
Callback type for home button events.
SensorHalCustom::CustomMode _halModeCallback
Custom GPIO mode callback.
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 void getMaxCoordinates(uint16_t &x, uint16_t &y)
Get the maximum coordinates used for mirroring.
virtual void setCenterButtonCoordinate(int16_t x, int16_t y)
Set the expected screen coordinates of a hardware home button.
virtual void reset()
Reset the touch controller.
void * _userData
User data for home button callback.
virtual const TouchPoints & getTouchPoints()=0
Get the current touch points (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 void updateXY(TouchPoints &points) const
Apply coordinate transformations (swap, scale, mirror) to all touch points.
virtual bool initImpl(uint8_t param)=0
Device-specific initialization implementation (pure virtual).
virtual uint16_t getMaxY()
Get the maximum Y coordinate (e.g., display height).
virtual const char * getModelName()=0
Get the human-readable model name of the touch controller.
virtual bool isMirrorY() const
Check if Y coordinates are mirrored.
TouchPinsCfg _pinsCfg
Configuration for reset and interrupt pins.
virtual bool begin(SensorCommCustom::CustomCallback callback, SensorCommCustomHal::CustomHalCallback hal_callback, uint8_t addr)
Initialize the touch driver with custom communication callbacks.
virtual uint16_t getResolutionX()
Get the raw maximum X coordinate of the touch panel.
int16_t _center_btn_y
Y coordinate of home button center.
virtual void setResolution(uint16_t width, uint16_t height)
Set the raw resolution of the touch panel (physical maximum coordinates).
virtual void setMirrorXY(bool mirrorX, bool mirrorY)
Enable or disable mirroring of X and/or Y coordinates.
virtual uint8_t getSupportTouchPoint()
Get the maximum number of touch points supported by the hardware.
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.
TouchDrvInterface()
Construct a new TouchDrvInterface object.
int16_t _center_btn_x
X coordinate of home button center.
SensorHalCustom::CustomWrite _halWriteCallback
Custom GPIO write callback.
virtual ~TouchDrvInterface()=default
Destroy the TouchDrvInterface object.
virtual uint32_t getChipID()
Get the chip identifier (e.g., ID register value).
virtual bool isPressed(uint32_t filter_ms=0)
Check if any touch point is currently pressed.
virtual void setHomeButtonCallback(HomeButtonCallback cb, void *user_data)
Register a callback for home button events.
virtual uint16_t getResolutionY()
Get the raw maximum Y coordinate of the touch panel.
virtual void sleep()=0
Put the touch controller into low-power sleep mode (pure virtual).
virtual void setTargetResolution(uint16_t width, uint16_t height)
Set the target display resolution to map touch coordinates to screen pixels.
TouchPoints _touchPoints
Touch points data.
SensorHalCustom::CustomRead _halReadCallback
Custom GPIO read callback.
uint8_t _maxTouchPoints
Maximum supported touch points.
virtual void wakeup()
Wake the touch controller from sleep mode (pure virtual).
HomeButtonCallback _HButtonCallback
Home button callback function.
uint32_t _lastPulse
Timestamp of the last touch event.
virtual void setSwapXY(bool swap)
Enable or disable swapping of X and Y coordinates.
Container for touch point data and optional gesture information.
uint8_t getPointCount() const
Returns the number of stored touch points.
TouchPoint & getPoint(uint8_t index)
Gets a reference to a touch point at the specified index.
bool hasPoints() const
Checks whether any touch points are stored.
uint32_t hal_callback(SensorCommCustomHal::Operation op, void *param1, void *param2)
__attribute__((weak)) void setupPower()
Represents a single touch point with its properties.
uint16_t x
X coordinate of the touch point.
uint16_t y
Y coordinate of the touch point.