需要使用开源的一个驱动库:
git clone https://github.com/alex-code/GT911
把整个代码下载下来,然后使用:
#include "GT911.h"
GT911 tp = GT911();
void loop(){
uint8_t touches = touch.touched(GT911_MODE_POLLING);
if (touches) {
GTPoint tp = touch.getPoint(0);
// 根据屏幕的分辨率和旋转方向,调整xy
uint16_t x = 320 - tp.y;
uint16_t y = tp.x;
mySerial.printf("#%d %d,%d s:%d\n", tp.trackId, 320 - tp.y, tp.x, tp.area);
}
}