Show a live picture on a camera tile, run an action from the alert button, roll long media titles, and keep full-page tiles in their own colour (0.2.91)

Live picture (issue #4): a camera or image tile on a Guition takes
Display -> Live picture with a pace of 15 or 30 s. The camera tiles of a
page share one download: the screen asks ESP Screens for them together
(esphome.screen_camera with tiles, size and bg) and the app serves one
BMP, a strip of squares with the corners rounded over each tile's own
colour; every tile draws its square out of it with LVGL's image offset
(LV_IMAGE_ALIGN_TOP_LEFT: the default centres a taller source). A third
online_image on the Guition holds the strip; it loads after the alert's
picture, a cover and the camera full screen, never under a card, in
standby or under a finger. The strip is served whole every time: ESPHome's
http_request logs a 304 as a failed request. Firmware 0.2.77.

Alert button: esp_screens_show_alert takes action and data; the app
performs the action once when the button's report (esphome.screen_alert,
ok) comes from any screen. show_alert keeps its seven fields, so every
firmware from 0.2.31 has it.

Media card and full-page media tile: a title or artist line that is too
wide rolls by (LV_LABEL_LONG_SCROLL_CIRCULAR) instead of ending in dots.

Full-page tiles are white or their own pastel like every other tile; the
tint in the state colour of firmware 0.2.62 to 0.2.76 is gone.

Host harness (27 checks) and bench Guition + local add-on on the Yellow:
docs/TEST_RESULTS_0291.md. CYD firmware 1,633,728 B, 89.0 %.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Max Gramser
2026-09-20 12:47:44 +02:00
parent 8a81ff4d93
commit 306636434b
55 changed files with 1133 additions and 126 deletions
+8 -3
View File
@@ -24,14 +24,19 @@ struct Feed {
// once (firmware 0.2.64+): an album cover on the media card. It loads one time per link and stays; a new cover comes
// with a new link (the card asks again when Home Assistant's picture changes), never on a clock.
bool once = false, loaded = false; // loaded: this link's image is on screen
// every (firmware 0.2.77+): the live pictures on a page's camera tiles load at their own pace, 15 or 30 s, where the
// camera full screen keeps REFRESH_MS.
uint32_t every = REFRESH_MS;
uint8_t failures = 0;
void open(const std::string &camera, bool one_load = false) { *this = Feed{}; entity = camera; once = one_load; }
void open(const std::string &camera, bool one_load = false, uint32_t every_ms = REFRESH_MS) { *this = Feed{}; entity = camera; once = one_load; every = every_ms; }
bool open() const { return !entity.empty(); }
// A cover the app has none of (or an app that knows no covers) is asked for once: the card keeps its placeholder.
// A feed whose app has no picture asks again at its own pace, never sooner than ASK_AGAIN_MS.
bool should_ask(uint32_t now) const {
if (once && empty) return false;
return open() && !loading && url.empty() && (!asked || now - asked_at >= ASK_AGAIN_MS);
const uint32_t again = empty && every > ASK_AGAIN_MS ? every : ASK_AGAIN_MS;
return open() && !loading && url.empty() && (!asked || now - asked_at >= again);
}
void ask(uint32_t now) { asked = true; asked_at = now; }
// The app's answer: a link, or none (no image from Home Assistant, or a camera this screen may not show).
@@ -46,7 +51,7 @@ struct Feed {
if (!open() || loading || url.empty()) return false;
if (!started_at) return true;
if (once) return !loaded && now - finished_at >= GAP_MS; // a failed load is tried again, a loaded one stays
return now - started_at >= REFRESH_MS && now - finished_at >= GAP_MS;
return now - started_at >= every && now - finished_at >= GAP_MS;
}
void start(uint32_t now) { loading = true; started_at = now ? now : 1; }
void finish(uint32_t now, bool ok) {