#include <SPI.h>
#include <Adafruit_FT6206.h>
#include <Adafruit_ILI9341.h>
#include <Wire.h>
#include <Arduino_GFX_Library.h>
#define TFT_CS 0
#define TFT_DC 2
#define TFT_RST 15
#define TFT_LED 1
#define TFT_SCK 14
#define TFT_MOSI 13
#define TFT_MISO 12
Arduino_ESP32SPI bus = Arduino_ESP32SPI(TFT_DC, TFT_CS, TFT_SCK, TFT_MOSI, TFT_MISO);
Arduino_ILI9341 tft = Arduino_ILI9341(&bus, TFT_RST);
Adafruit_FT6206 ctp = Adafruit_FT6206();
void setup() {
Serial.begin(115200);
tft.begin();
if (!ctp.begin(40)) {
Serial.println("lknfs");;
}
tft.setCursor(20,20);
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(3);
tft.print("a");
}
void loop() {
TS_Point p = ctp.getPoint();
if (ctp.touched()) {
// flip it around to match the screen.
p.x = map(p.x, 0, 240, 240, 0);
p.y = map(p.y, 0, 320, 320, 0);
Serial.println(p.x);
}
delay(10); }