From 9196cd8616a48968a52f0aa266a966e8f4be6dce Mon Sep 17 00:00:00 2001 From: Lukas Schulz Date: Sun, 20 Dec 2020 00:08:08 +0100 Subject: [PATCH] yes. --- main.py | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/main.py b/main.py index 7b92a33..09264a7 100644 --- a/main.py +++ b/main.py @@ -32,6 +32,8 @@ screen = RGBMatrix(options = options) token = util.prompt_for_user_token(username, scope, client_id, client_secret, redirect_uri) +canvas = Image.new('RGB', (192, 128), color = 'red') + def get_track(): print('getting info') sp = spotipy.Spotify(auth=token) @@ -43,28 +45,11 @@ def get_track(): response = requests.get(image_url) image = Image.open(BytesIO(response.content)) print(image_url) - #imageString = requests.get(track['item']['album']['images'][0]['url']) - #image = Image.open(f) - print('resizing image') image = image.resize((32,32)) - print(str(image)) - #return image - #image.save("thumbnail.jpg","JPEG") - print('set image') - #image = Image.new('RGB', (32, 32), color = 'red') - image = image.convert('RGB') - #screen.SetImage(image, 10, 10) - #screen.SetPixel(0,1,255,255,255) - offset_x = 10 - offset_y = 10 -# for x in range(31): -# for y in range(31): -# r, g, b = image.getpixel((x, y)) -# screen.SetPixel(x+offset_x,y+offset_y,r,g,b) - showImage(image) - print('image set') + return image def showImage(image, offset_x = 0, offset_y = 0): + image = image.convert('RGB') width, height = image.size for x in range(width): for y in range(height): @@ -72,6 +57,7 @@ def showImage(image, offset_x = 0, offset_y = 0): screen.SetPixel(x+offset_x,y+offset_y,r,g,b) + #if token: # sp = spotipy.Spotify(auth=token) # track = sp.currently_playing() @@ -82,20 +68,23 @@ def showImage(image, offset_x = 0, offset_y = 0): # image = image.resize((32,32)) # #image.save("thumbnail.jpg","JPEG") #else: - print("Can't get token for", username) +# print("Can't get token for", username) def main(): - x = threading.Thread(target=get_track) + x = threading.Thread(target=updateImage) x.start() +def updateImage(): + print("text") + if __name__ == "__main__": main() print('text') + while True: - time.sleep(10) - print('timed') + showImage(canvas)