feat: TFT display init and splash screen
Landscape 160x80 (rotation 3, no invert) per this panel. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "display_ui.h"
|
||||||
|
|
||||||
static void i2cScan() {
|
static void i2cScan() {
|
||||||
Serial.println(F("I2C scan:"));
|
Serial.println(F("I2C scan:"));
|
||||||
@@ -21,6 +22,9 @@ void setup() {
|
|||||||
Serial.println(F("\n=== Weather Predictor booting ==="));
|
Serial.println(F("\n=== Weather Predictor booting ==="));
|
||||||
Wire.begin(I2C_SDA, I2C_SCL); // MUST come before any I2C driver begin()
|
Wire.begin(I2C_SDA, I2C_SCL); // MUST come before any I2C driver begin()
|
||||||
i2cScan();
|
i2cScan();
|
||||||
|
|
||||||
|
displayBegin();
|
||||||
|
displaySplash("Weather", "Predictor v0.1");
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#include <Adafruit_GFX.h>
|
||||||
|
#include <Adafruit_ST7735.h>
|
||||||
|
#include <SPI.h>
|
||||||
|
#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);
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
void displayBegin();
|
||||||
|
void displaySplash(const char* line1, const char* line2);
|
||||||
Reference in New Issue
Block a user