yes.
This commit is contained in:
parent
d79e41d5f4
commit
22170b1088
1 changed files with 20 additions and 6 deletions
26
main.py
26
main.py
|
@ -9,6 +9,7 @@ import threading
|
|||
import requests
|
||||
from io import BytesIO
|
||||
import time
|
||||
import datetime
|
||||
|
||||
client_id = cfg.client_id
|
||||
client_secret = cfg.client_secret
|
||||
|
@ -55,6 +56,7 @@ token = None #oauth2.SpotifyOAuth(username, scope, client_id, client_secret, red
|
|||
#token = util.prompt_for_user_token(username, scope, client_id, client_secret, redirect_uri)
|
||||
|
||||
font = ImageFont.load_default()
|
||||
clock_font = ImageFont.trueType(font='BebasNeue_Regular_1.otf', size=20)
|
||||
|
||||
|
||||
def get_track():
|
||||
|
@ -184,7 +186,7 @@ def scrollUpSongInfo(offset_x=0, offset_y=96, song_name=song_name, artist_name=a
|
|||
is_scrolling_art = False
|
||||
|
||||
def scrolling_text(text,offset_x=0,offset_y=0):
|
||||
scroll_frame_time = (8/2)/(font.getsize(text)[0]-160)
|
||||
scroll_frame_time = (6/2)/(font.getsize(text)[0]-160)
|
||||
#print(scroll_frame_time)
|
||||
if(scroll_frame_time>0.03):
|
||||
scroll_frame_time = 0.03
|
||||
|
@ -208,6 +210,23 @@ def scrolling_text(text,offset_x=0,offset_y=0):
|
|||
|
||||
def main():
|
||||
get_access_token()
|
||||
clock = threading.Thread(target=drawClock)
|
||||
clock.start()
|
||||
print('led-matrix-viewer started')
|
||||
while True:
|
||||
get_access_token()
|
||||
drawCanvas()
|
||||
time.sleep(10)
|
||||
|
||||
def drawClock():
|
||||
while True:
|
||||
sleep(0.4)
|
||||
canvas = Image.new('RGB', (64,128), color = 'black')
|
||||
clock_text = ImageDraw.Draw(canvas)
|
||||
clock_text.text((20,0), datetime.now(), font = clock_font, align = center)
|
||||
showImage(canvas, 32, 0)
|
||||
|
||||
|
||||
|
||||
def get_access_token():
|
||||
global token
|
||||
|
@ -233,12 +252,7 @@ def get_access_token():
|
|||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
print('led-matrix-viewer started')
|
||||
|
||||
while True:
|
||||
get_access_token()
|
||||
drawCanvas()
|
||||
time.sleep(10)
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue