playframes.py
1 #!/usr/bin/python3 2 """ 3 Display a series of 64x32 PNG images as fast as possible 4 5 Run like this: 6 7 $ python playframes.py "/path/to/images/*.png" 8 9 The image files are sorted and then played repeatedly until interrupted with ctrl-c. 10 """ 11 12 import glob 13 import sys 14 15 import adafruit_raspberry_pi5_piomatter 16 import numpy as np 17 import PIL.Image as Image 18 19 images = sorted(glob.glob(sys.argv[1])) 20 21 geometry = adafruit_raspberry_pi5_piomatter.Geometry(width=64, height=32, n_addr_lines=4, rotation=adafruit_raspberry_pi5_piomatter.Orientation.Normal) 22 framebuffer = np.asarray(Image.open(images[0])) + 0 # Make a mutable copy 23 matrix = adafruit_raspberry_pi5_piomatter.AdafruitMatrixBonnetRGB888Packed(framebuffer, geometry) 24 25 while True: 26 for i in images: 27 print(i) 28 framebuffer[:] = np.asarray(Image.open(i)) 29 matrix.show()