Skip to content

display.root_group.hidden = True causes RuntimeError: Read-only #9880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dhalbert opened this issue Dec 8, 2024 · 14 comments
Closed

display.root_group.hidden = True causes RuntimeError: Read-only #9880

dhalbert opened this issue Dec 8, 2024 · 14 comments

Comments

@dhalbert
Copy link
Collaborator

dhalbert commented Dec 8, 2024

display.root_group.hidden = True
has error:

RuntimeError: Read-only

Originally posted by @bh1rio in #2791 (comment)

@dhalbert
Copy link
Collaborator Author

dhalbert commented Dec 8, 2024

This started happening between 9.0.0-beta.0 and 9.0.0-beta.1.

@dhalbert
Copy link
Collaborator Author

dhalbert commented Dec 8, 2024

This is due to #8923.

@jepler

display.root_group.hidden = True was previously recommended as a way to hide the terminal. Now that the root group is read-only, it can no longer be made hidden. I can't remember if there is an alternate way to hid the terminal now.

@jepler
Copy link

jepler commented Dec 8, 2024

I think it's display.root_group = None

@dhalbert
Copy link
Collaborator Author

dhalbert commented Dec 8, 2024

@jepler That makes sense, thanks! @bh1rio that should work for you. Please reply if not.

@dhalbert
Copy link
Collaborator Author

dhalbert commented Dec 8, 2024

More on this: https://forums.adafruit.com/viewtopic.php?p=1019617#p1019617

@tannewt see your comments there.

@bh1rio
Copy link

bh1rio commented Dec 8, 2024

More on this: https://forums.adafruit.com/viewtopic.php?p=1019617#p1019617

@tannewt see your comments there.

en...... set root_group to none, does not have effect

@jepler
Copy link

jepler commented Dec 8, 2024

Huh, I tested it here:

Adafruit CircuitPython 9.2.1-21-g7c28ec69cd-dirty on 2024-12-04; Adafruit Floppsy RP2040 with rp2040
>>> import board
>>> board.DISPLAY.root_group = None

After I hit enter on the 2nd line the TFT was set to all black.

I see two things from the forum thread:

  • first, you're using an epaper display ("pimoroni badger2040 which has a built in Epaper Display"). circuitpython will defer the refresh of an epaper display for a long time, sometimes minutes, based on the datasheet recommended refresh time/rate
  • second, based on the code sample you posted, your code.py finishes right after setting the root group to None (& calling refresh). However, whenever a program exits, the display is set back to the default, i.e., the console. You have to do something like have a loop that runs forever or enter a deep sleep mode to prevent this happening.

@bh1rio
Copy link

bh1rio commented Dec 8, 2024

it have effect in a vm, e.g. code.py.
after it run, display recovery.

if you use thonny, thonny will run help('modules'), and get dir list.
For the 320 * 240 LCD of M5Stack, it will take four to five screens to display all of these contents.

Perhaps it would be better for me to compile a bin with CIRCUITPY_TERMINALIO=0 by myself.

thanks.

@bh1rio
Copy link

bh1rio commented Dec 8, 2024

CIRCUITPY_TERMINALIO=0 is not a perfect solution either. By doing so, both the built-in terminalio and fontio modules will be gone, and there may be other modules that I haven't noticed are missing as well.

@dhalbert
Copy link
Collaborator Author

dhalbert commented Dec 8, 2024

You can try putting board.DISPLAY.root_group = None in boot.py. In my testing, this produced nothing on the screen when ctrl-C'ing a program, or when using Thonny.

@todbot
Copy link

todbot commented Feb 22, 2025

And for future people who discover this thread: you must put board.DISPLAY.root_group = None in both boot.py and code.py as it seems the display gets recreated after boot.py finishes. (at least on an M5Stack Cardputer)

@konsumer
Copy link

konsumer commented Mar 2, 2025

board.DISPLAY is not defined on RP2040-zero with ssd1306. This worked in boot.py, though:

import supervisor

supervisor.status_bar.display = False
supervisor.status_bar.console = False

@jepler
Copy link

jepler commented Mar 2, 2025

board.DISPLAY is a short hand for "the built in display, if this board has one in its board definition". If you create a display object in your code with a line like display = ssd1306(...) then you'd write display instead of board.DISPLAY.

@konsumer
Copy link

konsumer commented Mar 3, 2025

board.DISPLAY is a short hand for "the built in display, if this board has one in its board definition". If you create a display object in your code with a line like display = ssd1306(...) then you'd write display instead of board.DISPLAY.

yep. If you do display.root_group = None with your own display, it doesn't work like that, though, is my point. At least on my RP2040, I needed to also run those 2 supervisor lines in boot.py, to remove the initial flash of console. Even with that, if your loop breaks, it will show the console, regardless of what you do with display/supervisor, which in my case is fine, even though trying to put a REPL on a 128x32 OLED is a bit un-useful, at least it doesn't show when it first starts.

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

No branches or pull requests

5 participants