#include <SPI.h>
#include <Ucglib.h>
// ===============================
// CYD ESP32-2432S028
// WORKING Ucglib TEST
// ===============================
// TFT PINS
#define TFT_CS 15
#define TFT_DC 2
#define TFT_RST -1
// RGB LED
#define LED_R 4
#define LED_G 16
#define LED_B 17
// ==========================================
// IMPORTANT:
// THIS constructor works on most CYD boards
// ==========================================
Ucglib_ILI9341_18x240x320_HWSPI ucg(
TFT_DC,
TFT_CS,
TFT_RST
);
// ==========================================
// RGB
// ==========================================
void setRGB(bool r, bool g, bool b) {
digitalWrite(LED_R, r ? LOW : HIGH);
digitalWrite(LED_G, g ? LOW : HIGH);
digitalWrite(LED_B, b ? LOW : HIGH);
}
// ==========================================
// SETUP
// ==========================================
void setup() {
Serial.begin(115200);
pinMode(LED_R, OUTPUT);
pinMode(LED_G, OUTPUT);
pinMode(LED_B, OUTPUT);
setRGB(true,false,false);
// IMPORTANT
SPI.begin(14, 12, 13, 15);
ucg.begin(UCG_FONT_MODE_TRANSPARENT);
ucg.clearScreen();
// Background
ucg.setColor(0,0,80);
ucg.drawBox(0,0,320,240);
// Text
ucg.setFont(ucg_font_ncenR14_tr);
ucg.setColor(255,255,0);
ucg.setPrintPos(35,90);
ucg.print("CODE BY ARVIND");
ucg.setColor(0,255,255);
ucg.setPrintPos(18,140);
ucg.print("AI CENTRE NANDURBAR");
// Graphics
for(int i=0;i<100;i++){
ucg.setColor(
random(255),
random(255),
random(255)
);
ucg.drawCircle(
random(320),
random(240),
random(5,40),
UCG_DRAW_ALL
);
}
setRGB(false,true,false);
}
// ==========================================
// LOOP
// ==========================================
void loop() {
for(int i=0;i<1000;i++){
ucg.setColor(
random(255),
random(255),
random(255)
);
ucg.drawPixel(
random(320),
random(240)
);
}
}https://wokwi.com/projects/464273894944083969
https://wokwi.com/projects/464274205433771009