#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 Shapes + Grid + Fonts");
SPI.begin(TFT_SCK, TFT_MISO, TFT_MOSI, TFT_CS);
ucg.begin(UCG_FONT_MODE_TRANSPARENT);
ucg.clearScreen();
ucg.setRotate90(); // Landscape orientation
// Draw grid background
ucg.setColor(50, 50, 50); // gray lines
for (int x = 0; x < ucg.getWidth(); x += 20) {
ucg.drawVLine(x, 0, ucg.getHeight());
}
for (int y = 0; y < ucg.getHeight(); y += 20) {
ucg.drawHLine(0, y, ucg.getWidth());
}
// Draw shapes
ucg.setColor(255, 0, 0); // Red triangle
ucg.drawTriangle(60, 60, 120, 160, 20, 160);
ucg.setColor(0, 0, 255); // Blue rectangle
ucg.drawBox(150, 80, 60, 40);
ucg.setColor(0, 255, 0); // Green circle
ucg.drawDisc(250, 120, 30, UCG_DRAW_ALL);
// Text in different fonts
ucg.setColor(255, 255, 0); // Yellow text
ucg.setFont(ucg_font_ncenR14_tr);
ucg.setPrintPos(40, 30);
ucg.print("HELLO, ARVIND!");
ucg.setColor(0, 255, 255); // Cyan text
ucg.setFont(ucg_font_helvB18_tr);
ucg.setPrintPos(40, 220);
ucg.print("UCGLIB DEMO");
ucg.setColor(255, 128, 0); // Orange text
ucg.setFont(ucg_font_9x15_tr);
ucg.setPrintPos(200, 200);
ucg.print("GRID + SHAPES");
}
void loop() {
// Static demo, no animation
}
Loading
esp32-2432s028r
esp32-2432s028r
https://wokwi.com/projects/462365532285332481