This commit is contained in:
Lukas Schulz 2020-12-20 13:44:57 +01:00
parent e0bfb814b7
commit df3e69c81e

18
main.py
View file

@ -104,6 +104,9 @@ def drawCanvas():
if(was_playing and not is_playing): if(was_playing and not is_playing):
scroll = threading.Thread(target=scrollDownSongInfo) scroll = threading.Thread(target=scrollDownSongInfo)
scroll.start() scroll.start()
if(not was_playing and is_playing):
scroll = threading.Thread(target=scrollUpSongInfo)
scroll.start()
if(is_playing): if(is_playing):
canvas.paste(cover_art,(cover_art_offset_x,cover_art_offset_y)) canvas.paste(cover_art,(cover_art_offset_x,cover_art_offset_y))
songinfo = ImageDraw.Draw(canvas) songinfo = ImageDraw.Draw(canvas)
@ -136,8 +139,21 @@ def scrollDownSongInfo(offset_x=0,offset_y=96):
songinfo.text((songinfo_offset_x,i), artist_name) songinfo.text((songinfo_offset_x,i), artist_name)
song_info_canvas.paste(cover_art,(0,i)) song_info_canvas.paste(cover_art,(0,i))
showImage(song_info_canvas, offset_x, offset_y) showImage(song_info_canvas, offset_x, offset_y)
time.sleep(0.02) time.sleep(0.01)
def scrollUpSongInfo(offset_x=0, offset_y=96):
cover_art = get_track()
if (cover_art is None):
return
for i in range(33):
song_info_canvas = Image.new('RGB', (192,32), color = 'black')
songinfo = ImageDraw.Draw(song_info_canvas)
songinfo_offset_x = 33
songinfo.text((songinfo_offset_x,11+(33-i)), song_name)
songinfo.text((songinfo_offset_x,(33-i)), artist_name)
song_info_canvas.paste(cover_art,(0,(33-i)))
showImage(song_info_canvas, offset_x, offset_y)
time.sleep(0.01)
def scrolling_text(text,offset_x=0,offset_y=0): def scrolling_text(text,offset_x=0,offset_y=0):
scroll_frame_time = (8/2)/(font.getsize(text)[0]-160) scroll_frame_time = (8/2)/(font.getsize(text)[0]-160)