Skip to content

Virtual Viewport Set Position Assertion Error #177

@jantznick

Description

@jantznick

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions