diff options
| author | Luke Hoersten <[email protected]> | 2026-07-17 18:56:03 -0500 |
|---|---|---|
| committer | Luke Hoersten <[email protected]> | 2026-07-17 18:56:03 -0500 |
| commit | 9d94f710f7b00d109bf6f6ee57996f43bce5c67f (patch) | |
| tree | b86320353884536d2d1b342efa27600b19c845de /main/local_screens.c | |
| parent | 866015678918560a0d0519be8a2549e4fc23b2cd (diff) | |
main: code-review fixes — brightness units, OTA stall cap, stats + locking
- display: s_last_pwm cached the raw 0-100 percentage at init but
display_wake writes it straight to REG_PWM (0-255 duty) — first wake
ran visibly dim until a /config brightness change. Shared pct_to_duty
helper now converts in both paths.
- http_api: cap consecutive OTA recv timeouts (a stalled client spun
forever holding s_ota_in_progress, wedging OTA until reboot); cap
viewport name at 54 chars so viewport-<name> fits the 63-byte mDNS
label; log mdns_service_refresh failures; /state builds JSON from a
snapshot instead of holding the state lock across ~25 cJSON allocs;
respond_400 delegates to respond_status.
- stream_server: bytes_in_window now counts painted frames only (frames
discarded while asleep inflated the first post-wake window's MB/s,
avg-jpeg and chunk/wire averages; recv_bytes folded in); so_rcvbuf
carried into the stats snapshot under the mux; drop dead HEADER_BYTES;
merge read_body_instrumented into read_n.
- state_machine: transition mutex serializes concurrent wake/sleep
(display side-effects ran after the state lock dropped, so racing
callers could leave the backlight contradicting st->state); wake-path
placeholder paint now takes the decoder lock like the stream path
(concurrent esp_lcd_panel_draw_bitmap from two tasks isn't safe).
- local_screens: overlay paint takes the decoder lock too; check the
overlay timer create; panel dims from viewport_state.h.
- jpeg_decoder: try_lock before init returns busy instead of passing a
NULL semaphore to xSemaphoreTake.
- net_eth: clear cached IP string on link down (stale /state + info).
- dead code: display_present_bgr888, TOUCH_FT5426_ADDR, touch s_task,
JPEG_DECODER_MAX_OUTPUT_BYTES; doc drift in nvs_config.h /
jpeg_decoder.h / app_main flag legend.
Diffstat (limited to 'main/local_screens.c')
| -rw-r--r-- | main/local_screens.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/main/local_screens.c b/main/local_screens.c index 1277d00..351c7c5 100644 --- a/main/local_screens.c +++ b/main/local_screens.c @@ -9,13 +9,14 @@ #include "chip_temp.h" #include "display.h" +#include "jpeg_decoder.h" #include "net_eth.h" #include "viewport_state.h" static const char *TAG = "screens"; -#define PANEL_W 800 -#define PANEL_H 480 +#define PANEL_W VIEWPORT_PANEL_WIDTH +#define PANEL_H VIEWPORT_PANEL_HEIGHT #define MAX_BUF_PX (PANEL_W * PANEL_H) // 8x8 bitmap font, lit pixels = foreground. Covers the characters used by @@ -150,7 +151,11 @@ esp_err_t local_screens_init(void) .callback = &overlay_expired_cb, .name = "info_overlay", }; - esp_timer_create(&args, &s_overlay_timer); + esp_err_t err = esp_timer_create(&args, &s_overlay_timer); + if (err != ESP_OK) { + ESP_LOGE(TAG, "overlay timer create failed: %s", esp_err_to_name(err)); + return err; + } return ESP_OK; } @@ -174,7 +179,11 @@ esp_err_t local_screens_overlay(uint32_t duration_ms) if (!display_is_up()) return ESP_ERR_INVALID_STATE; esp_timer_stop(s_overlay_timer); display_wake(); + // Serialize the overlay paint against the stream decode-task's paints + // (concurrent esp_lcd_panel_draw_bitmap calls aren't safe). + if (!jpeg_decoder_try_lock(500)) return ESP_ERR_TIMEOUT; esp_err_t err = local_screens_show_info(); + jpeg_decoder_unlock(); if (err != ESP_OK) return err; s_overlay_active = true; return esp_timer_start_once(s_overlay_timer, |
