works reliably - especially when using gunicorn

This commit is contained in:
Christoph Haas 2026-01-16 22:36:32 +01:00
parent c937450f92
commit 39cd98823a
7 changed files with 253 additions and 38 deletions

View file

@ -1,5 +1,6 @@
from rgbmatrix import RGBMatrix, RGBMatrixOptions
from PIL import ImageFont, Image
#from time import sleep
# Das Bild nur speichern. Nicht die LED-Matrix ansteuern.
DEV = False
@ -18,22 +19,39 @@ class MyMatrix:
try:
self.font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-ExtraLight.ttf", 18)
self.large_font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-ExtraLight.ttf", 32)
except IOError:
self.font = ImageFont.load_default()
self.large_font = ImageFont.load_default()
self.width = MATRIX_WIDTH * NUMBER_OF_PANELS
self.height = MATRIX_HEIGHT
if not DEV:
options = RGBMatrixOptions()
options.rows = MATRIX_HEIGHT
options.cols = MATRIX_WIDTH
options.chain_length = NUMBER_OF_PANELS
options.parallel = 1
options.hardware_mapping = 'regular' # change if using Adafruit HAT, e.g. 'adafruit-hat'
options.gpio_slowdown = 5 # try 2, 4, or even 5
options.disable_hardware_pulsing = True
#options.parallel = 1
#options.hardware_mapping = 'regular' # change if using Adafruit HAT, e.g. 'adafruit-hat'
options.gpio_slowdown = 4 # try 2, 4, or even 5
#options.disable_hardware_pulsing = True
#options.show_refresh_rate = True
options.drop_privileges = False
options.brightness = 60 # scale down brightness if needed
options.pwm_bits = 8 # default 1112; lower = faster refresh
self.matrix = RGBMatrix(options=options)
#sleep(0.2)
#self.matrix.Clear()
#sleep(0.2)
#self.matrix.Clear()
#sleep(0.2)
#self.matrix.Clear()
#sleep(0.2)
def show(self, image):
"""Save the image to disk in DEV mode. Or send it to the LED matrix panel."""
if DEV: