style: apply consistent code formatting and spacing

This commit is contained in:
2026-02-17 04:15:48 -08:00
parent f39364f67f
commit 8e9bd18676
13 changed files with 217 additions and 223 deletions

View File

@@ -1,8 +1,9 @@
#pragma once
#include "board_config.h"
#include <KlubhausCore.h>
#include <TFT_eSPI.h>
#include "board_config.h"
class DisplayDriverTFT : public IDisplayDriver {
public:
@@ -10,11 +11,11 @@ public:
void setBacklight(bool on) override;
void render(const ScreenState& state) override;
TouchEvent readTouch() override;
int dashboardTouch(int x, int y) override;
int dashboardTouch(int x, int y) override;
HoldState updateHold(unsigned long holdMs) override;
void updateHint(int x, int y) override;
int width() override { return DISPLAY_WIDTH; }
int height() override { return DISPLAY_HEIGHT; }
int width() override { return DISPLAY_WIDTH; }
int height() override { return DISPLAY_HEIGHT; }
private:
void drawBoot();
@@ -23,8 +24,8 @@ private:
TFT_eSPI _tft;
bool _holdActive = false;
bool _holdActive = false;
uint32_t _holdStartMs = 0;
ScreenID _lastScreen = ScreenID::BOOT;
bool _needsRedraw = true;
ScreenID _lastScreen = ScreenID::BOOT;
bool _needsRedraw = true;
};

View File

@@ -1,6 +1,6 @@
#pragma once
#define BOARD_NAME "WS_32E"
#define BOARD_NAME "WS_32E"
// ══════════════════════════════════════════════════════════
// TODO: Set these to match YOUR display + wiring.
@@ -9,12 +9,12 @@
// (which gets copied into the vendored TFT_eSPI library).
// ══════════════════════════════════════════════════════════
#define DISPLAY_WIDTH 320
#define DISPLAY_HEIGHT 240
#define DISPLAY_ROTATION 1 // landscape
#define DISPLAY_WIDTH 320
#define DISPLAY_HEIGHT 240
#define DISPLAY_ROTATION 1 // landscape
// Backlight GPIO (directly wired)
#define PIN_LCD_BL 22
#define PIN_LCD_BL 22
// Touch — if using XPT2046 via TFT_eSPI, set TOUCH_CS in tft_user_setup.h
// If using capacitive touch (e.g. FT6236), configure I2C pins here:

View File

@@ -2,14 +2,15 @@
// Klubhaus Doorbell — ESP32-32E target
//
#include <KlubhausCore.h>
#include "DisplayDriverTFT.h"
#include "board_config.h"
#include "secrets.h"
#include "DisplayDriverTFT.h"
#include <KlubhausCore.h>
DisplayDriverTFT tftDriver;
DisplayManager display(&tftDriver);
DoorbellLogic logic(&display);
DisplayManager display(&tftDriver);
DoorbellLogic logic(&display);
void setup() {
Serial.begin(115200);
@@ -31,19 +32,19 @@ void loop() {
static int holdStartX = -1;
static int holdStartY = -1;
if (st.deviceState == DeviceState::ALERTING) {
if(st.deviceState == DeviceState::ALERTING) {
HoldState h = display.updateHold(HOLD_TO_SILENCE_MS);
if (h.completed) {
if(h.completed) {
logic.silenceAlert();
holdStartX = -1;
holdStartY = -1;
}
if (h.started) {
if(h.started) {
TouchEvent t = display.readTouch();
holdStartX = t.x;
holdStartY = t.y;
}
if (!h.active && holdStartX >= 0) {
if(!h.active && holdStartX >= 0) {
display.updateHint(holdStartX, holdStartY);
}
} else {
@@ -51,18 +52,20 @@ void loop() {
holdStartY = -1;
}
if (st.screen == ScreenID::DASHBOARD) {
if(st.screen == ScreenID::DASHBOARD) {
TouchEvent evt = display.readTouch();
if (evt.pressed) {
if(evt.pressed) {
int tile = display.dashboardTouch(evt.x, evt.y);
if (tile >= 0) Serial.printf("[DASH] Tile %d tapped\n", tile);
if(tile >= 0)
Serial.printf("[DASH] Tile %d tapped\n", tile);
}
}
// ── Serial console ──
if (Serial.available()) {
if(Serial.available()) {
String cmd = Serial.readStringUntil('\n');
cmd.trim();
if (cmd.length() > 0) logic.onSerialCommand(cmd);
if(cmd.length() > 0)
logic.onSerialCommand(cmd);
}
}

View File

@@ -11,27 +11,27 @@
// ── Resolution ──
// FIXED: Match board_config.h (320x240 landscape)
#define TFT_WIDTH 320
#define TFT_WIDTH 320
#define TFT_HEIGHT 240
// ── SPI Pins ──
#define TFT_MOSI 23
#define TFT_SCLK 18
#define TFT_CS 5
#define TFT_DC 27
#define TFT_RST 33
#define TFT_MOSI 23
#define TFT_SCLK 18
#define TFT_CS 5
#define TFT_DC 27
#define TFT_RST 33
// ── Backlight (optional, can also use GPIO directly) ──
// #define TFT_BL 22
// #define TFT_BACKLIGHT_ON HIGH
// ── Touch (XPT2046 resistive) ──
#define TOUCH_CS 14
#define TOUCH_CS 14
// ── SPI speed ──
#define SPI_FREQUENCY 40000000
#define SPI_READ_FREQUENCY 20000000
#define SPI_TOUCH_FREQUENCY 2500000
#define SPI_FREQUENCY 40000000
#define SPI_READ_FREQUENCY 20000000
#define SPI_TOUCH_FREQUENCY 2500000
// ── Misc ──
#define LOAD_GLCD