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