/**
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 <TFT_eSPI.h>
#include <SPI.h> // this is needed for display
#include <Wire.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 15
#define TFT_DC 2
#define TFT_MOSI 23
#define TFT_SCLK 18
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library with default width and height
#define ILI9341_RED TFT_RED
#define ILI9341_YELLOW TFT_YELLOW
#define ILI9341_GREEN TFT_GREEN
#define ILI9341_CYAN TFT_CYAN
#define ILI9341_BLUE TFT_BLUE
#define ILI9341_MAGENTA TFT_MAGENTA
// Size of the color selection boxes and the paintbrush size
#define BOXSIZE 40
#define PENRADIUS 3
int oldcolor, currentcolor;
void setup(void) {
Serial.begin(115200);
tft.begin();
if (!ctp.begin(40)) { // pass in 'sensitivity' coefficient
Serial.println("Couldn't start FT6206 touchscreen controller");
while (1);
}
tft.fillScreen(ILI9341_BLACK);
// make the color selection boxes
tft.drawRect(19, 19, 52, 32, ILI9341_RED);
tft.fillRect(20, 20, 50, 30, ILI9341_GREEN);
tft.drawCircle(150, 50, 20, ILI9341_RED);
tft.fillCircle(150, 50, 19, ILI9341_GREEN);
}
void loop() {
}
// Wait for a touch
// if (! ctp.touched()) {
// delay(10); // Speeds up the simulation
// return;
// }
// Retrieve a point
// TS_Point p = ctp.getPoint();
// 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);