From a10a5d8abe229b691543d532d4b1de6df939159e Mon Sep 17 00:00:00 2001 From: foamyguy Date: Wed, 18 Nov 2026 15:27:58 -0600 Subject: [PATCH] web VNC display mirror fix for FramebufferDisplay under LVGL --- .../framebufferio/lvgl/FramebufferDisplay.c | 10 ++++++++++ supervisor/shared/web_workflow/display_stream.c | 12 ++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/shared-module/framebufferio/lvgl/FramebufferDisplay.c b/shared-module/framebufferio/lvgl/FramebufferDisplay.c index 78eb2d5ae13..94f64f54901 100644 --- a/shared-module/framebufferio/lvgl/FramebufferDisplay.c +++ b/shared-module/framebufferio/lvgl/FramebufferDisplay.c @@ -21,6 +21,9 @@ #include "shared-module/videocore/VideoBuffer.h" #endif #include "supervisor/port_heap.h" +#if CIRCUITPY_WEB_WORKFLOW +#include "supervisor/shared/web_workflow/display_stream.h" +#endif #if CIRCUITPY_ESPIDF #include "esp_attr.h" @@ -191,6 +194,9 @@ static void framebufferio_lvgl_flush_cb(lv_display_t *disp, const lv_area_t *are for (uint16_t y = area->y1; y <= area->y2; y++) { MARK_ROW_DIRTY(y); } + #if CIRCUITPY_WEB_WORKFLOW + display_stream_area_updated(&self->core, area); + #endif } else { lv_area_t rotated_area = *area; lv_display_rotate_area(disp, &rotated_area); @@ -205,6 +211,10 @@ static void framebufferio_lvgl_flush_cb(lv_display_t *disp, const lv_area_t *are for (uint16_t y = rotated_area.y1; y <= rotated_area.y2; y++) { MARK_ROW_DIRTY(y); } + #if CIRCUITPY_WEB_WORKFLOW + // The stream reads the framebuffer, so it needs the area in the panel's orientation. + display_stream_area_updated(&self->core, &rotated_area); + #endif } // Publish each flushed area now. LVGL doesn't reliably report the last flush part in all diff --git a/supervisor/shared/web_workflow/display_stream.c b/supervisor/shared/web_workflow/display_stream.c index 1ce81ea48e1..2c51289a0cb 100644 --- a/supervisor/shared/web_workflow/display_stream.c +++ b/supervisor/shared/web_workflow/display_stream.c @@ -408,7 +408,12 @@ void display_stream_area_updated(displayio_display_core_t *core, const displayio return; } if (core == target) { + #if CIRCUITPY_DISPLAYIO_LVGL + // An lv_area_t: the second corner is inclusive. + _mark_dirty(area->x1, area->y1, area->x2 + 1, area->y2 + 1); + #else _mark_dirty(area->x1, area->y1, area->x2, area->y2); + #endif } // Another display may be a new one to switch to. _pass_later(); @@ -463,8 +468,11 @@ static void _check_display(void) { // The panel's size, whatever the rotation. The legacy compositor keeps it in the // full refresh area; LVGL tracks invalidation itself, so the core keeps only the size. #if CIRCUITPY_DISPLAYIO_LVGL - uint16_t new_width = core != NULL ? core->width : width; - uint16_t new_height = core != NULL ? core->height : height; + // The LVGL core keeps the rotated size, but the framebuffer read below is in + // the panel's own orientation, so swap them back when transposed. + bool transposed = core != NULL && (core->rotation == 90 || core->rotation == 270); + uint16_t new_width = core != NULL ? (transposed ? core->height : core->width) : width; + uint16_t new_height = core != NULL ? (transposed ? core->width : core->height) : height; #else uint16_t new_width = core != NULL ? core->area.x2 : width; uint16_t new_height = core != NULL ? core->area.y2 : height;