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

32
scenes/colorclock.py Normal file
View file

@ -0,0 +1,32 @@
#!/usr/bin/env python3
import io
from time import sleep
from PIL import Image, ImageDraw, ImageFont
import lib.display
import datetime
import locale
locale.setlocale(locale.LC_TIME, "de_DE.UTF-8")
def start(stop_event, text="Hello World!"):
while not stop_event.is_set():
image_buffer = lib.display.matrix.buffer()
draw = ImageDraw.Draw(image_buffer)
now = datetime.datetime.now()
now_string = now.strftime('%d. %B %Y %H:%m:%S')
draw.text((0, 0), now_string, fill=(255, 255, 0), font=lib.display.matrix.font)
draw.text((0, 20), now_string, fill=(0, 255, 255), font=lib.display.matrix.font)
draw.text((0, 40), now_string, fill=(255, 0, 255), font=lib.display.matrix.font)
float_seconds = now.second + now.microsecond/10**6
length = 64*4/60.0*float_seconds
# 64*4 = 60
# x = seconds
# x=64*4/60*seconds
#draw.line( ((0,63), (now.second,63)), fill=(128,128,128), width=1)
draw.line( ((0,62), (length,62)), fill=(128,128,128), width=2)
lib.display.matrix.show(image_buffer)
sleep(0.05)