Skip to content
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

displayio: the display does not survive a VM restart on SAMD21 #6277

Closed
deshipu opened this issue Apr 12, 2022 · 6 comments · Fixed by #6321
Closed

displayio: the display does not survive a VM restart on SAMD21 #6277

deshipu opened this issue Apr 12, 2022 · 6 comments · Fixed by #6321
Assignees
Labels
Milestone

Comments

@deshipu
Copy link

deshipu commented Apr 12, 2022

CircuitPython version

Adafruit CircuitPython 7.3.0-alpha.0-22-g102ee716a-dirty on 2022-04-12; PewPew LCD with samd21e18

Code/REPL

import board
import terminalio
import displayio
from adafruit_display_text import label
from adafruit_st7789 import ST7789
import busio

# Release any resources currently in use for the displays
displayio.release_displays()

spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI)
tft_cs = board.D5
tft_dc = board.D9

display_bus = displayio.FourWire(
    spi, command=tft_dc, chip_select=tft_cs, reset=board.D6
)

display = ST7789(display_bus, width=240, height=240, rowstart=80)

# Make the display context
splash = displayio.Group()
display.show(splash)

color_bitmap = displayio.Bitmap(24, 24, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0x00FF00  # Bright Green

bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
splash.append(bg_sprite)

# Draw a smaller inner rectangle
inner_bitmap = displayio.Bitmap(20, 20, 1)
inner_palette = displayio.Palette(1)
inner_palette[0] = 0xAA0088  # Purple
inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=20, y=20)
splash.append(inner_sprite)

# Draw a label
text_group = displayio.Group(scale=2, x=50, y=120)
text = "Hello World!"
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00)
text_group.append(text_area)  # Subgroup for text scaling
splash.append(text_group)

Behavior

The display keeps displaying two squares and text even after the code finishes running.
It should instead display the REPL with the "Code done running." message.

IMG_20220412_214723

Same happens when the code is interrupted with ctrl+c — instead of REPL, the display shows the last thing the program was displaying.

Description

The reverse happens if I copy-paste the display initialization code in the REPL — the display works until ctrl+c is pressed.

Additional information

If the display is initialized in board.c as part of the startup, then it initializes properly, but never displays anything.

@deshipu deshipu added the bug label Apr 12, 2022
@deshipu
Copy link
Author

deshipu commented Apr 12, 2022

With more testing, I noticed that sometimes, randomly, I can get a line or two of the traceback, before the display freezes, so there is some kind of race condition in there perhaps?

@deshipu
Copy link
Author

deshipu commented Apr 13, 2022

A much easier reproducer: the HalloWing M0 Express display no longer works with recent versions of CircuitPython.

@deshipu
Copy link
Author

deshipu commented Apr 13, 2022

The last version that works is adafruit-circuitpython-hallowing_m0_express-en_US-7.0.0-alpha.6.uf2, the first version that is broken is adafruit-circuitpython-hallowing_m0_express-en_US-7.0.0-beta.0.uf2.

@deshipu
Copy link
Author

deshipu commented Apr 13, 2022

Further testing leads me to believe that it's commit f0859ac that broke this.

@deshipu
Copy link
Author

deshipu commented Apr 15, 2022

I have tried to experiment with this, but I really don't know what is happening. Perhaps the clock that the SPI peripheral uses gets shut down? The code itself doesn't refer to anything directly related to displayio. I give up.

@jepler jepler added this to the 7.3.0 milestone Apr 24, 2022
@dhalbert
Copy link
Collaborator

Further testing leads me to believe that it's commit f0859ac that broke this.

Confirmed via bisect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants