Hi,
This library is basically came with commented interrupt functions, so I uncommented the lines because I want to use it with my EA7013 ESP32 TFT display model.
So I got this error, but I don't know how to solve it.
- Header code:
class TAMC_GT911 {
public:
TAMC_GT911(uint8_t _sda, uint8_t _scl, uint8_t _int, uint8_t _rst, uint16_t _width, uint16_t _height);
void begin(uint8_t _addr = GT911_ADDR1);
void reset();
void setResolution(uint16_t _width, uint16_t _height);
// void setOnRead(void (*isr)());
void read(void);
private:
static void IRAM_ATTR onInterrupt();
TP_Point readPoint(uint8_t *data);
void (*onRead)();
void setOnRead(void (*isr)());
...
};
- Source code:
void TAMC_GT911::reset() {
pinMode(pinInt, OUTPUT);
pinMode(pinRst, OUTPUT);
digitalWrite(pinInt, 0);
digitalWrite(pinRst, 0);
delay(10);
digitalWrite(pinInt, addr==GT911_ADDR2);
delay(1);
digitalWrite(pinRst, 1);
delay(5);
digitalWrite(pinInt, 0);
delay(50);
pinMode(pinInt, INPUT);
attachInterrupt(pinInt, onInterrupt, RISING);
delay(50);
readBlockData(configBuf, GT911_CONFIG_START, GT911_CONFIG_SIZE);
setResolution(width, height);
}
void IRAM_ATTR TAMC_GT911::onInterrupt() {
read();
//TAMC_GT911::onRead();
}
void TAMC_GT911::setOnRead(void (*isr)()) {
onRead = isr;
}
void TAMC_GT911::read(void) {
uint8_t data[7];
uint8_t id;
uint16_t x, y, size;
uint8_t pointInfo = readByteData(GT911_POINT_INFO);
uint8_t bufferStatus = pointInfo >> 7 & 1;
uint8_t proximityValid = pointInfo >> 5 & 1;
uint8_t haveKey = pointInfo >> 4 & 1;
isLargeDetect = pointInfo >> 6 & 1;
touches = pointInfo & 0xF;
isTouched = touches > 0;
if (bufferStatus == 1 && isTouched) {
for (uint8_t i=0; i<touches; i++) {
readBlockData(data, GT911_POINT_1 + i * 8, 7);
points[i] = readPoint(data);
}
}
writeByteData(GT911_POINT_INFO, 0);
}
Also, IRAM_ATTR
was ARDUINO_ISR_ATTR
, but it caused an error so I changed it to IRAM_ATTR
.
When I compile the code I get this error:
Arduino: 1.8.19 (Windows 10), Board: "ESP32S3 Dev Module, Disabled, OPI PSRAM, QIO 80MHz, 4MB (32Mb), Core 1, Core 1, Hardware CDC and JTAG, Disabled, Disabled, Disabled, UART0 / Hardware CDC, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi), 921600, None, Enabled"
E:\Programs_Files\Arduino\libraries\gt911-arduino-main\TAMC_GT911.cpp: In static member function 'static void TAMC_GT911::onInterrupt()':
E:\Programs_Files\Arduino\libraries\gt911-arduino-main\TAMC_GT911.cpp:68:8: error: cannot call member function 'void TAMC_GT911::read()' without object
read();
^
exit status 1
Error compiling for board ESP32S3 Dev Module.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.