30#include "../SensorBuildOpt.h"
31#if !SENSORLIB_EXCLUDE_TOUCH_FT6X36
42 static constexpr size_t POINT_BUFFER_SIZE = MAX_FINGER_NUM * BYTES_PER_POINT;
43 uint8_t buffer[POINT_BUFFER_SIZE] = {0};
45 int numPoints =
readReg(FT6X36_REG_STATUS);
50 if (numPoints == 0 || numPoints > MAX_FINGER_NUM) {
53 uint8_t expectedBytes = numPoints * BYTES_PER_POINT;
56 if (
readRegBuff(FT6X36_REG_TOUCH1_XH, buffer, expectedBytes) == 0) {
57 for (
int i = 0;
i < numPoints;
i++) {
58 const uint8_t eventFlag = (buffer[0 +
i * BYTES_PER_POINT] & 0xC0) >> 6;
59 const uint8_t touchId = (buffer[2 +
i * BYTES_PER_POINT] >> 4) & 0x0F;
60 const uint16_t
x = ((buffer[0 +
i * BYTES_PER_POINT] & 0x0F) << 8) | buffer[1 +
i * BYTES_PER_POINT];
61 const uint16_t
y = ((buffer[2 +
i * BYTES_PER_POINT] & 0x0F) << 8) | buffer[3 +
i * BYTES_PER_POINT];
62 const uint8_t weight = buffer[4 +
i * BYTES_PER_POINT];
81 case FT6206_CHIP_ID:
return "FT6206";
82 case FT6236_CHIP_ID:
return "FT6236";
83 case FT6336U_CHIP_ID:
return "FT6336U";
84 case FT3267_CHIP_ID:
return "FT3267";
85 case FT5336_CHIP_ID:
return "FT5336";
86 case FT3068_CHIP_ID:
return "FT3068";
87 default:
return "UNKNOWN";
93 return readReg(FT6X36_REG_MODE) & 0x03;
98 int val =
readReg(FT6X36_REG_GEST);
118 return readReg(FT6X36_REG_THRESHOLD);
123 writeReg(FT6X36_REG_THRESHOLD, value);
128 return readReg(FT6X36_REG_MONITOR_TIME);
133 writeReg(FT6X36_REG_MONITOR_TIME, sec);
138 uint8_t buffer[2] = {0};
140 return (buffer[0] << 8) | buffer[1];
145 writeReg(FT6X36_REG_INT_STATUS, 0x00);
150 writeReg(FT6X36_REG_INT_STATUS, 0x01);
155 writeReg(FT6X36_REG_POWER_MODE, mode);
160 return readReg(FT6X36_REG_VENDOR1_ID);
165 return readReg(FT6X36_REG_ERROR_STATUS);
168bool TouchDrvFT6X36::initImpl(uint8_t)
170 uint8_t vendId =
readReg(FT6X36_REG_VENDOR1_ID);
189 case FT6336U_CHIP_ID:
#define SENSORLIB_LOG_I(...)
#define SENSORLIB_LOG_E(...)
int readReg(uint8_t reg) const
int writeReg(uint8_t reg, uint8_t val)
int readRegBuff(uint8_t reg, uint8_t *buf, size_t len) const
void interruptPolling(void)
Polling mode for touch interrupt.
uint16_t getLibraryVersion()
Get the library version.
const char * getModelName() override
Get the model name.
void interruptTrigger(void)
Trigger mode for touch interrupt.
uint8_t getThreshold(void)
Get the touch threshold.
uint8_t getVendorID(void)
Get the vendor ID.
void setThreshold(uint8_t value)
Set the touch threshold.
const TouchPoints & getTouchPoints() override
Get the touch points.
uint8_t getMonitorTime(void)
Get the monitor time.
void setMonitorTime(uint8_t sec)
Set the monitor time.
void setPowerMode(PowerMode mode)
Set the touch interrupt mode.
uint8_t getDeviceMode(void)
Get the device mode.
void setDeviceMode(uint8_t value)
Set the device mode.
void sleep() override
Puts the touch driver to sleep.
uint8_t getErrorCode(void)
Get the error code.
uint32_t _chipID
Chip identification value.
virtual void updateXY(TouchPoints &points) const
Apply coordinate transformations (swap, scale, mirror) to all touch points.
TouchPoints _touchPoints
Touch points data.
uint8_t _maxTouchPoints
Maximum supported touch points.
Container for touch point data and optional gesture information.
bool addPoint(uint16_t x, uint16_t y, uint16_t pressure=0, uint8_t id=0, uint8_t event=0)
Adds a touch point to the container.
void clear()
Clears all stored touch points and gesture.