40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
#!/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, args):
|
||
image_buffer = lib.display.matrix.buffer()
|
||
draw = ImageDraw.Draw(image_buffer)
|
||
while not stop_event.is_set():
|
||
# All to black
|
||
draw.rectangle( ((0,0),(lib.display.matrix.width-1,lib.display.matrix.height-1)), fill=(0,0,0) )
|
||
|
||
# Current time
|
||
now = datetime.datetime.now()
|
||
#now_string = now.strftime('%d. %B %Y – %H:%M:%S')
|
||
# Date into top left
|
||
draw.text((10, 0), now.strftime('%d. %B %Y'), fill=(255, 255, 0), font=lib.display.matrix.font)
|
||
# Time into middle
|
||
draw.text((100, 20), now.strftime('%H:%M:%S'), fill=(0, 255, 255), font=lib.display.matrix.large_font)
|
||
# Weekday
|
||
draw.text((10, 33), now.strftime('%A'), 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)
|
||
|