File tree Expand file tree Collapse file tree
CircuitPython_gifio/Single Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments