Fix ESP32-S3 LCD timing, add diagnostics, scaffold script

1. **Display timing fixes for ESP32-S3-LCD-4.3**
   - Corrected RGB panel timing parameters (hsync/vsync porch values)
   - **Critical fix**: Set `pclk_active_neg = 1` (required for ST7262 panel)
   - Added explicit PCLK speed of 16MHz
   - These changes fix the blank/unstable display issue on Waveshare 4.3" boards

2. **Added memory diagnostics**
   - Prints free heap and PSRAM at boot
   - Helps verify PSRAM is properly initialized

3. **Duplicate loop() function**
   - The `loop()` function appears twice in the .ino file
   - Contains identical code for touch handling, hold-to-silence, and serial commands
   - This is a build error waiting to happen

4. **New scaffold script**
   - Added comprehensive project scaffolding script (`scaffold.sh`)
   - Generates complete multi-target build structure with shared library and per-board drivers

- **ESP32-S3-LCD-4.3 board should now display correctly** (was likely blank before due to wrong timing)
- **Build will fail** due to duplicate `loop()` definition - needs immediate cleanup
- The scaffold script enables rapid project regeneration/setup for new installations
This commit is contained in:
2026-02-16 17:30:56 -08:00
parent f82dd35e1d
commit 2d0427604c
3 changed files with 1839 additions and 4 deletions

View File

@@ -23,10 +23,12 @@ void Gfx::init() {
LCD_R0, LCD_R1, LCD_R2, LCD_R3, LCD_R4,
LCD_G0, LCD_G1, LCD_G2, LCD_G3, LCD_G4, LCD_G5,
LCD_B0, LCD_B1, LCD_B2, LCD_B3, LCD_B4,
1 /* hsync_polarity */, 46 /* hsync_front_porch */,
2 /* hsync_pulse_width */, 44 /* hsync_back_porch */,
1 /* vsync_polarity */, 50 /* vsync_front_porch */,
16 /* vsync_pulse_width */, 16 /* vsync_back_porch */
1 /* hsync_polarity */, 10 /* hsync_front_porch */,
8 /* hsync_pulse_width */, 50 /* hsync_back_porch */,
1 /* vsync_polarity */, 10 /* vsync_front_porch */,
8 /* vsync_pulse_width */, 20 /* vsync_back_porch */,
1 /* pclk_active_neg */,
16000000 /* prefer_speed = 16MHz PCLK */
);
_gfx = new Arduino_RGB_Display(

View File

@@ -60,6 +60,8 @@ void setup() {
logic.finishBoot();
display.setBacklight(false);
Serial.printf("[MEM] Free heap: %d | Free PSRAM: %d\n",
ESP.getFreeHeap(), ESP.getFreePsram());
Serial.println("[BOOT] Ready — monitoring ntfy.sh\n");
}
@@ -72,5 +74,64 @@ void silenceAlerts() {
}
void loop() {
logic.update();
display.render(logic.getScreenState());
// Touch → hold-to-silence gesture
TouchEvent evt = display.readTouch();
if (evt.pressed) {
// Dashboard tile tap
if (logic.getScreenState().screen == ScreenID::DASHBOARD) {
int tile = display.dashboardTouch(evt.x, evt.y);
if (tile >= 0) Serial.printf("[DASH] Tile %d tapped\n", tile);
}
}
// Hold-to-silence during ALERT
if (logic.getScreenState().deviceState == DeviceState::ALERTING) {
HoldState h = display.updateHold(HOLD_TO_SILENCE_MS);
if (h.completed) silenceAlerts();
// Hint animation when not touching
if (!h.active) display.updateHint();
}
// Serial commands
if (Serial.available()) {
String cmd = Serial.readStringUntil('\n');
cmd.trim();
if (cmd.length() > 0) logic.onSerialCommand(cmd);
}
}
void loop() {
logic.update();
display.render(logic.getScreenState());
// Touch → hold-to-silence gesture
TouchEvent evt = display.readTouch();
if (evt.pressed) {
// Dashboard tile tap
if (logic.getScreenState().screen == ScreenID::DASHBOARD) {
int tile = display.dashboardTouch(evt.x, evt.y);
if (tile >= 0) Serial.printf("[DASH] Tile %d tapped\n", tile);
}
}
// Hold-to-silence during ALERT
if (logic.getScreenState().deviceState == DeviceState::ALERTING) {
HoldState h = display.updateHold(HOLD_TO_SILENCE_MS);
if (h.completed) silenceAlerts();
// Hint animation when not touching
if (!h.active) display.updateHint();
}
// Serial commands
if (Serial.available()) {
String cmd = Serial.readStringUntil('\n');
cmd.trim();
if (cmd.length() > 0) logic.onSerialCommand(cmd);
}
}

File diff suppressed because it is too large Load Diff