#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <SPI.h>
// ✅ SAFE PINS (ESP32-C3)
#define TFT_CS 7
#define TFT_RST 2
#define TFT_DC 3
#define TFT_SCLK 4
#define TFT_MOSI 6
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
// Colors
#define BLACK 0x0000
#define WHITE 0xFFFF
#define BLUE 0x001F
#define YELLOW 0xFFE0
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define PINK 0xF81F
#define ORANGE 0xFD20
#define CLOUD 0xFFFF
void setup() {
SPI.begin(TFT_SCLK, -1, TFT_MOSI, TFT_CS);
tft.initR(INITR_MINI160x80);
tft.setRotation(3); // 🔥 IMPORTANT FIX
tft.fillScreen(BLACK);
drawUI();
}
void loop() {
}
// ================= UI =================
void drawUI() {
tft.fillScreen(BLACK);
// City
tft.setTextSize(2);
tft.setTextColor(CYAN);
tft.setCursor(5, 5);
tft.print("London");
// Day
tft.setTextSize(1);
tft.setTextColor(ORANGE);
tft.setCursor(95, 5);
tft.print("Friday");
// Weather
tft.setTextColor(WHITE);
tft.setCursor(5, 25);
tft.print("Clouds");
// Date
tft.setTextColor(BLUE);
tft.setCursor(85, 20);
tft.print("13/03/2026");
// Time (BIG)
tft.setTextSize(2);
tft.setTextColor(CYAN);
tft.setCursor(60, 33);
tft.print("12:00:54");
// Labels
tft.setTextSize(1);
tft.setTextColor(PINK);
tft.setCursor(10, 53);
tft.print("Press");
tft.setCursor(65, 53);
tft.print("Temp");
tft.setCursor(120, 53);
tft.print("Humi");
// Values
tft.setTextColor(WHITE);
tft.setCursor(10, 65);
tft.print("998hPa");
tft.setTextColor(BLUE);
tft.setCursor(65, 65);
tft.print("38.6C");
tft.setTextColor(ORANGE);
tft.setCursor(120, 65);
tft.print("80%");
// Draw Weather Icon
//drawWeatherIcon(35, 55);
}
// ================= ICON =================
void drawWeatherIcon(int x, int y) {
// ☀️ Sun
tft.fillCircle(x - 8, y - 6, 5, YELLOW);
// Sun Rays
for (int i = 0; i < 360; i += 45) {
int x1 = x - 12 + cos(i * 0.0174533) * 10;
int y1 = y - 10 + sin(i * 0.0174533) * 10;
int x2 = x - 12 + cos(i * 0.0174533) * 8;
int y2 = y - 10 + sin(i * 0.0174533) * 14;
tft.drawLine(x1, y1, x2, y2, ORANGE);
}
// ☁️ Cloud (3 circles + base)
tft.fillCircle(x, y, 10, CLOUD);
tft.fillCircle(x + 8, y, 7, CLOUD);
tft.fillCircle(x + 16, y, 6, CLOUD);
tft.fillRect(x - 2, y, 20, 6, CLOUD);
}