#include <Adafruit_GFX.h>
#include <Adafruit_ST7789.h>
#include <SPI.h>
#define TFT_CS 5
#define TFT_RST 4
#define TFT_DC 2
#define TFT_SCLK 12
#define TFT_MOSI 11
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
void setup() {
Serial.begin(115200);
tft.init(240, 280); // Init ST7789 280x240
tft.setRotation(2);
tft.fillScreen(ST77XX_BLACK);
tft.setTextColor(ST77XX_YELLOW);
tft.setTextSize(2);
tft.setCursor(20, 20);
tft.println("ESP32-S3 Benchmark Demo");
}
void loop() {
// --- Fast rainbow gradient sweep ---
for (int c = 0; c < 256; c += 8) {
tft.fillScreen(tft.color565(c, 255 - c, c / 2));
delay(5);
}
// --- Color fills benchmark ---
tft.fillScreen(ST77XX_RED);
delay(20);
tft.fillScreen(ST77XX_GREEN);
delay(20);
tft.fillScreen(ST77XX_BLUE);
delay(20);
tft.fillScreen(ST77XX_BLACK);
// --- Circles ---
for (int r = 10; r < 120; r += 10) {
tft.drawCircle(tft.width()/2, tft.height()/2, r, ST77XX_CYAN);
}
// --- Filled rectangles ---
for (int i = 0; i < 6; i++) {
tft.fillRect(20 + i*30, 80, 30, 30, tft.color565(40*i, 200-20*i, 100+15*i));
}
// --- Triangles ---
for (int i = 0; i < 6; i++) {
tft.drawTriangle(20+i*30, 200, 60+i*30, 240, 100+i*30, 200, ST77XX_MAGENTA);
}
// --- Text test ---
tft.setTextColor(ST77XX_WHITE);
tft.setTextSize(2);
tft.setCursor(30, 260);
tft.println("Graphics Cycle Done!");
// --- Blink invert to show hardware effect ---
for (int i = 0; i < 4; i++) {
tft.invertDisplay(true);
delay(100);
tft.invertDisplay(false);
delay(100);
}
}
#define TFT_CS 5
#define TFT_RST 4
#define TFT_DC 2
#define TFT_SCLK 12
#define TFT_MOSI 11
https://wokwi.com/projects/466165238744007681