/**
ESP32s3 adaptation by Tyeth Gundry of Arduino version of
First demo for FT6206 Capactive Touch Screen on Wokwi. Enjoy!
https://wokwi.com/arduino/projects/311598148845830720
*/
/***************************************************
This is our touchscreen painting example for the Adafruit ILI9341
captouch shield
----> http://www.adafruit.com/products/1947
Check out the links above for our tutorials and wiring diagrams
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
MIT license, all text above must be included in any redistribution
****************************************************/
#include <Adafruit_GFX.h> // Core graphics library
#include <SPI.h> // this is needed for display
#include <Adafruit_ILI9341.h>
#include <Arduino.h> // this is needed for FT6206
#include <Adafruit_FT6206.h>
// The FT6206 uses hardware I2C (SCL/SDA)
Adafruit_FT6206 ctp = Adafruit_FT6206();
// // The display also uses hardware SPI, plus #9 & #10
// #define TFT_CS 10
// #define TFT_DC 9
#define TFT_DC 2
#define TFT_CS 15
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
#define BUTTON_A 16
#define BUTTON_B 17
#define BUTTON_C 18
TS_Point p_current;
TS_Point p_prev;
void setup() {
//while (!Serial); // used for leonardo debugging
Serial.begin(115200);
Serial.println(F("Cap Touch Paint!"));
Wire.setPins(10, 8); // redefine first I2C port to be on pins 10/8
tft.begin();
if (! ctp.begin(40)) { // pass in 'sensitivity' coefficient
Serial.println("Couldn't start FT6206 touchscreen controller");
while (1);
}
Serial.println("Capacitive touchscreen started");
tft.fillScreen(ILI9341_BLACK);
tft.setRotation(2);
pinMode(BUTTON_A, INPUT_PULLUP);
pinMode(BUTTON_B, INPUT_PULLUP);
pinMode(BUTTON_C, INPUT_PULLUP);
}
void loop() {
// Wait for a touch
if (ctp.touched()) {
p_current = ctp.getPoint();
if (p_current!=p_prev){
Serial.printf("x:%d, y:%d \r\n", p_current.x, p_current.y);
tft.drawPixel(p_current.x, p_current.y, ILI9341_WHITE);
}
p_prev = p_current;
}
if (!digitalRead(BUTTON_A)){
Serial.printf("Button A pressed");
}
if (!digitalRead(BUTTON_B)){
Serial.printf("Button B pressed");
}
if (!digitalRead(BUTTON_C)){
Serial.printf("Button C pressed");
}
delay(10);
}
Loading
esp32-s3-devkitc-1
esp32-s3-devkitc-1
Loading
ili9341-cap-touch
ili9341-cap-touch