refactor: move TileLayoutHelper from DisplayManager.h to Style.h

- Pure static helper class moved from DisplayManager.h to Style.h
- Drivers now use TileLayoutHelper::calculateLayouts() directly
- Remove extern DisplayManager references from display drivers
- Drop LGFX_USE_V1 build flag (no longer needed)
- Add delay(LOOP_YIELD_MS) in S3 loop to prevent watchdog
This commit is contained in:
2026-05-29 20:17:15 -07:00
parent 3d17e7bab9
commit 14781b8c07
6 changed files with 134 additions and 131 deletions
+6 -6
View File
@@ -3,8 +3,7 @@
#include <Arduino.h>
#include <KlubhausCore.h>
#include <TFT_eSPI.h>
extern DisplayManager display;
#include <Style.h>
// ── Fonts ───────────────────────────────────────────────────
// TFT_eSPI built-in fonts for 320x480 display (scaled from 800x480)
@@ -257,10 +256,11 @@ void DisplayDriverTFT::drawDashboard(const ScreenState& st) {
_tft.setCursor(dispW - wifiW - 10, 20);
_tft.print(wifiText);
// Get tile layouts from library helper
int tileCount = display.calculateDashboardLayouts(STYLE_HEADER_HEIGHT, STYLE_TILE_GAP);
display.setHeaderHeight(STYLE_HEADER_HEIGHT);
const TileLayout* layouts = display.getTileLayouts();
// Calculate tile layouts using TileLayoutHelper
TileLayout layouts[DASHBOARD_TILE_COUNT];
int gridCols, gridRows;
int tileCount = TileLayoutHelper::calculateLayouts(
dispW, dispH, STYLE_HEADER_HEIGHT, STYLE_TILE_GAP, layouts, &gridCols, &gridRows);
const char* tileLabels[] = { "Alert", "Silent", "Status", "Reboot" };
const uint16_t tileColors[] = { 0x0280, 0x0400, 0x0440, 0x0100 };
+6 -5
View File
@@ -6,10 +6,10 @@
#include <Arduino.h>
#include <KlubhausCore.h>
#include <Style.h>
// ── Globals ──
static LGFX* _gfx = nullptr;
extern DisplayManager display;
// ── Forward declarations ──
static void initDisplay();
@@ -443,10 +443,11 @@ void DisplayDriverGFX::drawDashboard(const ScreenState& state) {
},
safeWifi.w);
// Get tile layouts from library helper
int tileCount = display.calculateDashboardLayouts(STYLE_HEADER_HEIGHT, STYLE_TILE_GAP);
display.setHeaderHeight(STYLE_HEADER_HEIGHT);
const TileLayout* layouts = display.getTileLayouts();
// Calculate tile layouts using TileLayoutHelper
TileLayout layouts[DASHBOARD_TILE_COUNT];
int gridCols, gridRows;
int tileCount = TileLayoutHelper::calculateLayouts(
DISP_W, DISP_H, STYLE_HEADER_HEIGHT, STYLE_TILE_GAP, layouts, &gridCols, &gridRows);
const char* tileLabels[] = { "Alert", "Silent", "Status", "Reboot" };
const uint16_t tileColors[] = { 0x0280, 0x0400, 0x0440, 0x0100 };
+1 -1
View File
@@ -1,4 +1,4 @@
FQBN="esp32:esp32:waveshare_esp32_s3_touch_lcd_43:PSRAM=enabled,FlashSize=16M,USBMode=hwcdc,PartitionScheme=app3M_fat9M_16MB"
PORT="/dev/ttyUSB0"
LIBS="--library ./vendor/esp32-s3-lcd-43/LovyanGFX"
OPTS="-DDEBUG_MODE -DBOARD_HAS_PSRAM -DLGFX_USE_V1 -DLOCAL_SECRETS"
OPTS="-DDEBUG_MODE -DBOARD_HAS_PSRAM -DLOCAL_SECRETS"
@@ -38,4 +38,7 @@ void loop() {
// Serial console
logic.processSerial();
// Yield to WiFi/BT stack
delay(LOOP_YIELD_MS);
}