From 5bed2f0ccc9ca3bab80e1d2ed2a9dddc621428c6 Mon Sep 17 00:00:00 2001 From: Luke Hoersten Date: Sun, 14 Jun 2026 19:43:13 -0500 Subject: touch: retry + hard-reset when FT5426 boots into wedged 0xff state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After a long bench session of taps + power cycles, the FT5426 on this unit started returning dev_mode=0xff on every read. The polling loop interpreted that as 15 simultaneous touches forever (td_status bits 0..3 all set), wedged `was_down=true` permanently, and no tap or long-press ever fired — the screen looked dead. Two layers of defence in touch_init: 1. retry the dev_mode read up to 10 × 30 ms in case the chip is just slow to come up after PC_RST_TP_N is released. 2. if still stuck, pulse PC_RST_TP_N via a new display_touch_reset_pulse() helper (drop reset for 20 ms then release + 50 ms settle), then retry the read another 10 × 30 ms. Plus a polling-loop sanity check: an FT5x06 supports max 5 simultaneous points, so a TD_STATUS lower-nibble value > 5 is bogus and the poll cycle is skipped. That keeps a wedged chip from producing phantom "15 touches" reports if it slips into 0xff during runtime. If both attempts still report 0xff, we log loudly and let the polling task run — it harmlessly drops cycles via the >5 sanity check. Wake still works via POST /state from Scrypted; this only disables touch gestures on a hardware-stuck boot. --- main/display.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'main/display.c') diff --git a/main/display.c b/main/display.c index a704891..8c5ffb2 100644 --- a/main/display.c +++ b/main/display.c @@ -218,6 +218,22 @@ static esp_err_t touch_release_reset(void) PC_LED_EN | PC_RST_TP_N | PC_RST_LCD_N | PC_RST_BRIDGE_N); } +// Hard-reset the touch IC: drop PC_RST_TP_N for ~20 ms, then release. +// touch_init() calls this if its dev_mode read keeps returning 0xff — +// usually unwedges a stuck FT5426 without needing a power cycle. +esp_err_t display_touch_reset_pulse(void) +{ + if (!s_panel_mcu) return ESP_ERR_INVALID_STATE; + // Hold touch in reset (clear PC_RST_TP_N), keep everything else as-is. + esp_err_t err = mcu_write_u8(REG_PORTC, + PC_LED_EN | PC_RST_LCD_N | PC_RST_BRIDGE_N); + if (err != ESP_OK) return err; + vTaskDelay(pdMS_TO_TICKS(20)); + err = touch_release_reset(); + vTaskDelay(pdMS_TO_TICKS(50)); + return err; +} + // ============================================================================ // TC358762 bridge configuration (DSI Generic Long Write packets) // Sequence mirrors Linux drivers/gpu/drm/bridge/tc358762.c tc358762_init(). -- cgit v1.2.3