23
23
import adafruit_rgb_display .ssd1351 as ssd1351 # pylint: disable=unused-import
24
24
import adafruit_rgb_display .ssd1331 as ssd1331 # pylint: disable=unused-import
25
25
26
+ # Change to match your display
27
+ BUTTON_NEXT = board .D17
28
+ BUTTON_PREVIOUS = board .D22
29
+
26
30
# Configuration for CS and DC pins (these are PiTFT defaults):
27
31
cs_pin = digitalio .DigitalInOut (board .CE0 )
28
32
dc_pin = digitalio .DigitalInOut (board .D25 )
@@ -59,8 +63,8 @@ def __init__(self, display, width=None, height=None, folder=None):
59
63
else :
60
64
self ._height = disp .height
61
65
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 )
64
68
if folder is not None :
65
69
self .load_files (folder )
66
70
self .run ()
@@ -142,7 +146,8 @@ def play(self):
142
146
143
147
# Check if we have loaded any files first
144
148
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
146
151
while True :
147
152
for frame_object in self ._frames :
148
153
self .display .image (frame_object .image )
@@ -165,7 +170,7 @@ def run(self):
165
170
if auto_advance :
166
171
self .advance (True )
167
172
168
- # Config for display baudrate (default max is 24mhz ):
173
+ # Config for display baudrate (default max is 64mhz ):
169
174
BAUDRATE = 64000000
170
175
171
176
# Setup SPI bus using hardware SPI:
@@ -191,7 +196,7 @@ def run(self):
191
196
disp_height = disp .width # we swap height/width to rotate it to landscape!
192
197
disp_width = disp .height
193
198
else :
194
- disp_width = disp .width # we swap height/width to rotate it to landscape!
199
+ disp_width = disp .width
195
200
disp_height = disp .height
196
201
197
202
gif_player = AnimatedGif (disp , width = disp_width , height = disp_height , folder = "." )
0 commit comments