#include <TFT_eSPI.h>
#include <SPI.h>
// --- Pin Connections for ESP32-C3 Mini + ILI9341 ---
// VCC -> 3.3V
// GND -> GND
// CS -> GPIO10
// DC -> GPIO6
// RST -> GPIO7
// MOSI -> GPIO4
// MISO -> GPIO5 (optional, for read ops)
// SCK -> GPIO3
// Define pins in TFT_eSPI User_Setup.h
// #define TFT_MISO 5
// #define TFT_MOSI 4
// #define TFT_SCLK 3
// #define TFT_CS 10
// #define TFT_DC 6
// #define TFT_RST 7
TFT_eSPI tft = TFT_eSPI(); // Create TFT instance
void setup() {
tft.init();
tft.setRotation(1); // Landscape orientation, upright text
tft.fillScreen(TFT_BLACK);
// Splash screen
tft.setTextColor(TFT_YELLOW, TFT_BLACK);
tft.setTextDatum(MC_DATUM);
tft.drawString("ESP32-C3 + ILI9341", 120, 160, 2);
delay(2000);
}
void loop() {
// Test 1: Color bars
for (int i = 0; i < tft.height(); i++) {
uint16_t color = tft.color565(i % 32 * 8, i % 64 * 4, i % 32 * 8);
tft.drawFastHLine(0, i, tft.width(), color);
}
delay(2000);
// Test 2: Gradient fill
for (int x = 0; x < tft.width(); x++) {
uint16_t color = tft.color565(x % 64 * 4, 128, 255 - (x % 64 * 4));
tft.drawFastVLine(x, 0, tft.height(), color);
}
delay(2000);
// Test 3: Shapes
tft.fillScreen(TFT_BLACK);
tft.fillCircle(60, 60, 40, TFT_RED);
tft.fillRect(120, 40, 80, 60, TFT_BLUE);
tft.drawTriangle(40, 200, 120, 200, 80, 120, TFT_GREEN);
delay(2000);
// Test 4: Text showcase
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.drawString("Graphics Test", 10, 10, 4);
tft.drawString("AI Centre Nandurbar", 10, 60, 2);
delay(2000);
}