From 228ecb1fc60a1148d4bd84a6eb04028e5b5ec15a Mon Sep 17 00:00:00 2001 From: thirdr Date: Thu, 23 Jan 2025 15:52:59 +0000 Subject: [PATCH] adding cover-art.py --- .../examples/interstate_75_w/cover-art.py | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 micropython/examples/interstate_75_w/cover-art.py diff --git a/micropython/examples/interstate_75_w/cover-art.py b/micropython/examples/interstate_75_w/cover-art.py new file mode 100644 index 0000000..02539f4 --- /dev/null +++ b/micropython/examples/interstate_75_w/cover-art.py @@ -0,0 +1,41 @@ +""" + +Simple example to display cover art. + +Album art should be saved in 128 x 128 resolution PNG format +and placed in a folder called 'covers' in the root. + +""" + +import time +from interstate75 import Interstate75, DISPLAY_INTERSTATE75_128X128 +import pngdec +import os +from random import choice + +# Time between covers +INTERVAL = 10 + +# Setup for the display +i75 = Interstate75(display=DISPLAY_INTERSTATE75_128X128, stb_invert=False, panel_type=Interstate75.PANEL_GENERIC) +display = i75.display +WIDTH, HEIGHT = display.get_bounds() + +WHITE = display.create_pen(255, 255, 255) + +p = pngdec.PNG(display) + + +while True: + + # Select a PNG image from our 'covers' folder at random + file = choice(os.listdir("covers")) + img = f"covers/{file}" + + p.open_file(img) + + # Decode our PNG file and set the X and Y + p.decode(0, 0) + + i75.update() + time.sleep(INTERVAL)