From 8df888eb29adbc49ea0b37b4206603829d3446b6 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sat, 7 Feb 2026 18:28:59 -0500 Subject: [PATCH 1/2] prevent recursive display refresh --- shared-module/busdisplay/BusDisplay.c | 5 ++++- shared-module/epaperdisplay/EPaperDisplay.c | 6 +++++- shared-module/framebufferio/FramebufferDisplay.c | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/shared-module/busdisplay/BusDisplay.c b/shared-module/busdisplay/BusDisplay.c index a4652324c1e4f..46f3aaeaa0abc 100644 --- a/shared-module/busdisplay/BusDisplay.c +++ b/shared-module/busdisplay/BusDisplay.c @@ -309,11 +309,14 @@ static bool _refresh_area(busdisplay_busdisplay_obj_t *self, const displayio_are } static void _refresh_display(busdisplay_busdisplay_obj_t *self) { + if (!displayio_display_core_start_refresh(&self->core)) { + // Refresh for this display already in progress. + return; + } if (!displayio_display_bus_is_free(&self->bus)) { // A refresh on this bus is already in progress. Try next display. return; } - displayio_display_core_start_refresh(&self->core); const displayio_area_t *current_area = _get_refresh_areas(self); while (current_area != NULL) { _refresh_area(self, current_area); diff --git a/shared-module/epaperdisplay/EPaperDisplay.c b/shared-module/epaperdisplay/EPaperDisplay.c index 556db6ae22002..5d92862fced2a 100644 --- a/shared-module/epaperdisplay/EPaperDisplay.c +++ b/shared-module/epaperdisplay/EPaperDisplay.c @@ -187,6 +187,11 @@ void epaperdisplay_epaperdisplay_change_refresh_mode_parameters(epaperdisplay_ep } static void epaperdisplay_epaperdisplay_start_refresh(epaperdisplay_epaperdisplay_obj_t *self) { + if (!displayio_display_core_start_refresh(&self->core)) { + // Refresh on this display already in progress. + return; + } + if (!displayio_display_bus_is_free(&self->bus)) { // Can't acquire display bus; skip updating this display. Try next display. return; @@ -201,7 +206,6 @@ static void epaperdisplay_epaperdisplay_start_refresh(epaperdisplay_epaperdispla if (mp_hal_is_interrupted()) { return; } - displayio_display_core_start_refresh(&self->core); } uint32_t common_hal_epaperdisplay_epaperdisplay_get_time_to_refresh(epaperdisplay_epaperdisplay_obj_t *self) { diff --git a/shared-module/framebufferio/FramebufferDisplay.c b/shared-module/framebufferio/FramebufferDisplay.c index 4ba2b1325815c..8116f4b0347cb 100644 --- a/shared-module/framebufferio/FramebufferDisplay.c +++ b/shared-module/framebufferio/FramebufferDisplay.c @@ -217,7 +217,10 @@ static void _refresh_display(framebufferio_framebufferdisplay_obj_t *self) { if (!self->bufinfo.buf) { return; } - displayio_display_core_start_refresh(&self->core); + if (!displayio_display_core_start_refresh(&self->core)) { + // Refresh on this display already in progress. + return; + } const displayio_area_t *current_area = _get_refresh_areas(self); if (current_area) { bool transposed = (self->core.rotation == 90 || self->core.rotation == 270); From bcb9cd1f78be1508ef46967dba55cbfe3d6e29fd Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 9 Feb 2026 15:09:06 -0500 Subject: [PATCH 2/2] don't start refresh until we know bus is available --- shared-module/busdisplay/BusDisplay.c | 9 +++++---- shared-module/epaperdisplay/EPaperDisplay.c | 9 ++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/shared-module/busdisplay/BusDisplay.c b/shared-module/busdisplay/BusDisplay.c index 46f3aaeaa0abc..6ef1c4c7f66ce 100644 --- a/shared-module/busdisplay/BusDisplay.c +++ b/shared-module/busdisplay/BusDisplay.c @@ -309,14 +309,15 @@ static bool _refresh_area(busdisplay_busdisplay_obj_t *self, const displayio_are } static void _refresh_display(busdisplay_busdisplay_obj_t *self) { - if (!displayio_display_core_start_refresh(&self->core)) { - // Refresh for this display already in progress. - return; - } if (!displayio_display_bus_is_free(&self->bus)) { // A refresh on this bus is already in progress. Try next display. return; } + if (!displayio_display_core_start_refresh(&self->core)) { + // Refresh for this display already in progress. + return; + } + const displayio_area_t *current_area = _get_refresh_areas(self); while (current_area != NULL) { _refresh_area(self, current_area); diff --git a/shared-module/epaperdisplay/EPaperDisplay.c b/shared-module/epaperdisplay/EPaperDisplay.c index 5d92862fced2a..655ae10307155 100644 --- a/shared-module/epaperdisplay/EPaperDisplay.c +++ b/shared-module/epaperdisplay/EPaperDisplay.c @@ -187,15 +187,14 @@ void epaperdisplay_epaperdisplay_change_refresh_mode_parameters(epaperdisplay_ep } static void epaperdisplay_epaperdisplay_start_refresh(epaperdisplay_epaperdisplay_obj_t *self) { - if (!displayio_display_core_start_refresh(&self->core)) { - // Refresh on this display already in progress. - return; - } - if (!displayio_display_bus_is_free(&self->bus)) { // Can't acquire display bus; skip updating this display. Try next display. return; } + if (!displayio_display_core_start_refresh(&self->core)) { + // Refresh on this display already in progress. + return; + } // run start sequence self->bus.bus_reset(self->bus.bus);