Description
Right now display core will move I2C and SPI objects that they need to keep outside the VM. This is bug prone. Instead we should ensure the used object is already outside the Python VM. It can either be statically allocated (likely for use in board
) or allocated dynamically to the outer heap.
This will be easier once we move to a model where only one display lives past VM reset. displayio
currently lets all displays outlive the VM. In practice, this is almost always 1 because of the display limit. We can remove this limit with the split heap switch in 9 but it doesn't make it clear which display to use for the terminal. Instead, we can add an explicit supervisor.runtime.display =
that allows for setting a single display to preserve outside the VM and use for the terminal. It also allows for user code to access a previously constructed display without needing to reconstruct it after release_displays()
. The assignment can also validate that all objects are present outside the Python VM and won't need to be moved.
So:
- Introduce
supervisor.runtime.display =
that validates that the display and anything it uses won't need to be moved (is in `board.) - Make
release_displays()
a no-op and release any other displays at VM end. - Allocate all I2C and SPI objects off the VM heap by default so they can outlive the VM.
This will break display behavior because the "lives outside VM and is used by CP" will be explicit. Boards with displays can set this automatically though.