2323import adafruit_rgb_display .ssd1351 as ssd1351 # pylint: disable=unused-import
2424import 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):
2731cs_pin = digitalio .DigitalInOut (board .CE0 )
2832dc_pin = digitalio .DigitalInOut (board .D25 )
33+
34+ # Set this to None on the Mini PiTFT
2935reset_pin = digitalio .DigitalInOut (board .D24 )
3036
3137def 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 ):
169176BAUDRATE = 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
193200else :
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
197204gif_player = AnimatedGif (disp , width = disp_width , height = disp_height , folder = "." )
0 commit comments