diff options
| author | Luke Hoersten <[email protected]> | 2026-06-13 23:01:23 -0500 |
|---|---|---|
| committer | Luke Hoersten <[email protected]> | 2026-06-13 23:01:23 -0500 |
| commit | 1d6cbb222ced226fcb482c0b19130774d181c8f8 (patch) | |
| tree | 768d964dc962e111c8c596e10e2da95748bc738a /main/display.h | |
| parent | 57c93fd2978ed5b5e64f4620803b7a2cd7767ed2 (diff) | |
M7: touch + outbound /state POST to Scrypted
state_client.{h,c}:
- Worker task drains a depth-1 queue (xQueueOverwrite gives the
replace-on-full semantics from the spec — in-flight POST is never
cancelled; the next queued entry is overwritten by newer state).
- esp_http_client POST to <scrypted>/state with Content-Type application/
json, User-Agent ScryptedViewport/<version>, Connection: close, 1s
timeout. Body: {"viewport":"<name>","state":"wake"|"sleep"}.
- Any non-2xx or transport error increments state_post_failures and is
otherwise ignored. Silently drops if no Scrypted URL is configured.
touch.{h,c}:
- FT5426 capacitive touch on the shared I2C bus at 0x38.
- 30ms polling task; tracks down/up transitions, detects taps as
down-then-up within 500ms with a 150ms debounce.
- On tap, toggles wake/sleep via state_machine_set_local(), which drives
the local transition AND fires state_client_post() at Scrypted.
state_machine adds state_machine_set_local(): runs the same transition
as state_machine_set() then enqueues an outbound POST. Idle-timer
expiry now uses this path so Scrypted sees idle-driven sleeps too
(the spec's "tighten the race with /frame 409" path stays in place as
the fallback).
display.h exposes display_i2c_bus(); touch.c uses it instead of
re-initializing the same I2C port.
app_main starts state_client right after the state machine and starts
touch after display init (touch is skipped if display isn't up since
they share the bus).
CMakeLists.txt: add esp_http_client to REQUIRES.
Build clean against ESP-IDF 5.4 (binary ~860 KB; jumped ~210 KB from
M6 because esp_http_client + cJSON path pulls in tcp_transport, mbedtls,
http_parser).
TESTING.md M7: flask-based test receiver, tap dispatch verification,
failure-path check (kill receiver, confirm counter increments),
queue-coalescing behavior, no-POST-on-Scrypted-initiated, no-POST-
when-unconfigured.
Diffstat (limited to 'main/display.h')
| -rw-r--r-- | main/display.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/main/display.h b/main/display.h index e26845f..3119a60 100644 --- a/main/display.h +++ b/main/display.h @@ -4,6 +4,7 @@ #include <stdint.h> #include "esp_err.h" +#include "driver/i2c_master.h" // Initialize the panel-side MCU over I2C, then bring up the DSI link in // video (DPI) mode. Safe to call when the panel is not attached — returns @@ -12,6 +13,11 @@ esp_err_t display_init(void); bool display_is_up(void); +// The Hosyond's I2C bus carries both the panel-MCU (0x45) and the touch +// IC (0x38). Display owns the bus; touch shares it via this getter. +// Returns NULL before display_init() succeeds. +i2c_master_bus_handle_t display_i2c_bus(void); + // 0–100, gamma-corrected to 0–255 on the panel-MCU PWM register. // brightness=0 is fully off (backlight enable line de-asserted). esp_err_t display_set_brightness(uint8_t brightness_0_100); |
