Skip to content

Commit da03462

Browse files
committed
Minor Animated Gif Player edits for guide
1 parent 7b5ec1f commit da03462

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

examples/rgb_display_pillow_animated_gif.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
import adafruit_rgb_display.ssd1351 as ssd1351 # pylint: disable=unused-import
2424
import adafruit_rgb_display.ssd1331 as ssd1331 # pylint: disable=unused-import
2525

26+
# Change to match your display
27+
BUTTON_NEXT = board.D17
28+
BUTTON_PREVIOUS = board.D22
29+
2630
# Configuration for CS and DC pins (these are PiTFT defaults):
2731
cs_pin = digitalio.DigitalInOut(board.CE0)
2832
dc_pin = digitalio.DigitalInOut(board.D25)
@@ -59,8 +63,8 @@ def __init__(self, display, width=None, height=None, folder=None):
5963
else:
6064
self._height = disp.height
6165
self.display = display
62-
self.advance_button = init_button(board.D17)
63-
self.back_button = init_button(board.D22)
66+
self.advance_button = init_button(BUTTON_NEXT)
67+
self.back_button = init_button(BUTTON_PREVIOUS)
6468
if folder is not None:
6569
self.load_files(folder)
6670
self.run()
@@ -142,7 +146,8 @@ def play(self):
142146

143147
# Check if we have loaded any files first
144148
if not self._gif_files:
145-
print("There are no Gif Images to Play")
149+
print("There are no Gif Images loaded to Play")
150+
return False
146151
while True:
147152
for frame_object in self._frames:
148153
self.display.image(frame_object.image)
@@ -165,7 +170,7 @@ def run(self):
165170
if auto_advance:
166171
self.advance(True)
167172

168-
# Config for display baudrate (default max is 24mhz):
173+
# Config for display baudrate (default max is 64mhz):
169174
BAUDRATE = 64000000
170175

171176
# Setup SPI bus using hardware SPI:
@@ -191,7 +196,7 @@ def run(self):
191196
disp_height = disp.width # we swap height/width to rotate it to landscape!
192197
disp_width = disp.height
193198
else:
194-
disp_width = disp.width # we swap height/width to rotate it to landscape!
199+
disp_width = disp.width
195200
disp_height = disp.height
196201

197202
gif_player = AnimatedGif(disp, width=disp_width, height=disp_height, folder=".")

0 commit comments

Comments
 (0)