CircuitPython helper library for displaying a slideshow of images on a display.
Author(s): Kattni Rembor, Carter Nelson, Rose Hooper, Melissa LeBlanc-Williams
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
- class adafruit_slideshow.HorizontalAlignment¶
Defines possible horizontal alignment orders.
- class adafruit_slideshow.PlayBackDirection¶
Defines possible slideshow playback directions.
- BACKWARD = -1¶
The next image is before the current image. When alphabetically sorted, this is towards A.
- FORWARD = 1¶
The next image is after the current image. When alphabetically sorted, this is towards Z.
- class adafruit_slideshow.PlayBackOrder¶
Defines possible slideshow playback orders.
- ALPHABETICAL = 0¶
Orders by alphabetical sort of filenames
- RANDOM = 1¶
Randomly shuffles the images
- class adafruit_slideshow.SlideShow(display: displayio.Display, backlight_pwm: Optional[pwmio.PWMOut] = None, *, folder: str = '/', order: int = 0, loop: bool = True, dwell: int = 3, fade_effect: bool = True, auto_advance: bool = True, direction: int = 1, h_align: int = 1, v_align: int = 1)¶
Class for displaying a slideshow of .bmp images on displays.
display (displayio.Display) – The display to use
backlight_pwm (PWMOut) – The PWMOut object used for the backlight
folder (str) – Specify the folder containing the image files, in quotes. Default is the root directory,
order (PlayBackOrder) – The order in which the images display. You can choose random (
RANDOM) or alphabetical (
ALPHABETICAL). Default is
dwell (int) – The number of seconds each image displays, in seconds. Default is 3.
fade_effect (bool) – Specify whether to include the fade effect between images.
Truetells the code to fade the backlight up and down between image display transitions.
Falsemaintains max brightness on the backlight between image transitions. Default is
auto_advance (bool) – Specify whether to automatically advance after dwell seconds.
Trueif slideshow should auto play,
Falseif you want to control advancement manually. Default is
direction (PlayBackDirection) – The playback direction.
h_align (HorizonalAlignment) – The Horizontal alignment of smaller/larger images
v_align (VerticalAlignment) – The Vertical alignment of smaller/larger images
Example code for Hallowing Express. With this example, the slideshow will play through once in alphabetical order:
from adafruit_slideshow import PlayBackOrder, SlideShow import board import pwmio slideshow = SlideShow(board.DISPLAY, pwmio.PWMOut(board.TFT_BACKLIGHT), folder="/", loop=False, order=PlayBackOrder.ALPHABETICAL) while slideshow.update(): pass
Example code for Hallowing Express. Sets
dwellto 0 seconds, turns
auto_advanceoff, and uses capacitive touch to advance backwards and forwards through the images and to control the brightness level of the backlight:
from adafruit_slideshow import PlayBackOrder, SlideShow, PlayBackDirection import touchio import board import pwmio forward_button = touchio.TouchIn(board.TOUCH4) back_button = touchio.TouchIn(board.TOUCH1) brightness_up = touchio.TouchIn(board.TOUCH3) brightness_down = touchio.TouchIn(board.TOUCH2) slideshow = SlideShow(board.DISPLAY, pwmio.PWMOut(board.TFT_BACKLIGHT), folder="/", auto_advance=False, dwell=0) while True: if forward_button.value: slideshow.direction = PlayBackDirection.FORWARD slideshow.advance() if back_button.value: slideshow.direction = PlayBackDirection.BACKWARD slideshow.advance() if brightness_up.value: slideshow.brightness += 0.001 elif brightness_down.value: slideshow.brightness -= 0.001
- advance() bool ¶
Displays the next image. Returns True when a new image was displayed, False otherwise.
Enable auto-advance based on dwell time. Set to
Falseto manually control.
- property brightness: float¶
Brightness of the backlight when an image is displaying. Clamps to 0 to 1.0
Specify the playback direction. Default is
PlayBackDirection.FORWARD. Can also be
The number of seconds each slide displays, in seconds.
Whether to include the fade effect between slides.
Truetells the code to fade the backlight up and down between slide display transitions.
Falsemaintains max brightness on the backlight between slide transitions.
Specifies whether to loop through the slides continuously or play through the list once.
Truewill continue to loop,
Falsewill play only once.
- property order: int¶
The order in which the images display. You can choose random (
RANDOM) or alphabetical (
- class adafruit_slideshow.VerticalAlignment¶
Defines possible vertical alignment orders.