Flashing Pixels; Performance Issue?
See original GitHub issueI think I may be seeing a performance issue. I’m using legacy.text() and draw.point() to light text (the time) plus a few pixels on 4 cascaded matrix displays. When doing this in a simple test script it works great. However, when moving this into my larger script I’m seeing flashing of the pixels I’m lighting individually (legacy.text is solid). Code is below. I can upload a video of the behavior I’m seeing if you’d like.
Thanks for your work here! Other than this flashing issue I’ve had a really easy time getting up a running. Great examples and documentation.
Type of Raspberry Pi
RPi3
Linux Kernel version
Linux piclock 4.4.34-v7+ #930 SMP Wed Nov 23 15:20:41 GMT 2016 armv7l GNU/Linux
Expected behaviour
Pixels change to desired state and do not flash in transition or while lit.
Actual behaviour
Seeing pixels flashing either while in transition or while lit.
Here’s the code that works in this test script, but causes flashing behavior in my larger script:
#!/usr/bin/env python
from luma.core import legacy
from luma.led_matrix.device import max7219
from luma.core.serial import spi, noop
from luma.core.render import canvas
import datetime, time
# create matrix device
serial = spi(port=0, device=0, gpio=noop())
device = max7219(serial, cascaded=4, block_orientation="vertical")
show_dots = True
counter = 1
while True:
clock_display = (datetime.datetime.now().strftime('%I:%M'))
if show_dots == True:
with canvas(device) as draw:
legacy.text(draw, (0, 0), clock_display, fill="white", font=legacy.font.proportional(legacy.font.SINCLAIR_FONT))
draw.point([(31, 7), (30, 7), (31, 6)], fill="white")
elif show_dots == False:
with canvas(device) as draw:
legacy.text(draw, (0, 0), clock_display, fill="white", font=legacy.font.proportional(legacy.font.SINCLAIR_FONT))
time.sleep(.5)
counter += 1
if counter == 8:
show_dots = not show_dots
counter = 1
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
Just wanted to follow up in case it can help someone in the future:
Using
ps -ef | grep python
showed me that there were in fact two copies of my script running.My problem came from the fact that I am using Flask and was running in debug mode. Flask includes reloading functionality such that you can change code and you don’t need to restart your app. It’s handy. Well, it accomplishes this by basically running two instances of your script. This is what was causing the flashing that I saw (two scripts writing to the matrix display that weren’t perfectly in sync).
You can work around this issue in debug mode by adding
use_reloader=False
to your app.run() call. That fixed it for me. You lose the reloading functionality though. I believe switching out of debug mode should also solve it.Anyway, problem solved. Thanks again @rm-hull
More info can be found here
@rm-hull we should move away from
time.sleep
stuff…