hzeller / rpi-rgb-led-matrix

Controlling up to three chains of 64x64, 32x32, 16x32 or similar RGB LED displays using Raspberry Pi GPIO
GNU General Public License v2.0
3.59k stars 1.15k forks source link

random flicker #1366

Open forever80-dev opened 2 years ago

forever80-dev commented 2 years ago

This code causes a slight random flicker. Do you know what could be causing this?

#!/usr/bin/env python
# Display a runtext with double-buffering
import argparse
from rgbmatrix import RGBMatrix, RGBMatrixOptions
from rgbmatrix import graphics
import time
import socket
import thread
import urlparse
from urlparse import parse_qs
import BaseHTTPServer

global offscreen_canvas

font = graphics.Font()
red = graphics.Color(255, 0, 0)
blue = graphics.Color(0, 0, 255)
options = RGBMatrixOptions()
options.rows = 32
options.cols = 64
options.chain_length = 3
options.parallel = 2
options.multiplexing = 1
matrix = RGBMatrix(options = options)
offscreen_canvas = matrix.CreateFrameCanvas()

class handler(BaseHTTPServer.BaseHTTPRequestHandler):
     def do_HEAD(s):
         s.send_response(200)
         s.send_header("Content-type", "text/html")
         s.end_headers()
     def do_GET(s):
         parsed_path = urlparse.urlparse(s.path)
         s.send_response(200)
         s.send_header("Content-type", "text/html")
         s.end_headers()
         s.wfile.write("OK"+parse_qs(parsed_path.query)['scoreB'][0])
         scoreA=parse_qs(parsed_path.query)['scoreA'][0]
     scoreB=parse_qs(parsed_path.query)['scoreB'][0]
         SendMatrix(scoreA,scoreB)

def SendMatrix(scoreA,scoreB):
    global offscreen_canvas
    if len(scoreA)>2 or len(scoreB)>2:
        fontchoise="Score3.bdf"
        posx=50
    else:
       fontchoise="Score2.bdf"
       posx=60
    font.LoadFont("../../../fonts/"+fontchoise)

    offscreen_canvas.Clear()
    lenA=graphics.DrawText(offscreen_canvas, font, 2, posx, red, scoreA)
    lenB=graphics.DrawText(offscreen_canvas, font, 100, posx, blue, scoreB)
    offscreen_canvas.Clear()
    graphics.DrawText(offscreen_canvas, font, (100-lenA)/2, posx, red, scoreA)
    graphics.DrawText(offscreen_canvas, font, ((100-lenB)/2)+100, posx, blue, scoreB)
    offscreen_canvas = matrix.SwapOnVSync(offscreen_canvas)
    print('UPDATE')

if __name__ == '__main__':
     server_class = BaseHTTPServer.HTTPServer
     httpd = server_class(('', 5000), handler)
     try:
         httpd.serve_forever()
     except KeyboardInterrupt:
         pass
     httpd.server_close()
forever80-dev commented 2 years ago

it seems this happens when there is a write to memory

Beersatron commented 2 years ago

I have seen flicker when the ethernet port was in use, so I switched to WiFi only and the flicker was gone. Are you using ethernet?

forever80-dev commented 2 years ago

Yes I am using ethernet. I will test in WIFI

forever80-dev commented 2 years ago

The problem is the same. And when I read video. it is really more pronounced.

Beersatron commented 2 years ago

What is your setup? What rPi, how many panels and are you using a HAT or just wired up? How much power are you supplying?

What do the demos look like and can you try the demos without using Python?

Beersatron commented 2 years ago

Also, I believe the best setup is to use a lite version of the Raspbian OS and run things headless.

forever80-dev commented 2 years ago

I have two panel 32x64, power supply is 40A 5v

I have Raspberry pi 3 b+ and the card : DEBO MATRIXCTRL Raspberry Pi - Ecran pour matrice LED RGB

Command is : video-viewer -f --led-rows=32 --led-cols=64 --led-parallel=2 --led-chain=1 --led-multiplexing=1 logo.mp4 -F -f