/**
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>
#include <TFT_eSPI.h>
// Only define one driver, the other ones must be commented out
#define ILI9341_DRIVER // Generic driver for common displays
//#define ILI9341_2_DRIVER // Alternative ILI9341 driver, see https://github.com/Bodmer/TFT_eSPI/issues/1172
//#define ST7735_DRIVER // Define additional parameters below for this display
//#define ILI9163_DRIVER // Define additional parameters below for this display
//#define S6D02A1_DRIVER
//#define RPI_ILI9486_DRIVER // 20MHz maximum SPI
//#define HX8357D_DRIVER
//#define ILI9481_DRIVER
//#define ILI9486_DRIVER
//#define ILI9488_DRIVER // WARNING: Do not connect ILI9488 display SDO to MISO if other devices share the SPI bus (TFT SDO does NOT tristate when CS is high)
//#define ST7789_DRIVER // Full configuration option, define additional parameters below for this display
//#define ST7789_2_DRIVER // Minimal configuration option, define additional parameters below for this display
//#define R61581_DRIVER
//#define RM68140_DRIVER
//#define ST7796_DRIVER
//#define SSD1351_DRIVER
//#define SSD1963_480_DRIVER
//#define SSD1963_800_DRIVER
//#define SSD1963_800ALT_DRIVER
//#define ILI9225_DRIVER
//#define GC9A01_DRIVER
// 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_WIDTH 60
#define BUTTON_HEIGHT 30
#define TFT_WIDTH 320
#define TFT_HEIGHT 240
TFT_eSPI tft = TFT_eSPI(TFT_WIDTH, TFT_HEIGHT); // Inicialização do display
float temperatureTarget = 0; // Temperatura alvo
float temperatureCurrent = 0; // Temperatura atual
float rotationTarget = 0; // Rotação alvo
float rotationCurrent = 0; // Rotação atual
void setup(void) {
Serial.begin(115200);
Serial.println(F("Cap Touch Paint!"));
Wire.setPins(10, 8); // redefine first I2C port to be on pins 10/8
tft.init(); // Inicialização do display
tft.setRotation(3); // Ajuste da rotação do display
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(TFT_BLACK); // Limpa a tela com a cor preta
tft.fillRect(10, 10, 50, 30, TFT_RED); // Desenha um retângulo vermelho
//drawButtonsAndText();
}
void loop() {
}
void updateDisplay() {
// Limpa o display
tft.fillScreen(TFT_BLACK);
// Desenha os botões e textos
drawButtonsAndText();
// Desenha as informações de temperatura e velocidade
tft.setCursor(10, 100);
tft.setTextSize(2);
tft.setTextColor(TFT_WHITE);
tft.print("Temperatura Alvo: ");
tft.print(temperatureTarget);
tft.setCursor(10, 120);
tft.print("Temperatura Atual: ");
tft.print(temperatureCurrent);
tft.setCursor(10, 150);
tft.print("Rotação Alvo: ");
tft.print(rotationTarget);
tft.setCursor(10, 170);
tft.print("Rotação Atual: ");
tft.print(rotationCurrent);
}
void drawButtonsAndText() {
// Desenha botões de temperatura
tft.fillRect(10, 10, BUTTON_WIDTH, BUTTON_HEIGHT, TFT_BLUE);
tft.setTextColor(TFT_WHITE);
tft.setCursor(20, 20);
tft.print("Temp +");
tft.fillRect(10, 50, BUTTON_WIDTH, BUTTON_HEIGHT, TFT_BLUE);
tft.setCursor(20, 60);
tft.print("Temp -");
// Desenha botões de velocidade
tft.fillRect(170, 10, BUTTON_WIDTH, BUTTON_HEIGHT, TFT_BLUE);
tft.setCursor(180, 20);
tft.print("Vel +");
tft.fillRect(170, 50, BUTTON_WIDTH, BUTTON_HEIGHT, TFT_BLUE);
tft.setCursor(180, 60);
tft.print("Vel -");
// Escreve os textos entre os botões
tft.setTextColor(TFT_WHITE);
tft.setTextSize(1);
tft.setCursor(80, 20);
tft.print("Temperatura");
tft.setCursor(80, 50);
tft.print("Velocidade");
// Desenha o botão de iniciar/parar no centro
tft.fillRect(100, 200, 120, 40, TFT_GREEN);
tft.setTextColor(TFT_WHITE);
tft.setTextSize(2);
tft.setCursor(110, 210);
tft.print("Start/Stop");
}