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 )
33
+
34
+ # Set this to None on the Mini PiTFT
29
35
reset_pin = digitalio .DigitalInOut (board .D24 )
30
36
31
37
def init_button (pin ):
@@ -59,8 +65,8 @@ def __init__(self, display, width=None, height=None, folder=None):
59
65
else :
60
66
self ._height = disp .height
61
67
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 )
64
70
if folder is not None :
65
71
self .load_files (folder )
66
72
self .run ()
@@ -142,7 +148,8 @@ def play(self):
142
148
143
149
# Check if we have loaded any files first
144
150
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
146
153
while True :
147
154
for frame_object in self ._frames :
148
155
self .display .image (frame_object .image )
@@ -165,7 +172,7 @@ def run(self):
165
172
if auto_advance :
166
173
self .advance (True )
167
174
168
- # Config for display baudrate (default max is 24mhz ):
175
+ # Config for display baudrate (default max is 64mhz ):
169
176
BAUDRATE = 64000000
170
177
171
178
# Setup SPI bus using hardware SPI:
@@ -191,7 +198,7 @@ def run(self):
191
198
disp_height = disp .width # we swap height/width to rotate it to landscape!
192
199
disp_width = disp .height
193
200
else :
194
- disp_width = disp .width # we swap height/width to rotate it to landscape!
201
+ disp_width = disp .width
195
202
disp_height = disp .height
196
203
197
204
gif_player = AnimatedGif (disp , width = disp_width , height = disp_height , folder = "." )
0 commit comments