Skip to content

Release extra displays when code finishes - #11702

Merged
dhalbert merged 2 commits into
adafruit:mainfrom
mikeysklar:fix-10063
Nov 1, 2026
Merged

dhalbert merged 2 commits into
adafruit:mainfrom
mikeysklar:fix-10063

Conversation

@mikeysklar

@mikeysklar mikeysklar commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

What

Displays not set as supervisor.runtime.display are now released when your code finishes.

Why

Their pins stayed busy, so the same code failed on its next run.

Fixes #10063.

Behaviour change

External display Before After
Not set as primary Kept, and creating it again fails Released at exit, can be created again
Set with supervisor.runtime.display = d Kept Kept

Displays released this way should no longer show the REPL after your code exits.

Testing

Where Before After
Metro RP2040, normal build Too many display busses from run 2 Created on all 3 runs
CLUE, display limit raised to 2 Pins busy, Too many display busses Pins free, created on all 3 runs
Desktop lab, window and virtual TFT D9 in use No error

Built-in CLUE display still shows the console and paints. No real second panel, backlight or e-paper tested. CLUE builds had hashlib turned off. Desktop lab is cp-desktop-lab.

CLUE, stock on the left, fixed on the right:

CLUE console on the third reload. Stock shows busy pins and Too many display busses. Fixed shows free pins and second OK.

Desktop lab, before on the left, after on the right:

Desktop lab console on the second reload. Before shows D9 in use. After shows no error.

AI assistance

Claude helped find and test this. I checked the results.

🤖 Generated with Claude Code

Uncomment the release in reset_displays(). The bus loop compared bus
slots with the primary's display slot, but the two are allocated
separately, so it could release the primary's bus and keep a spare. Skip
the bus the primary actually uses instead.

With no primary left, stop the terminal so a later display doesn't get
one sized for the old display.

Update the docs that said displays stay active until release_displays().

Fixes adafruit#10063.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mikeysklar

Copy link
Copy Markdown
Collaborator Author

@lynt-smitka your cp-desktop-lab worked on this before any hardware verification. It reproduced the problem and showed that the suggested one-line fix released the wrong bus. A CLUE and a Metro RP2040 then confirmed the result. Thanks again!

@dhalbert dhalbert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

@dhalbert dhalbert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reference problem in new doc:

/home/runner/work/circuitpython/circuitpython/shared-bindings/busdisplay/index.rst:639:'any' reference target not found: supervisor.runtime.display [ref.any]

supervisor.runtime is an instance, so the doc reference doesn't resolve.
Keep the text users type and link it to supervisor.Runtime.display.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mikeysklar

Copy link
Copy Markdown
Collaborator Author

Thanks.

Fixed the doc reference.

It was in several display modules, so I corrected all of them.

@mikeysklar
mikeysklar requested a review from dhalbert November 1, 2026 16:04

@dhalbert dhalbert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@dhalbert
dhalbert merged commit 132286c into adafruit:main Nov 1, 2026
630 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Release non-primary displays at code.py exit

2 participants