realign and retime
This commit is contained in:
+6
-8
@@ -72,13 +72,13 @@ try:
|
||||
|
||||
epd.init(epd.PART_UPDATE)
|
||||
lyrics = open("lyrics.txt", "r").readlines()
|
||||
def get_lyric():
|
||||
LENGTH = 17
|
||||
def get_lyric(max_length = 17):
|
||||
print(max_length)
|
||||
lyric = choice(lyrics)
|
||||
out_lyric = ""
|
||||
counter = 0
|
||||
for word in lyric.split(" "):
|
||||
if counter + len(word) < LENGTH:
|
||||
if counter + len(word) < max_length:
|
||||
counter += len(word) + 1
|
||||
out_lyric += word + " "
|
||||
else:
|
||||
@@ -87,19 +87,17 @@ try:
|
||||
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)
|
||||
x = randint(0, 40)
|
||||
lyric = get_lyric((300-x)//15)
|
||||
time_image.paste(bmp, (x,randint(0, 10)))
|
||||
time_draw.rectangle((160, 90, 250, 122), fill = 255)
|
||||
time_draw.text((180, 90), time.strftime('%H:%M'), font = font24, fill = 0)
|
||||
time_draw.text((185, 90), time.strftime('%H:%M'), font = font24, fill = 0)
|
||||
time_draw.text((100+x, 5), lyric, font = font15, fill = 0)
|
||||
epd.displayPartial(epd.getbuffer(time_image))
|
||||
epd.displayPartial(epd.getbuffer(time_image))
|
||||
epd.displayPartial(epd.getbuffer(time_image))
|
||||
time.sleep(10)
|
||||
time.sleep(50)
|
||||
except IOError as e:
|
||||
logging.info(e)
|
||||
except KeyboardInterrupt:
|
||||
|
||||
Reference in New Issue
Block a user