refactor(Format code): Improve readability and structure

This commit is contained in:
2026-02-18 17:57:54 -08:00
parent c81e23f7cd
commit e4609c6978
11 changed files with 120 additions and 136 deletions

View File

@@ -1,4 +1,5 @@
#include "DisplayDriverTFT.h"
#include <KlubhausCore.h>
extern DisplayManager display;
@@ -35,7 +36,8 @@ void DisplayDriverTFT::setBacklight(bool on) { digitalWrite(PIN_LCD_BL, on ? HIG
// ── Rendering ───────────────────────────────────────────────
void DisplayDriverTFT::render(const ScreenState& st) {
if(st.screen != _lastScreen || (st.screen == ScreenID::BOOT && st.bootStage != _lastBootStage)) {
if(st.screen != _lastScreen
|| (st.screen == ScreenID::BOOT && st.bootStage != _lastBootStage)) {
_needsRedraw = true;
_lastScreen = st.screen;
_lastBootStage = st.bootStage;
@@ -162,7 +164,7 @@ void DisplayDriverTFT::drawDashboard(const ScreenState& st) {
_tft.setTextSize(2);
int textLen = strlen(tileLabels[i]);
int textW = textLen * 12;
_tft.setCursor(x + w/2 - textW/2, y + h/2 - 10);
_tft.setCursor(x + w / 2 - textW / 2, y + h / 2 - 10);
_tft.print(tileLabels[i]);
}
}
@@ -202,9 +204,7 @@ TouchEvent DisplayDriverTFT::readTouch() {
return evt;
}
uint16_t DisplayDriverTFT::getRawTouchZ() {
return _tft.getTouchRawZ();
}
uint16_t DisplayDriverTFT::getRawTouchZ() { return _tft.getTouchRawZ(); }
void DisplayDriverTFT::transformTouch(int* x, int* y) {
// Resistive touch panel is rotated 90° vs display - swap coordinates

View File

@@ -25,7 +25,8 @@ void DisplayDriverTFT::setBacklight(bool on) { digitalWrite(PIN_LCD_BL, on ? HIG
// ── Rendering ───────────────────────────────────────────────
void DisplayDriverTFT::render(const ScreenState& st) {
if(st.screen != _lastScreen || (st.screen == ScreenID::BOOT && st.bootStage != _lastBootStage)) {
if(st.screen != _lastScreen
|| (st.screen == ScreenID::BOOT && st.bootStage != _lastBootStage)) {
_needsRedraw = true;
_lastScreen = st.screen;
_lastBootStage = st.bootStage;

View File

@@ -151,7 +151,8 @@ void DisplayDriverGFX::render(const ScreenState& state) {
return;
// Check if we need full redraw
if(state.screen != _lastScreen || (state.screen == ScreenID::BOOT && state.bootStage != _lastBootStage)) {
if(state.screen != _lastScreen
|| (state.screen == ScreenID::BOOT && state.bootStage != _lastBootStage)) {
_needsRedraw = true;
_lastScreen = state.screen;
_lastBootStage = state.bootStage;
@@ -284,7 +285,7 @@ void DisplayDriverGFX::drawDashboard(const ScreenState& state) {
// Tile label
_gfx->setTextColor(0xFFFF);
_gfx->setTextSize(2);
_gfx->setCursor(x + w/2 - 10, y + h/2 - 10);
_gfx->setCursor(x + w / 2 - 10, y + h / 2 - 10);
_gfx->print(tileLabels[i]);
}
}

View File

@@ -18,6 +18,9 @@ public:
int width() override;
int height() override;
// Dashboard tile mapping
int dashboardTouch(int x, int y);
// ── Internal ──
static DisplayDriverGFX& instance();

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/ttyACM0"
LIBS="--libraries ./vendor/esp32-s3-lcd-43/LovyanGFX"
LIBS="--libraries ~/Arduino/libraries/LovyanGFX"
OPTS="-DDEBUG_MODE -DBOARD_HAS_PSRAM -DLGFX_USE_V1"