diff --git a/sheogorath.py b/sheogorath.py index 56aacea..e109d11 100644 --- a/sheogorath.py +++ b/sheogorath.py @@ -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))