Repository navigation
Keep audio smooth while an LVGL display redraws - #11909
Merged
Merged
Conversation
An explicit refresh() renders on the VM thread, so audio buffers were not refilled until it returned. A playlist scroll on the Metro ESP32-P4 with the Pi Touch Display 2 ran audio at 0.67x speed. Run background tasks after each flushed chunk, like the legacy framebufferio path does since adafruit#11875. A paced frame callback that fires during that yield waits for the next frame instead of starting a nested render. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A full re-render of a large text grid is one flush chunk but can take longer than the I2S DMA buffers last. Run background tasks after each batch of 64 cells when called from an explicit refresh(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
For 1/2/4/8 bit bitmaps with a Palette, write cell pixels straight into the ARGB8888 or RGB565 canvas through a 256 entry lookup table instead of one lv_draw_image() per cell. Clear cells with memset rather than lv_draw_buf_clear(), which flushed the cache for whole rows each call. Framebuffer CRCs match the old path at both color depths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A BusDisplay auto-refresh queued while an explicit refresh() runs background tasks could start a nested lv_refr_now() in the middle of the framebuffer render. Skip it; it draws on the next tick, like the paced framebuffer displays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The per-display lv_refresh_yield was always set together with the global displayio_lvgl_refresh_yield. The LVGL lock is held for the whole explicit refresh, so only that display's flush can see the global. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mikeysklar
marked this pull request as ready for review
November 18, 2026 20:29
tannewt
requested changes
Nov 18, 2026
tannewt
left a comment
Member
There was a problem hiding this comment.
Why do we want to yield only on explicit refresh? Isn't it true that auto-refreshes also need to yield?
Collaborator
Author
|
Auto-refresh needs a yield too. Liz's player sets BusDisplay and UVC auto-refresh draw inside a background callback with nothing yielding. Plan: render framebuffer auto-refresh on the CircuitPython thread, the way BusDisplay already does. All three paths then yield with |
This was referenced Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Screen redraws now pause to let audio refill.
Why
On the Metro ESP32-P4, scrolling a playlist slowed and garbled MP3 audio.
@BlitzCityDIY found this while testing her Winamp player on the P4.
Changes
display.refresh()runs background tasks while it draws, so I2S can refill. The old framebufferio path already does this (Fix garbled I2S audio on the ESP32-P4 #11875).Results
Liz's Winamp player, Raspberry Pi Touch Display 2, scripted playlist scroll:
App tips (not in this PR)
Two user code changes that help on the P4:
RaspberryPiTouchDisplay2(bus, i2c, color_depth=16): redraws about 35% faster than the 24-bit default.sdioio.SDCard(..., frequency=40_000_000): the 40 MHz maximum instead of 25 MHzThe two changes in Liz's code.py
Follow-up
Playing from the SD card still drops some audio while scrolling (about 45 per 20 s). Refilling audio from its own high-priority task, so SD reads and decoding never wait on the display, should fix that. @tannewt idea that would be good to add as a separate PR.
Written with Claude Code.