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

Error in display thread when updating a Label #146

Open
Neradoc opened this issue Jan 15, 2025 · 0 comments
Open

Error in display thread when updating a Label #146

Neradoc opened this issue Jan 15, 2025 · 0 comments

Comments

@Neradoc
Copy link
Contributor

Neradoc commented Jan 15, 2025

It's unclear what exactly causes it.
This only happens with certain values of y, it seems 0 and below. 2 doesn't trigger the error for example.
Note that the text is partly off-screen regardless.
Just initing the text_area with y=0 doesn't cause an error.
The sleep seems necessary to trigger the error when y is set.
I also briefly tried to reproduce by moving a simple TileGrid around without success.

import board
import requests
import time
import displayio
import terminalio
import adafruit_displayio_ssd1306

i2c = board.I2C()
display_bus = displayio.I2CDisplay(i2c, device_address=0x3D)
oled = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=64)

splash = displayio.Group()
oled.root_group = splash

from adafruit_display_text import label
text_area = label.Label(terminalio.FONT, text="Test", color=0xFFFFFF, x=0, y=1,)
splash.append(text_area)

time.sleep(1)
text_area.y = 0

while True:
	time.sleep(1)

Here is another repro, updating the text.

from adafruit_display_text import label
text_area = label.Label(terminalio.FONT, text="Test", color=0xFFFFFF)
splash.append(text_area)

time.sleep(1)
text_area.text = "Hi"

while True:
	time.sleep(1)
Exception in thread Thread-1 (_background):
Traceback (most recent call last):
  File ".pyenv/versions/3.11.2/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File ".pyenv/versions/3.11.2/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File ".env/lib/python3.11/site-packages/displayio/__init__.py", line 54, in _background
    display._background()  # pylint: disable=protected-access
    ^^^^^^^^^^^^^^^^^^^^^
  File ".env/lib/python3.11/site-packages/busdisplay/__init__.py", line 332, in _background
    self.refresh()
  File ".env/lib/python3.11/site-packages/busdisplay/__init__.py", line 299, in refresh
    self._refresh_display()
  File ".env/lib/python3.11/site-packages/busdisplay/__init__.py", line 308, in _refresh_display
    self._refresh_area(area)
  File ".env/lib/python3.11/site-packages/busdisplay/__init__.py", line 389, in _refresh_area
    self._core.set_region_to_update(subrectangle)
  File ".env/lib/python3.11/site-packages/displayio/_displaycore.py", line 340, in set_region_to_update
    data += struct.pack(">BB", region_y1, region_y2)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
struct.error: ubyte format requires 0 <= number <= 255
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

1 participant