diff options
| author | Luke Hoersten <[email protected]> | 2026-06-14 20:11:21 -0500 |
|---|---|---|
| committer | Luke Hoersten <[email protected]> | 2026-06-14 20:11:21 -0500 |
| commit | 865c4859d710870245ae7954e729edcaf442a921 (patch) | |
| tree | c22cb7d60fb8ea3bba6e9e85b45779d0dfa87d4f /main/touch.c | |
| parent | 8e2de89efb540fd6a3dce2086216d3afc49e6831 (diff) | |
Default name = MAC; brief wake on boot; drop dead touch defences
- Seed viewport_name with the full base MAC, colons stripped
(e8:f6:0a:e0:90:94 → "e8f60ae09094"). Stable across reboots, globally
unique, 12 alphanumeric chars — well inside the mDNS hostname limit
even with the "viewport-" prefix.
- Add a mac_str field to viewport_state and expose it as the new "mac"
key in GET /state and as a "mac" line on the info screen.
- "Configured" no longer requires a viewport_name (it always has the
MAC default); the scrypted URL alone gates outbound POSTs and the
loading-vs-info screen choice.
- Strip viewport_name[0] fallbacks in http_api / mdns / local_screens
now that the field is never empty.
- Replace the wake-on-boot-stays-on behaviour with a ~600 ms flash
followed by sleep — long enough for the FT5426 touch IC to come out
of its initial unresponsive state, short enough that an idle device
doesn't burn the backlight.
- Drop the touch defensive cruft added when we were chasing a PoE-power
theory: the DEV_MODE=0x00 write at init, the touch_reset_pulse() call
at init, and the runtime wedge-self-heal in the polling loop didn't
actually fix anything — the wake-on-boot flash did. Also delete the
display_touch_reset_pulse() helper since it now has zero callers.
Diffstat (limited to 'main/touch.c')
| -rw-r--r-- | main/touch.c | 56 |
1 files changed, 9 insertions, 47 deletions
diff --git a/main/touch.c b/main/touch.c index 4615f45..b470536 100644 --- a/main/touch.c +++ b/main/touch.c @@ -54,13 +54,6 @@ static void on_long_press(void) if (display_is_up()) local_screens_overlay(OVERLAY_MS); } -// If we see N consecutive bogus polls (TD_STATUS > 5, i.e. the FT5426 is -// returning 0xff), pulse PC_RST_TP_N to try to bring it back. PoE-only -// cold boots leave the touch IC in a wedged state for ~seconds before it -// recovers; this lets us keep nudging it without blocking init. -#define WEDGE_THRESHOLD (3000 / POLL_PERIOD_MS) // ~3 s of bad polls -#define WEDGE_BACKOFF_MS 2000 - static void touch_task(void *arg) { bool was_down = false; @@ -68,35 +61,16 @@ static void touch_task(void *arg) bool long_fired = false; uint64_t last_tap_us = 0; uint8_t buf[7]; - unsigned wedged_cycles = 0; - uint64_t last_reset_us = 0; - bool announced_up = false; for (;;) { vTaskDelay(pdMS_TO_TICKS(POLL_PERIOD_MS)); if (ft_read(FT_REG_DEV_MODE, buf, sizeof(buf)) != ESP_OK) continue; - uint64_t now_us = (uint64_t)esp_timer_get_time(); uint8_t touches = buf[FT_REG_TD_STATUS] & 0x0F; - // FT5x06 supports max 5 simultaneous points. A reading above that - // is bogus (typically the bus is parking 0xff because the IC isn't - // responding) — drop the cycle and bump the wedge counter. - if (touches > 5) { - if (++wedged_cycles >= WEDGE_THRESHOLD && - now_us - last_reset_us > (uint64_t)WEDGE_BACKOFF_MS * 1000ULL) { - ESP_LOGW(TAG, "touch wedged — pulsing reset"); - display_touch_reset_pulse(); - last_reset_us = now_us; - wedged_cycles = 0; - } - continue; - } - if (wedged_cycles > 0 || !announced_up) { - ESP_LOGI(TAG, "touch online (TD_STATUS=%u)", touches); - wedged_cycles = 0; - announced_up = true; - } - uint64_t now = now_us; + // FT5x06 supports max 5 simultaneous points; anything above that + // is a bogus reading (chip parking 0xff during a transient). + if (touches > 5) continue; + uint64_t now = (uint64_t)esp_timer_get_time(); if (touches > 0) { if (!was_down) { @@ -141,23 +115,11 @@ esp_err_t touch_init(void) ESP_RETURN_ON_ERROR(i2c_master_bus_add_device(bus, &cfg, &s_dev), TAG, "i2c add FT5426"); - // Force DEV_MODE=0x00 (Working Mode) — chip might have powered up in - // System Info mode (0x40) or Factory Test mode (0x40) which would - // explain steady 0x00 TD_STATUS but no touch detection. Cheap to - // attempt; ignore result since some firmware revisions reject it - // pre-reset and the polling loop handles the alternative anyway. - { - uint8_t set_working[2] = { FT_REG_DEV_MODE, 0x00 }; - i2c_master_transmit(s_dev, set_working, sizeof(set_working), 50); - } - - // Pulse the touch reset line and don't read dev_mode at init time: - // on PoE-only boots the FT5426 hasn't finished its internal firmware - // load when touch_init runs, and any read returns 0xff. The polling - // loop already drops cycles where TD_STATUS > 5, so a wedged chip is - // harmless; once its firmware finishes (often after a few hundred ms - // of being prodded by polling reads), real touches start landing. - display_touch_reset_pulse(); + // No dev_mode read here: the FT5426 starts reporting contacts only + // after the LCD has streamed with the backlight on at least once + // (handled by the wake-on-boot flash in app_main). Any read before + // that returns 0xff, which the polling loop's >5 sanity filter + // already drops. ESP_LOGI(TAG, "FT5426 polling started " "(tap=toggle wake/sleep, %dms hold=info overlay)", LONG_PRESS_MS); |
