Skip to content

Commit 421c1d7

Browse files
authored
Create code-slow.py
1 parent b1951eb commit 421c1d7

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# SPDX-FileCopyrightText: 2023 Anne Barela for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
# Documentation:
5+
# https://docs.circuitpython.org/en/latest/shared-bindings/gifio/
6+
# Updated 3/29/2023
7+
import board
8+
import gifio
9+
import displayio
10+
import time
11+
12+
display = board.DISPLAY
13+
splash = displayio.Group()
14+
display.root_group = splash
15+
16+
try:
17+
odg = gifio.OnDiskGif('/sample.gif')
18+
except OSError: # pylint: disable=broad-except
19+
raise Exception("sample.gif was not found\n")
20+
start = time.monotonic()
21+
next_delay = odg.next_frame() # Load the first frame
22+
end = time.monotonic()
23+
call_delay = end - start
24+
25+
# Depending on your display the next line may need Colorspace.RGB565
26+
# instead of Colorspace.RGB565_SWAPPED
27+
face = displayio.TileGrid(odg.bitmap,
28+
pixel_shader=displayio.ColorConverter
29+
(input_colorspace=displayio.Colorspace.RGB565_SWAPPED))
30+
splash.append(face)
31+
board.DISPLAY.refresh()
32+
33+
# Play the GIF file forever
34+
while True:
35+
time.sleep(max(0, next_delay - call_delay))
36+
next_delay = odg.next_frame()

0 commit comments

Comments
 (0)