push changes
This commit is contained in:
42
gif.py
Normal file
42
gif.py
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/python3
|
||||
"""
|
||||
Display an animated gif
|
||||
|
||||
Run like this:
|
||||
|
||||
$ python play_gif.py
|
||||
|
||||
The animated gif is played repeatedly until interrupted with ctrl-c.
|
||||
"""
|
||||
|
||||
import time
|
||||
|
||||
import numpy as np
|
||||
import PIL.Image as Image
|
||||
|
||||
import adafruit_blinka_raspberry_pi5_piomatter as piomatter
|
||||
|
||||
width = 192
|
||||
height = 64
|
||||
|
||||
gif_file = "jake2.gif"
|
||||
|
||||
canvas = Image.new('RGB', (width, height), (0, 0, 0))
|
||||
geometry = piomatter.Geometry(width=width, height=height,
|
||||
n_addr_lines=5, rotation=piomatter.Orientation.Normal, n_planes=6, n_temporal_planes=0)
|
||||
framebuffer = np.asarray(canvas) + 0 # Make a mutable copy
|
||||
matrix = piomatter.PioMatter(colorspace=piomatter.Colorspace.RGB888Packed,
|
||||
pinout=piomatter.Pinout.AdafruitMatrixBonnet,
|
||||
framebuffer=framebuffer,
|
||||
geometry=geometry)
|
||||
|
||||
with Image.open(gif_file) as img:
|
||||
print(f"frames: {img.n_frames}")
|
||||
while True:
|
||||
for i in range(img.n_frames):
|
||||
img.seek(i)
|
||||
img2 = img.resize((192,64))
|
||||
canvas.paste(img2, (0,0))
|
||||
framebuffer[:] = np.asarray(canvas)
|
||||
matrix.show()
|
||||
time.sleep(0.05)
|
||||
Reference in New Issue
Block a user