displayio: send one area buffer while composing the next - #11468
Open
lynt-smitka wants to merge 2 commits into
Open
lynt-smitka wants to merge 2 commits into
lynt-smitka wants to merge 2 commits into
Conversation
common_hal_busio_spi_write_async() starts a DMA write and returns; common_hal_busio_spi_wait() waits for it without running background tasks, since the caller still holds the bus. Ports that have them set CIRCUITPY_BUSIO_SPI_ASYNC. There is no Python API. raspberrypi: TX-only DMA. The channel is claimed on first use and kept until deinit. Writes shorter than 32 bytes or from flash/PSRAM stay synchronous. atmel-samd: samd51/same5x only, through shared_dma_transfer_start(). espressif: up to two queued ESP-IDF transactions (8 KB). Writes of four bytes or less, longer writes and word sizes other than 8 bits stay synchronous.
A display bus can now have send_async next to send, and flush waits for it. FourWire provides both when the SPI port has an async write. BusDisplay then uses two area buffers: it composes the next one while the previous one is sent. Background tasks still run only while the bus is released, so another device on the same SPI bus is not locked out. Full-screen repaint: PicoPad (RP2040) 76.7 -> 57.2 ms, PyBadge (SAMD51) 26.5 -> 15.5 ms, Feather ESP32-S3 TFT 29.9 -> 19.6 ms. Ports without the async write build the same code as before.
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.
BusDisplay on a FourWire bus now composes the next area buffer while the previous one is sent over SPI with DMA.
busio: internalcommon_hal_busio_spi_write_async()andcommon_hal_busio_spi_wait(), enabled byCIRCUITPY_BUSIO_SPI_ASYNC. Implemented on raspberrypi, samd51/same5x and espressif. No new Python API.displayio: the display bus gets an optionalsend_async. FourWire provides both when the SPI port has the async write. Without a DC pin, with a chip select toggled per byte, and on the other buses nothing changes.Full-screen repaint of a TileGrid with an 8-bit Bitmap, main -> this PR:
Flash: PicoPad +624 B, Fruit Jam +576 B, Feather ESP32-S3 +528 B, PyBadge +320 B.
With an async bus the second area buffer is on the stack during a refresh. A full-screen refresh at the Python recursion limit ran without a crash on both boards. On RP2 the display's SPI bus keeps one DMA channel claimed until it is deinitialized.
picogame will use this in a follow-up PR and drop its own port DMA backends.