forked from pimoroni/interstate75
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgif.py
47 lines (30 loc) · 1.16 KB
/
gif.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
This example lets you display an animated gif, by cycling quickly through a series of PNG images.
First resize your gif to 128x128 pixels (we used https://ezgif.com/resize for this).
Then use https://ezgif.com/split (and 'Output images in PNG format') to split the gif into individual frames.
Save the individual frames in a folder on your I75 called "gif" (or change the folder name in the code below).
Check out https://1jps.tumblr.com/ for many nice retro video game gifs!
"""
import time
from interstate75 import Interstate75, DISPLAY_INTERSTATE75_128X128
import pngdec
import os
# Time to pause between frames
INTERVAL = 0.02
# Setup for the display
i75 = Interstate75(display=DISPLAY_INTERSTATE75_128X128)
display = i75.display
p = pngdec.PNG(display)
while True:
# make a list of files in the gif folder
files = os.listdir("gif")
# open each file in the gif folder
for file in files:
if file.endswith(".png" or ".PNG"):
img = "gif/" + file
p.open_file(img)
# Decode our PNG file and set the X and Y
p.decode(0, 0)
i75.update()
print("Displaying: " + img)
time.sleep(INTERVAL)