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

Virtual Viewport Set Position Assertion Error #177

Open
jantznick opened this issue May 2, 2020 · 1 comment
Open

Virtual Viewport Set Position Assertion Error #177

jantznick opened this issue May 2, 2020 · 1 comment

Comments

@jantznick
Copy link

Type of Raspberry Pi

This is on a Pi Zero W, using 4 daisy chained 8x8 matrix's I bought off AliExpress. Everything with the setup seems to be running fine.

Linux Kernel version

Linux raspberrypi 4.19.97+ #1294 Thu Jan 30 13:10:54 GMT 2020 armv6l GNU/Linux

Expected behaviour

I'm following the docs here:
https://luma-led-matrix.readthedocs.io/en/latest/python-usage.html#scrolling-virtual-viewports
The entirety of my code is here:
https://gist.github.com/jantznick/f8a3ad9bcb3a039ca539070fb8faed24
The import bit is

for offset in range(100):  
    print(f'Offset: {offset}')  
    virtual.set_position((offset,0))  
    time.sleep(.1)

Eventually I'd do something like:

width = font.font.getsize(text)
for offset in range(32 + width[0]):

to continually scroll through any feed I add to the text variable. If I do a small piece of text like '0', this does work how I want it, but as soon as the offset value gets to above 68 it is breaking the scrolling feature.

Actual behaviour

I'm expecting the code to scroll across the screen, after going 100 through it should start over again. Whenever the offset gets to 69 it breaks and gives the following Traceback:

Traceback (most recent call last):
  File "test.py", line 27, in <module>
    virtual.set_position((offset,0))
  File "/usr/local/lib/python3.7/dist-packages/luma/core/virtual.py", line 75, in set_position
    self.refresh()
  File "/usr/local/lib/python3.7/dist-packages/luma/core/virtual.py", line 123, in refresh
    im = self._backing_image.crop(box=self._crop_box())
  File "/usr/local/lib/python3.7/dist-packages/luma/core/virtual.py", line 135, in _crop_box
    assert(0 <= left <= right <= self.width)
AssertionError

This always breaks no matter what the text is, long or small if the offset range portion goes above 68.

I'd be more than happy to make a PR if anyone has any sort of idea what might actually be causing this issue or if it is originating from the

@thijstriemstra
Copy link
Collaborator

@rm-hull this probably belongs in luma.led_matrix?

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

No branches or pull requests

2 participants