From 906adaddfe16317dbf8eeabfaafc3f8207bb2d14 Mon Sep 17 00:00:00 2001 From: Vitali Date: Fri, 17 Jul 2026 19:39:13 +0700 Subject: [PATCH] feat: TFT display init and splash screen Landscape 160x80 (rotation 3, no invert) per this panel. Co-Authored-By: Claude Opus 4.8 --- WeatherPredictor/WeatherPredictor.ino | 4 ++++ WeatherPredictor/display_ui.cpp | 27 +++++++++++++++++++++++++++ WeatherPredictor/display_ui.h | 5 +++++ 3 files changed, 36 insertions(+) create mode 100644 WeatherPredictor/display_ui.cpp create mode 100644 WeatherPredictor/display_ui.h diff --git a/WeatherPredictor/WeatherPredictor.ino b/WeatherPredictor/WeatherPredictor.ino index 9e777ab..b4504b1 100644 --- a/WeatherPredictor/WeatherPredictor.ino +++ b/WeatherPredictor/WeatherPredictor.ino @@ -1,6 +1,7 @@ #include #include #include "config.h" +#include "display_ui.h" static void i2cScan() { Serial.println(F("I2C scan:")); @@ -21,6 +22,9 @@ void setup() { Serial.println(F("\n=== Weather Predictor booting ===")); Wire.begin(I2C_SDA, I2C_SCL); // MUST come before any I2C driver begin() i2cScan(); + + displayBegin(); + displaySplash("Weather", "Predictor v0.1"); } void loop() { diff --git a/WeatherPredictor/display_ui.cpp b/WeatherPredictor/display_ui.cpp new file mode 100644 index 0000000..58e72ec --- /dev/null +++ b/WeatherPredictor/display_ui.cpp @@ -0,0 +1,27 @@ +#include +#include +#include +#include "config.h" +#include "display_ui.h" + +static Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); + +void displayBegin() { + pinMode(TFT_BLK, OUTPUT); + digitalWrite(TFT_BLK, HIGH); // backlight on + tft.initR(INITR_MINI160x80); // 0.96" 80x160 ST7735S + tft.invertDisplay(false); // this panel needs inversion; flip if colours look wrong + tft.setRotation(3); // portrait, 80 wide x 160 tall + tft.fillScreen(ST77XX_BLACK); +} + +void displaySplash(const char* line1, const char* line2) { + tft.fillScreen(ST77XX_BLACK); + tft.setTextColor(ST77XX_WHITE); + tft.setTextSize(2); + tft.setCursor(4, 40); + tft.print(line1); + tft.setTextSize(1); + tft.setCursor(4, 70); + tft.print(line2); +} diff --git a/WeatherPredictor/display_ui.h b/WeatherPredictor/display_ui.h new file mode 100644 index 0000000..c21b7a2 --- /dev/null +++ b/WeatherPredictor/display_ui.h @@ -0,0 +1,5 @@ +#pragma once +#include + +void displayBegin(); +void displaySplash(const char* line1, const char* line2);