55 Serial.println(
"Scanning for I2C devices ...");
56 for (address = 0x01; address < 0x7f; address++) {
57 Wire.beginTransmission(address);
58 error = Wire.endTransmission();
60 Serial.print(
"I2C device found at address 0x");
61 Serial.println(address, HEX);
63 }
else if (error != 2) {
64 Serial.print(
"Error ");
66 Serial.print(
" at address 0x");
67 Serial.println(address, HEX);
71 Serial.println(
"No I2C devices found");
90 uint8_t address = 0xFF;
92#if (defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_ARCH_STM32)) && !defined(ARDUINO_ARCH_MBED)
96#elif defined(ARDUINO_ARCH_NRF52)
99#elif defined(ARDUINO_ARCH_ESP32)
108 Wire.beginTransmission(CST816_SLAVE_ADDRESS);
109 if (Wire.endTransmission() == 0) {
110 address = CST816_SLAVE_ADDRESS;
113 Wire.beginTransmission(CST226SE_SLAVE_ADDRESS);
114 if (Wire.endTransmission() == 0) {
115 address = CST226SE_SLAVE_ADDRESS;
117 Wire.beginTransmission(CST328_SLAVE_ADDRESS);
118 if (Wire.endTransmission() == 0) {
119 address = CST328_SLAVE_ADDRESS;
121 while (address == 0xFF) {
122 Serial.println(
"Could't find touch chip!"); delay(1000);
146 if (result ==
false) {
148 Serial.println(
"Failed to initialize CST series touch, please check the connection...");
164 Serial.println(
"Home key pressed!");
187 Serial.println(
"Touch Info:");
193 if (resX == 0 || resY == 0) {
194 Serial.println(
"The touch driver not support get touch resolution,please use setResolution() to set touch resolution.");
197 Serial.print(
"Resolution: "); Serial.print(resX); Serial.print(
" x "); Serial.println(resY);
210 Serial.print(
"ID: ");
211 Serial.print(point.
id);
214 Serial.print(point.
x);
217 Serial.print(point.
y);
219 Serial.print(
"Pressure: ");
222 Serial.print(
"Event: ");
223 switch (point.
event) {
224 case 0: Serial.print(
"Released");
break;
225 case 6: Serial.print(
"Pressed");
break;
226 default: Serial.print(
"Unknown");
break;
uint16_t getResolutionY() override
Gets the touch point resolution.
uint8_t getSupportTouchPoint() override
Gets the number of supported touch points.
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.
uint32_t getChipID() override
Get the chip ID.
uint16_t getResolutionX() override
Gets the touch point resolution.
virtual void setPins(int rst, int irq)
Set the hardware reset and interrupt pin numbers.
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.
Represents a single touch point with its properties.
uint16_t pressure
Pressure value (0 if not supported by the chip).
uint8_t event
Event type based on actual hardware feedback, most touch devices do not support.
uint8_t id
Touch point ID for multi‑touch tracking.
uint16_t x
X coordinate of the touch point.
uint16_t y
Y coordinate of the touch point.