Skip to content

Minor Animated Gif Player edits for guide #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions examples/rgb_display_pillow_animated_gif.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@
import adafruit_rgb_display.ssd1351 as ssd1351 # pylint: disable=unused-import
import adafruit_rgb_display.ssd1331 as ssd1331 # pylint: disable=unused-import

# Change to match your display
BUTTON_NEXT = board.D17
BUTTON_PREVIOUS = board.D22

# Configuration for CS and DC pins (these are PiTFT defaults):
cs_pin = digitalio.DigitalInOut(board.CE0)
dc_pin = digitalio.DigitalInOut(board.D25)

# Set this to None on the Mini PiTFT
reset_pin = digitalio.DigitalInOut(board.D24)

def init_button(pin):
Expand Down Expand Up @@ -59,8 +65,8 @@ def __init__(self, display, width=None, height=None, folder=None):
else:
self._height = disp.height
self.display = display
self.advance_button = init_button(board.D17)
self.back_button = init_button(board.D22)
self.advance_button = init_button(BUTTON_NEXT)
self.back_button = init_button(BUTTON_PREVIOUS)
if folder is not None:
self.load_files(folder)
self.run()
Expand Down Expand Up @@ -142,7 +148,8 @@ def play(self):

# Check if we have loaded any files first
if not self._gif_files:
print("There are no Gif Images to Play")
print("There are no Gif Images loaded to Play")
return False
while True:
for frame_object in self._frames:
self.display.image(frame_object.image)
Expand All @@ -165,7 +172,7 @@ def run(self):
if auto_advance:
self.advance(True)

# Config for display baudrate (default max is 24mhz):
# Config for display baudrate (default max is 64mhz):
BAUDRATE = 64000000

# Setup SPI bus using hardware SPI:
Expand All @@ -191,7 +198,7 @@ def run(self):
disp_height = disp.width # we swap height/width to rotate it to landscape!
disp_width = disp.height
else:
disp_width = disp.width # we swap height/width to rotate it to landscape!
disp_width = disp.width
disp_height = disp.height

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