From 186fd85422f99dfb59d89ae9338dc50627f7c3e5 Mon Sep 17 00:00:00 2001 From: Luke Hoersten Date: Sun, 14 Jun 2026 18:30:44 -0500 Subject: Tidy: delete dead code, inline single-use helpers, fix double-lock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Code-review pass after the M5 colour fix. -126 net lines (-215 / +89). Dead code removed: - display_fill, display_test_pattern — M3 bring-up self-tests, no callers - net_eth_is_up — no callers - nvs_config_reset — no callers (factory-reset gesture was removed earlier; NVS wipe now goes through `idf.py erase-flash`) Helpers inlined or collapsed (each had one call site): - state_name / orientation_name — ternaries at the cJSON site - fmt_bytes / fmt_uptime — inline scope in local_screens_show_info - expected_dims (http_api) + effective_dims (local_screens) — merged into viewport_state_effective_dims() in viewport_state, one canonical source state_machine cleanup: - arm_idle_timer_unlocked / disarm_idle_timer collapsed to one arm_idle_timer(ms) that takes the snapshotted timeout (ms==0 disables). Removes the misleading name and the second viewport_state lock acquisition per painted frame. - state_machine_set + state_machine_frame_painted now snapshot state + idle_ms under one lock. mdns_service cleanup: - snapshot_state / apply_hostname / apply_txt collapsed into a single apply_state(include_hostname) helper; mdns_service_start grabs hostname once for hostname_set + log instead of going under the lock three times. http_api cleanup: - POST /config brightness-changed path uses the local `bright` it already validated instead of re-locking + re-reading st->brightness. - Trimmed verbose bring-up comments (stack-size justification, M5 saga, DSI shadow struct) to one line each — kept the load-bearing facts. Smoke-tested on hardware: boot clean, display + JPEG + touch all up ([DJT]), info screen renders, no crashes. --- main/viewport_state.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'main/viewport_state.c') diff --git a/main/viewport_state.c b/main/viewport_state.c index 3ae8f81..7ddf737 100644 --- a/main/viewport_state.c +++ b/main/viewport_state.c @@ -13,8 +13,6 @@ void viewport_state_init(void) { memset(&s_state, 0, sizeof(s_state)); s_state.configured = false; - // State is always AWAKE or ASLEEP. UNCONFIGURED is reported via the - // `configured` flag, not as a state value. Boot is always asleep. s_state.state = VIEWPORT_STATE_ASLEEP; s_state.brightness = 80; s_state.idle_timeout_ms = 60000; @@ -46,3 +44,12 @@ const char *viewport_state_resolution_str(void) ? "480x800" : "800x480"; } + +void viewport_state_effective_dims(uint16_t *w, uint16_t *h) +{ + viewport_state_lock(); + viewport_orientation_t o = s_state.orientation; + viewport_state_unlock(); + if (o == VIEWPORT_ORIENTATION_PORTRAIT) { *w = 480; *h = 800; } + else { *w = 800; *h = 480; } +} -- cgit v1.2.3