led-matrix-panel/scenes/colorclock.py

32 lines
1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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)