Adafruit_Blinka_Raspberry_P.../examples/playframes.py
Jeff Epler 60ae2029b9
Some checks failed
Pip / build (ubuntu-24.04-arm, 3.11) (push) Has been cancelled
Pip / build (ubuntu-24.04-arm, 3.12) (push) Has been cancelled
Pip / build (ubuntu-24.04-arm, 3.13) (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Wheels / Build SDist (push) Has been cancelled
Wheels / Wheels on ubuntu-24.04-arm (push) Has been cancelled
Wheels / Upload release (push) Has been cancelled
Change module name
Change all references from adafruit_raspberry_pi5_piomatter to
adafruit_blinka_raspberry_pi5_piomatter.

Closes #20
2025-02-13 09:50:37 -06:00

38 lines
1.1 KiB
Python

#!/usr/bin/python3
"""
Display a series of 64x32 PNG images as fast as possible
Run like this:
$ python playframes.py "/path/to/images/*.png"
The image files are sorted and then played repeatedly until interrupted with ctrl-c.
"""
import glob
import sys
import time
import adafruit_blinka_raspberry_pi5_piomatter as piomatter
import numpy as np
import PIL.Image as Image
images = sorted(glob.glob(sys.argv[1]))
geometry = piomatter.Geometry(width=64, height=32, n_addr_lines=4, rotation=piomatter.Orientation.Normal)
framebuffer = np.asarray(Image.open(images[0])) + 0 # Make a mutable copy
nimages = len(images)
matrix = piomatter.PioMatter(colorspace=piomatter.Colorspace.RGB888Packed,
pinout=piomatter.Pinout.AdafruitMatrixBonnet,
framebuffer=framebuffer,
geometry=geometry)
while True:
t0 = time.monotonic()
for i in images:
framebuffer[:] = np.asarray(Image.open(i))
matrix.show()
t1 = time.monotonic()
dt = t1 - t0
fps = nimages/dt
print(f"{nimages} frames in {dt}s, {fps}fps [{matrix.fps}]")