This commit is contained in:
2024-01-12 19:52:00 +01:00
parent f46846645c
commit 3d98adda79
+19 -2
View File
@@ -6,7 +6,7 @@ import logging
import time
import traceback
import argparse
from random import randint
from random import randint, choice
from PIL import Image,ImageDraw,ImageFont,ImageShow
parser = argparse.ArgumentParser(description='e-Ink Sheogorath')
@@ -71,13 +71,30 @@ try:
#epd.displayPartBaseImage(epd.getbuffer(time_image))
epd.init(epd.PART_UPDATE)
lyrics = open("lyrics.txt", "r").readlines()
def get_lyric():
LENGTH = 15
lyric = choice(lyrics)
out_lyric = ""
counter = 0
for word in lyric.split(" "):
if counter + len(word) < LENGTH:
counter += len(word) + 1
out_lyric += word + " "
else:
counter = len(word) + 1
out_lyric += "\n" + word + " "
return out_lyric
while (True):
lyric = get_lyric()
print(lyric)
time_image = Image.new('1', (epd.height, epd.width), 255)
time_draw = ImageDraw.Draw(time_image)
time_image.paste(bmp, (2,2))
time_draw.rectangle((160, 90, 250, 122), fill = 255)
time_draw.text((160, 90), time.strftime('%H:%M'), font = font24, fill = 0)
time_draw.text((140, 10), 'Respect your \nparents, okay?', font = font15, fill = 0)
time_draw.text((140, 10), lyric, font = font15, fill = 0)
epd.displayPartial(epd.getbuffer(time_image))
epd.displayPartial(epd.getbuffer(time_image))
epd.displayPartial(epd.getbuffer(time_image))