whiterabbit icon indicating copy to clipboard operation
whiterabbit copied to clipboard

make scrolling faster

Open markusweibofner opened this issue 4 years ago • 8 comments

Awesome library! Code works really well on Raspi 3B+

I was wondering, if there is any possibility, to make the scrolling faster. Even with no delay in write_scrolling(), the writing should be faster. I'm not sure if this is a RAM issue of the Raspi or if settings in the code could accelerate scrolling.

Thanks for your help!

markusweibofner avatar Jan 21 '21 16:01 markusweibofner

@markusweibofner there's a delay in master loop too: https://github.com/jwalanta/whiterabbit/blob/7f408caa1837b35d052d513876dd7485cf5d4113/whiterabbit.py#L84

jwalanta avatar Jan 21 '21 18:01 jwalanta

Hi @jwalanta , thanks for your reply: Actually, i want to enhance the speed of the scrolling itself - not sure if this is possible tho. Basically the for-loop should process faster:

https://github.com/jwalanta/whiterabbit/blob/7f408caa1837b35d052d513876dd7485cf5d4113/matrixbuffer.py#L77 https://github.com/jwalanta/whiterabbit/blob/7f408caa1837b35d052d513876dd7485cf5d4113/matrixbuffer.py#L79

markusweibofner avatar Jan 21 '21 20:01 markusweibofner

@markusweibofner there's a limit on how fast the matrix can refresh.

you can make the scroll faster by moving one whole character at a time:

for st in range(len(str)):
    self.clear()
    self.write_string_at(0, 0, str[st:], color)
    self.show()
	time.sleep(delay)

or if you want it a bit smoother, multiple pixels at a time:

skip_pixels = 2
for st in range(len(str)):
    for offset in range(0, self.font.get_width() + self.CHAR_SPACING, skip_pixels):
        self.clear()
        self.write_string_at(0, -offset, str[st:], color)
        self.show()
        time.sleep(delay)

jwalanta avatar Jan 21 '21 21:01 jwalanta

Awesome, that was just what i was looking for ! It scrolls way faster. When implementing the two snippets, it's indeed not too smooth anymore, would more RAM help to refresh the matrix faster?

markusweibofner avatar Jan 21 '21 22:01 markusweibofner

@markusweibofner unfortunately, no. the ws2812b leds run at a low frequency (400Hz i believe). the new version of the led ws2813 runs at a much higher frequency, but i havent tried those yet.

jwalanta avatar Jan 21 '21 22:01 jwalanta

Alright, thanks for your help!

Jwalanta Shrestha [email protected] schrieb am Do. 21. Jan. 2021 um 23:29:

@markusweibofner https://github.com/markusweibofner unfortunately, no. the ws2812b leds run at a low frequency (400Hz i believe). the new version of the led ws2813 runs at a much higher frequency, but i havent tried those yet.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jwalanta/whiterabbit/issues/2#issuecomment-764982684, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANZNNJWFBCDKWAWBVJ7ZQIDS3CTFZANCNFSM4WNGE6LA .

markusweibofner avatar Jan 22 '21 09:01 markusweibofner

One more thing, i've figured out that the standard configuration for WS281x is 800kHz.

https://github.com/rpi-ws281x/rpi-ws281x-python/blob/master/examples/strandtest.py LED_FREQ_HZ = 800000 # LED signal frequency in hertz (usually 800khz)

I believe (not sure tho) that the dependent neopixel lib (https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel.git) uses 400kHz only. Is there a way i can change this to explicitly use 800Hz? It doesn't work when i add two additional parameters, freq_hz=800000 and dma=10 in neopixelwrapper.py self.strip = neopixel.NeoPixel(LED_PIN, LED_COUNT, brightness=1, auto_write=False, pixel_order=LED_ORDER)

markusweibofner avatar Jan 23 '21 11:01 markusweibofner

Did anyone notice, as well, that the velocity of the letters moving one by one is faster when the brightness is reduced?

markusweibofner avatar Jan 24 '22 15:01 markusweibofner