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

Group already in use when instantiating 2 displays #7824

Closed
Neradoc opened this issue Apr 1, 2023 · 0 comments · Fixed by #7829
Closed

Group already in use when instantiating 2 displays #7824

Neradoc opened this issue Apr 1, 2023 · 0 comments · Fixed by #7829
Assignees
Milestone

Comments

@Neradoc
Copy link

Neradoc commented Apr 1, 2023

CircuitPython version

Adafruit CircuitPython 8.0.5 on 2023-03-31; Adafruit Monster M4SK with samd51j19
Adafruit CircuitPython 8.1.0-beta.1-3-ge8711ee83 on 2023-03-31; Adafruit Monster M4SK with samd51j19

Code/REPL

import board
import busio
import digitalio
import displayio
from adafruit_st7789 import ST7789

displayio.release_displays()

# Left screen spi bus
left_spi = busio.SPI(board.LEFT_TFT_SCK, MOSI=board.LEFT_TFT_MOSI)
left_tft_cs = board.LEFT_TFT_CS
left_tft_dc = board.LEFT_TFT_DC
left_display_bus = displayio.FourWire(
    left_spi, command=left_tft_dc, chip_select=left_tft_cs
)
left_display = ST7789(left_display_bus, width=240, height=240, rowstart=80)

# right display spi bus
right_spi = busio.SPI(board.RIGHT_TFT_SCK, MOSI=board.RIGHT_TFT_MOSI)
right_tft_cs = board.RIGHT_TFT_CS
right_tft_dc = board.RIGHT_TFT_DC

right_display_bus = displayio.FourWire(
    right_spi,
    command=right_tft_dc,
    chip_select=right_tft_cs,
    reset=board.RIGHT_TFT_RST,
)

right_display = ST7789(
    right_display_bus, width=240, height=240, rowstart=80
)

Behavior

Adafruit CircuitPython 8.0.5 on 2023-03-31; Adafruit Monster M4SK with samd51j19
>>> import bugtest
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "bugtest.py", line 30, in <module>
  File "adafruit_st7789.py", line 64, in __init__
ValueError: Group already used
>>> 

Description

This is because displayio.Display() attempts to assign the terminal group as the root group of every new display, regardless of whether it was already set to another display. And common_hal_displayio_display_set_root_group raises an exception.

The init code could call displayio_display_core_set_root_group directly and ignore the return value instead ?

// Set the group after initialization otherwise we may send pixels while we delay in
// initialization.
common_hal_displayio_display_set_root_group(self, &circuitpython_splash);

mp_obj_t common_hal_displayio_display_set_root_group(displayio_display_obj_t *self, displayio_group_t *root_group) {
bool ok = displayio_display_core_set_root_group(&self->core, root_group);
if (!ok) {
mp_raise_ValueError(translate("Group already used"));
}
return mp_const_none;
}

Additional information

No response

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

Successfully merging a pull request may close this issue.

4 participants