#include "Adafruit_ILI9341.h"
// ESP32-WROOM
#define TFT_CS 5
#define TFT_RST 4
#define TFT_DC 2
// Farben
#define SCHWARZ 0x0000
#define WEISS 0xFFFF
#define BLAU 0x001F
#define ROT 0xF800
#define GRUEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define GELB 0xFFE0
#define BRAUN 0x9A60
#define GRAU 0x7BEF
#define GRUENGELB 0xB7E0
#define DUNKELCYAN 0x03EF
#define ORANGE 0xFDA0
#define PINK 0xFE19
#define BORDEAUX 0xA000
#define HELLBLAU 0x867D
#define VIOLETT 0x915C
#define SILBER 0xC618
#define GOLD 0xFEA0
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void setup()
{
// Zufallsgenerator starten
randomSeed(analogRead(A0));
Serial.begin(9600);
delay(500);
Serial.println("Bildschirm: " + String(tft.height()) + " x " + String(tft.width()));
// TFT starten
tft.begin();
// Rotation anpassen
tft.setRotation(0);
// schwarzer Hintergrund
tft.fillScreen(SCHWARZ);
}
void loop()
{
// interne Textdarstellung
tft.setTextSize(1);
tft.setCursor(1, 5);
tft.setTextColor(BLAU);
tft.print("Text");
delay(500);
tft.setTextSize(3);
tft.setCursor(1, 40);
tft.setTextColor(GRUEN);
tft.print("Text");
delay(500);
tft.setTextSize(5);
tft.setCursor(1, 70);
tft.setTextColor(ROT);
tft.print("Text");
delay(500);
tft.setTextSize(7);
tft.setCursor(1, 120);
tft.setTextColor(GELB);
tft.print("Text");
delay(500);
tft.setTextSize(9);
tft.setCursor(1, 200);
tft.setTextColor(GRAU);
tft.print("Text");
delay(2000);
// Sonderzeichen darstellen
tft.fillScreen(SCHWARZ);
tft.setTextColor(WEISS);
tft.setCursor(10, 20);
tft.setTextSize(3);
// Großstädte
tft.println();
tft.print("Gro");
tft.write(0xe);
tft.print("st");
tft.write(0x84);
tft.print("dte");
// Düsseldorf
tft.println();
tft.print("D");
tft.write(0x81);
tft.print("sseldorf");
// Köln
tft.println();
tft.print("K");
tft.write(0x94);
tft.println("ln");
tft.println();
tft.println("Temperatur:");
tft.print("20");
tft.write(0xf7);
tft.print("C");
delay(2000);
// zufällige Pixel
tft.fillScreen(SCHWARZ);
for (int i = 0; i < 700; i++)
{
int PixelX = random(1, tft.width());
int PixelY = random(1, tft.height());
tft.drawPixel(PixelX, PixelY, tft.color565(random(255),random(255),random(255)));
delay(5);
}
delay(2000);
// Linien ziehen
tft.fillScreen(SCHWARZ);
for (int i = 1; i < tft.height(); i+=10)
{
tft.drawLine(1, i, tft.width(), i, ORANGE);
}
delay(2000);
// Kreise vom Mittelpunkt zeichnen
tft.fillScreen(SCHWARZ);
for (int i = 1; i < tft.width() / 2; i+=10)
{
tft.fillCircle(tft.width() / 2, tft.height() / 2, tft.width() / 2 - i, tft.color565(random(255),random(255),random(255)));
delay(50);
}
delay(2000);
// Rechtecke zeichnen
tft.fillScreen(SCHWARZ);
for (int i = 1; i < tft.width(); i+=10)
{
tft.drawRect(tft.width() / 2 - i / 2, tft.height() / 2 - i / 2 , i, i, tft.color565(random(255),random(255),random(255)));
}
delay(2000);
// ausgefüllte Rechtecke zeichnen
tft.fillScreen(SCHWARZ);
for (int i = 1; i < tft.width() / 2; i+=10)
{
tft.fillRect(i, i, i, i, tft.color565(random(255),random(255),random(255)));
delay(50);
}
delay(2000);
// Dreiecke
tft.fillScreen(SCHWARZ);
for (int i = 1; i <tft.width(); i+=10)
{
tft.fillTriangle(i, i, 100, 100, 1, tft.width(), tft.color565(random(255),random(255),random(255)));
delay(50);
}
delay(2000);
tft.fillScreen(SCHWARZ);
}