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

Adding long string of text fails #439

Closed
n-i-x opened this issue Jan 6, 2024 · 2 comments · May be fixed by #348
Closed

Adding long string of text fails #439

n-i-x opened this issue Jan 6, 2024 · 2 comments · May be fixed by #348
Labels
bug Something isn't working

Comments

@n-i-x
Copy link

n-i-x commented Jan 6, 2024

Describe the bug
Adding text to an image fails with the error:

Traceback (most recent call last):
  File "/workspaces/turing-smart-screen-python/button_card.py", line 50, in <module>
    lcd_comm.DisplayText(game['gamename'], 5, 5,
  File "/workspaces/turing-smart-screen-python/library/lcd/lcd_comm.py", line 273, in DisplayText
    self.DisplayPILImage(text_image, left, top)
  File "/workspaces/turing-smart-screen-python/library/lcd/lcd_comm_rev_c.py", line 303, in DisplayPILImage
    img, pyd = self._generate_update_image(image, x, y, Count.Start, Command.UPDATE_BITMAP,
  File "/workspaces/turing-smart-screen-python/library/lcd/lcd_comm_rev_c.py", line 365, in _generate_update_image
    payload.extend(bytearray.fromhex(image_size))
ValueError: non-hexadecimal number found in fromhex() arg at position 5

To Reproduce
Steps to reproduce the behavior:

lcd_comm.DisplayText("1000 Miglia: Great 1000 Mile", 5, 5,
                                font="geforce/GeForce-Bold.ttf",
                                font_size=60,
                                font_color=(255, 255, 255),
                                background_image=background,
                                align="left",
                                anchor="lt")

image_size from line 365 in _generate_update_image = '10ff3'. It appears that when the value is more than 4 bytes there is an error.

Expected behavior
Text should render on the screen.

Screenshots / photos of the Turing screen
Nothing displays.

Environment:

  • Smart screen model Turing 5
  • Revision of this project main branch
  • OS with version OSX 14.2.1
  • Python version 3.9
  • Hardware MacBook Pro M3 Pro

Additional context
I attempted to zero pad the string but that didn't work. Reducing the string below the size that ends up being 5 bytes works fine.

@n-i-x n-i-x added the bug Something isn't working label Jan 6, 2024
@n-i-x n-i-x mentioned this issue Jan 7, 2024
@gwendal-h
Copy link
Contributor

Yes i fixed this one here 46f5398

@mathoudebine mathoudebine linked a pull request Jan 10, 2024 that will close this issue
@mathoudebine
Copy link
Owner

Hello, it has been fixed on the main branch.
Thanks @gwendal-h I've backported your commit until your PR is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants