Skip to content

Commit 33cc921

Browse files
authored
Merge pull request #59 from makermelissa/master
Minor Animated Gif Player edits for guide
2 parents 7b5ec1f + 9dd1043 commit 33cc921

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

examples/rgb_display_pillow_animated_gif.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,15 @@
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)
33+
34+
# Set this to None on the Mini PiTFT
2935
reset_pin = digitalio.DigitalInOut(board.D24)
3036

3137
def init_button(pin):
@@ -59,8 +65,8 @@ def __init__(self, display, width=None, height=None, folder=None):
5965
else:
6066
self._height = disp.height
6167
self.display = display
62-
self.advance_button = init_button(board.D17)
63-
self.back_button = init_button(board.D22)
68+
self.advance_button = init_button(BUTTON_NEXT)
69+
self.back_button = init_button(BUTTON_PREVIOUS)
6470
if folder is not None:
6571
self.load_files(folder)
6672
self.run()
@@ -142,7 +148,8 @@ def play(self):
142148

143149
# Check if we have loaded any files first
144150
if not self._gif_files:
145-
print("There are no Gif Images to Play")
151+
print("There are no Gif Images loaded to Play")
152+
return False
146153
while True:
147154
for frame_object in self._frames:
148155
self.display.image(frame_object.image)
@@ -165,7 +172,7 @@ def run(self):
165172
if auto_advance:
166173
self.advance(True)
167174

168-
# Config for display baudrate (default max is 24mhz):
175+
# Config for display baudrate (default max is 64mhz):
169176
BAUDRATE = 64000000
170177

171178
# Setup SPI bus using hardware SPI:
@@ -191,7 +198,7 @@ def run(self):
191198
disp_height = disp.width # we swap height/width to rotate it to landscape!
192199
disp_width = disp.height
193200
else:
194-
disp_width = disp.width # we swap height/width to rotate it to landscape!
201+
disp_width = disp.width
195202
disp_height = disp.height
196203

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

0 commit comments

Comments
 (0)