Show who is at the door: camera images on the Guition (0.2.66)
An alert from esp_screens_show_alert takes a `camera` (a camera.* or image.* entity): a Guition with firmware 0.2.57 shows that moment's picture across the top of the card, and a tap opens the camera full screen. A camera or image tile opens the same full-screen view, refreshed every four seconds at a steady pace. ESP Screen Manager fetches the snapshot with its own access, sizes it for the screen and serves a 24-bit BMP under a random, short-lived link on port 8098; the screen loads it with ESPHome's online_image and holds no Home Assistant token. BMP because ESPHome decodes it per chunk, where a full-screen JPEG held the loop 0.6 s. The CYD keeps its alerts without the picture and gets no camera tiles. The Guition also builds with ESPHome 2026.8+ again: backlight_fade.h derived from ESPHome's LEDC output, which 2026.8 made final, so the backlight now dims through ESPHome's own light transition. Tested on the bench boards and a local add-on on the Home Assistant Yellow; docs/TEST_RESULTS_0266.md. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,9 +23,13 @@ inline bool check_geometry(lv_obj_t *obj) {
|
||||
}
|
||||
#if LV_USE_SNAPSHOT
|
||||
inline lv_draw_buf_t *snapshot = nullptr;
|
||||
// LVGL's top layer (an alert, a camera full screen) when something is shown on it, with its transparency.
|
||||
inline lv_draw_buf_t *overlay = nullptr;
|
||||
inline int snapshot_row = 0;
|
||||
inline void snapshot_begin() {
|
||||
if (snapshot) lv_draw_buf_destroy(snapshot);
|
||||
if (overlay) lv_draw_buf_destroy(overlay);
|
||||
overlay = nullptr;
|
||||
snapshot = lv_snapshot_take(lv_screen_active(), LV_COLOR_FORMAT_RGB565);
|
||||
snapshot_row = 0;
|
||||
if (!snapshot || snapshot->header.w != 480 || snapshot->header.h != 480) {
|
||||
@@ -34,7 +38,24 @@ inline void snapshot_begin() {
|
||||
ESP_LOGE("ui_image", "IMAGE FAIL allocation/dimensions");
|
||||
return;
|
||||
}
|
||||
ESP_LOGI("ui_image", "IMAGE BEGIN 240 240");
|
||||
for (uint32_t i = 0; i < lv_obj_get_child_count(lv_layer_top()); ++i)
|
||||
if (!lv_obj_has_flag(lv_obj_get_child(lv_layer_top(), i), LV_OBJ_FLAG_HIDDEN)) {
|
||||
overlay = lv_snapshot_take(lv_layer_top(), LV_COLOR_FORMAT_ARGB8888);
|
||||
if (overlay && (overlay->header.w != 480 || overlay->header.h != 480)) { lv_draw_buf_destroy(overlay); overlay = nullptr; }
|
||||
break;
|
||||
}
|
||||
ESP_LOGI("ui_image", "IMAGE BEGIN 240 240%s", overlay ? " with top layer" : "");
|
||||
}
|
||||
// The top layer's pixel over the page's, as the panel shows them.
|
||||
inline uint16_t layered(uint16_t pixel, int x, int y) {
|
||||
if (!overlay) return pixel;
|
||||
const uint8_t *p = overlay->data + y * overlay->header.stride + x * 4; // B, G, R, A
|
||||
const unsigned alpha = p[3];
|
||||
if (!alpha) return pixel;
|
||||
const unsigned r = ((pixel >> 11) & 31) * 255 / 31, g = ((pixel >> 5) & 63) * 255 / 63, b = (pixel & 31) * 255 / 31;
|
||||
const unsigned mr = (p[2] * alpha + r * (255 - alpha)) / 255, mg = (p[1] * alpha + g * (255 - alpha)) / 255,
|
||||
mb = (p[0] * alpha + b * (255 - alpha)) / 255;
|
||||
return static_cast<uint16_t>((mr * 31 / 255) << 11 | (mg * 63 / 255) << 5 | (mb * 31 / 255));
|
||||
}
|
||||
inline void snapshot_next_row() {
|
||||
if (!snapshot) return;
|
||||
@@ -43,7 +64,7 @@ inline void snapshot_next_row() {
|
||||
static constexpr char hex[] = "0123456789abcdef";
|
||||
char line[961];
|
||||
for (int x = 0; x < 240; ++x) {
|
||||
uint16_t pixel = row[x * 2];
|
||||
uint16_t pixel = layered(row[x * 2], x * 2, snapshot_row * 2);
|
||||
for (int digit = 0; digit < 4; ++digit)
|
||||
line[x * 4 + digit] = hex[(pixel >> (12 - digit * 4)) & 15];
|
||||
}
|
||||
@@ -52,6 +73,8 @@ inline void snapshot_next_row() {
|
||||
if (++snapshot_row == 240) {
|
||||
lv_draw_buf_destroy(snapshot);
|
||||
snapshot = nullptr;
|
||||
if (overlay) lv_draw_buf_destroy(overlay);
|
||||
overlay = nullptr;
|
||||
ESP_LOGI("ui_image", "IMAGE COMPLETE");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user