#include <SPI.h>
#include <Ucglib.h>
// Pin mapping for ESP32-2432S028 (CYD)
#define TFT_CS 15
#define TFT_DC 2
#define TFT_RST -1 // Not connected
#define TFT_SCK 14
#define TFT_MOSI 13
#define TFT_MISO 12
// UCGLib constructor for ILI9341 SPI (hardware SPI)
Ucglib_ILI9341_18x240x320_HWSPI ucg(/*cd=*/TFT_DC, /*cs=*/TFT_CS, /*reset=*/TFT_RST);
void setup() {
Serial.begin(115200);
Serial.println("ESP32-2432S028 UCGLib Awesome Art");
SPI.begin(TFT_SCK, TFT_MISO, TFT_MOSI, TFT_CS);
ucg.begin(UCG_FONT_MODE_TRANSPARENT);
ucg.clearScreen();
ucg.setRotate270(); // Landscape orientation
}
// Gradient background
void gradientScene() {
for (int x = 0; x < ucg.getWidth(); x++) {
ucg.setColor(x % 255, (x*2) % 255, (255-x) % 255);
ucg.drawVLine(x, 0, ucg.getHeight());
}
ucg.setFont(ucg_font_helvB18_tr);
ucg.setColor(255, 255, 255);
ucg.setPrintPos(40, 40);
ucg.print("CINEMATIC GRADIENT");
delay(3000);
}
// Geometric art
void geometricScene() {
ucg.clearScreen();
for (int i = 0; i < 10; i++) {
ucg.setColor((i*25)%255, (i*50)%255, (i*75)%255);
ucg.drawCircle(160, 120, i*10, UCG_DRAW_ALL);
ucg.drawBox(40+i*10, 60+i*5, 40, 40);
}
ucg.setFont(ucg_font_ncenR14_tr);
ucg.setColor(255, 255, 0);
ucg.setPrintPos(60, 220);
ucg.print("GEOMETRIC ART");
delay(3000);
}
// Grid rainbow scene
void rainbowGridScene() {
ucg.clearScreen();
for (int x = 0; x < ucg.getWidth(); x += 20) {
ucg.setColor((x*3)%255, (x*5)%255, (x*7)%255);
ucg.drawVLine(x, 0, ucg.getHeight());
}
for (int y = 0; y < ucg.getHeight(); y += 20) {
ucg.setColor((y*7)%255, (y*3)%255, (y*5)%255);
ucg.drawHLine(0, y, ucg.getWidth());
}
ucg.setFont(ucg_font_9x15_tr);
ucg.setColor(0, 255, 255);
ucg.setPrintPos(100, 100);
ucg.print("RAINBOW GRID");
delay(3000);
}
void loop() {
gradientScene();
geometricScene();
rainbowGridScene();
}
Loading
esp32-2432s028r
esp32-2432s028r
https://wokwi.com/projects/462366218764026881