tamctec / gt911-arduino Goto Github PK
View Code? Open in Web Editor NEWArduino library for GT911
License: Apache License 2.0
Arduino library for GT911
License: Apache License 2.0
this library works great but if I set Rotation to NORMAL the y values get suspiciously heigh - around 65535 or a bit lower. Seems like some variable overflows ...
y = 0 is also not on the bottom but somewhere in the middle of the screen. Seems like the library assumes 320 to be the heighes value on the top. Going down then gets to zero and further down: 65335
in x direction the heighest value is 480
Am I expecting something diferent from "NORMAL"?
getGesture is defined in the .h but not present (that I can see) in the .cpp
I'd really like to implement swiping gestures!
I've been trying to get the touch panel working with an esp32-s3 for some time now. The same screen works fine on an original esp32, but not on my esp32-s3 wroom or esp32-s3 dev board. The resistive screen and touch work fine though, it's the the gt911 that I can't see for some reason, even with a few i2c scanner.
Need a modification where a 2nd I2C bus can be used and not just the default Wire.
After much frustration I have finally worked out the problem and solution.
The GT911 really needs the INT pin connected, this is used to set the I2C address of the chip on bootup, then can be used to drive interrupt driven touch. On my board this is not connected and floats, hence randomly changes between the 2 addresses on bootup.
Easy to sort in the TAMC_GT911.cpp. In the reset () add
delay(50);
checkCorrectAddr ();
readBlockData(configBuf, GT911_CONFIG_START, GT911_CONFIG_SIZE);
Then create a new routine
void TAMC_GT911::checkCorrectAddr(void) {
//Need to solve floating INT pin so on reset changes between the 2 addresses
uint8_t returnSize;
Wire.beginTransmission(addr);
Wire.write(highByte(GT911_PRODUCT_ID));
Wire.write(lowByte(GT911_PRODUCT_ID));
Wire.endTransmission();
returnSize = Wire.requestFrom(addr, (uint8_t)1); //returns rxLength - if 0 we have a problem
if (returnSize == 0) {
addr = GT911_ADDR2;
Serial.println ("setting address to ADDR2");
}
}
My ESP32-8048S070 gives a warning as I set the Int pin to -1 (not connected). Since the interrupts are commented out in the code would be better to comment out in reset(). Note - this is a minor issue as it does not cause any run time problems.
Hi
I would like to apply TAMC_GT911 for ESP32-WROOM-32D.
But the "Wire.requestFrom(addr, size);" doesn't work when the size is over 0x80(128).
void TAMC_GT911::readBlockData(uint8_t *buf, uint16_t reg, uint8_t size) { Wire.beginTransmission(addr); Wire.write(highByte(reg)); Wire.write(lowByte(reg)); Wire.endTransmission(); Wire.requestFrom(addr, size); for (uint8_t i=0; i<size; i++) { buf[i] = Wire.read(); } }
The problem happens in begin>>reset>readBlockData.
write to 0x5D ack data: 0x80 0x47 write to 0x5D ack data: 0x80 0xFF 0x43 write to 0x5D ack data: 0x81 0x00 0x01
If break the size below 0x80, the "readBlockData(configBuf, GT911_CONFIG_START, GT911_CONFIG_SIZE);" is work.
write to 0x5D ack data: 0x80 0x47 read to 0x5D ack data: 0x61 0x40 0x01 0xE0 0x01 0x05 0x35 0x00 0x02 0x08 0x1E 0x08 0x50 0x3C 0x0F 0x05 0x00 0x00 0x00 0x00 0x50 0x00 0x00 0x18 0x1A 0x1E 0x14 0x87 0x27 0x0A 0x4B 0x4D 0xD3 0x07 0x00 0x00 0x00 0x02 0x32 0x1D 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x32 0x00 0x00 0x2A 0x32 0x64 0x94 0xD5 0x02 0x07 0x00 0x00 0x04 0xA5 0x35 0x00 0x91 0x3D 0x00 0x80 0x46 0x00 0x70 0x51 0x00 0x63 0x5D 0x00 0x63 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x14 0x12 0x10 0x0E 0x0C 0x0A 0x08 0x06 0x04 0x02 0xFF 0xFF 0xFF 0xFF 0x00 0x00 write to 0x5D ack data: 0x00 0x80 read to 0x5D ack data: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 write to 0x5D ack data: 0x80 0xFF 0xDE write to 0x5D ack data: 0x81 0x00 0x01
Trying to use a 3.5" TFT capacitive touchscreen, ILI9488 driver, GT911 I2C bus for touch commands, with an ESP32 Dev module.
i have read the previous issues, none corrects my problem.
Display works with TFT_eSPI library from Bodmer
I2C bus works, i included a test code which returns me a valid address (0x14)
I run the example code, with the pin setting for an ESP32 (SDA 21 , SCL 22), and it returns always the same looping values (every 15 seconds), without any screen touch, and touching the screen doesn't produce any difference.
I have uncommented some "println" in the .cpp file, so the 6 extra lines after each Touch loop.
Touch 1: x: 65535 y: 65535 size: 255
Touch 2: x: 65535 y: 65535 size: 255
Touch 3: x: 65535 y: 65535 size: 255
Touch 4: x: 65535 y: 65535 size: 255
Touch 5: x: 65535 y: 65535 size: 255
Touch 6: x: 65535 y: 65535 size: 255
Touch 7: x: 65535 y: 65535 size: 255
Touch 8: x: 65535 y: 65535 size: 255
Touch 9: x: 65535 y: 65535 size: 255
Touch 10: x: 65535 y: 65535 size: 255
Touch 11: x: 65535 y: 65535 size: 255
Touch 12: x: 65535 y: 65535 size: 255
Touch 13: x: 65535 y: 65535 size: 255
Touch 14: x: 65535 y: 65535 size: 255
Touch 15: x: 65535 y: 65535 size: 255
TAMC_GT911::read
bufferStatus: 1
largeDetect: 1
proximityValid: 1
haveKey: 1
touches: 15
except the first occurence after reset, where the values are
Touch 1: x: 321 y: 481 size: 255
Touch 2: x: 321 y: 481 size: 255
Touch 3: x: 321 y: 481 size: 255
Touch 4: x: 321 y: 481 size: 255
Touch 5: x: 321 y: 481 size: 255
Touch 6: x: 321 y: 481 size: 255
Touch 7: x: 65535 y: 65535 size: 255
Touch 8: x: 65535 y: 65535 size: 255
Touch 9: x: 65535 y: 65535 size: 255
Touch 10: x: 65535 y: 65535 size: 255
Touch 11: x: 65535 y: 65535 size: 255
Touch 12: x: 65535 y: 65535 size: 255
Touch 13: x: 65535 y: 65535 size: 255
Touch 14: x: 65535 y: 65535 size: 255
Touch 15: x: 65535 y: 65535 size: 255
Any help to understand the issue ?
the test code
#include "TAMC_GT911.h"
#define TOUCH_SDA 21
#define TOUCH_SCL 22
#define TOUCH_INT 25
#define TOUCH_RST 13
#define TOUCH_WIDTH 320
#define TOUCH_HEIGHT 480
TAMC_GT911 tp = TAMC_GT911(TOUCH_SDA, TOUCH_SCL, TOUCH_INT, TOUCH_RST, TOUCH_WIDTH, TOUCH_HEIGHT);
void setup() {
Serial.begin(115200);
Serial.println("TAMC_GT911 Example: Ready");
tp.begin();
tp.setRotation(ROTATION_NORMAL);
}
void loop() {
tp.read();
if (tp.isTouched){
for (int i=0; i<tp.touches; i++){
Serial.print("Touch ");Serial.print(i+1);Serial.print(": ");;
Serial.print(" x: ");Serial.print(tp.points[i].x);
Serial.print(" y: ");Serial.print(tp.points[i].y);
Serial.print(" size: ");Serial.println(tp.points[i].size);
Serial.println(' ');
}
}
}
It seems that the ESP32-3248S035C has an issue where the capacitive touch does not work on every 2nd reset of the board. Adding "tp.reset()" before "tp.begin()" prevents the problem in my case. No idea why or how, but after spending half day pulling hairs from my head trying to fix it I thought I'll share this here.
It's worth to note that the same issue occurs with the example (called "LVGL_Arduino-3.5CTP-gt911.ino") provided in ESP32-3248S035C documentation (these can be downloaded from links listed in aliexpress ESP32-3248S035C descriptions), which does not use TAMC_GT911 library.
I have 4.3' TFT touch screen module from Makerfabs https://www.makerfabs.com/esp32-s3-parallel-tft-with-touch-4-3-inch.html. I am trying to use the DF2301Q module (https://www.dfrobot.com/product-2665.html) library (https://github.com/DFRobot/DFRobot_DF2301Q) with the TFT module but it does not work if the TAMC_GT911 touch library of the TFT module is in the code. The TFT module keeps restarting. If I remove the touch library from the code, the DF2301Q works with the TFT module, and if I remove the DF2301Q library from the code, the touch library works with the TFT module. I am not an expert in Arduino and cannot identify what is causing the problem. Please help me. Thank you in advance.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.