Dependencies¶
This driver depends on:
Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.
Installing from PyPI¶
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:
pip3 install adafruit-circuitpython-slideshow
To install system-wide (this may be required in some cases):
sudo pip3 install adafruit-circuitpython-slideshow
To install in a virtual environment in your current project:
mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install adafruit-circuitpython-slideshow
Usage Example¶
from adafruit_slideshow import PlayBackOrder, SlideShow
import board
import pulseio
# Create the slideshow object that plays through once alphabetically.
slideshow = SlideShow(board.DISPLAY, pulseio.PWMOut(board.TFT_BACKLIGHT), folder="/",
loop=False, order=PlayBackOrder.ALPHABETICAL)
while slideshow.update():
pass
Contributing¶
Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.
Documentation¶
For information on building library documentation, please check out this guide.
Table of Contents¶
Simple test¶
Ensure your device works with this simple test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | """Basic demonstration script will create a slideshow
object that plays through once alphabetically."""
import board
from adafruit_slideshow import PlayBackOrder, SlideShow
# use built in display (PyPortal, PyGamer, PyBadge, CLUE, etc.)
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
display = board.DISPLAY
# pylint: disable=no-member
slideshow = SlideShow(
board.DISPLAY,
None,
folder="/images/",
loop=False,
order=PlayBackOrder.ALPHABETICAL,
dwell=10,
)
while slideshow.update():
pass
|
adafruit_slideshow
¶
CircuitPython helper library for displaying a slideshow of images on a display.
- Author(s): Kattni Rembor, Carter Nelson, Roy Hooper, Melissa LeBlanc-Williams
Implementation Notes¶
Hardware:
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, backlight_pwm=None, *, folder='/', order=0, loop=True, dwell=3, fade_effect=True, auto_advance=True, direction=1, h_align=1, v_align=1)¶ Class for displaying a slideshow of .bmp images on displays.
Parameters: - 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 isALPHABETICAL
. - loop (bool) – Specify whether to loop the images or play through the list once.
True
if slideshow will continue to loop,False
if it will play only once. Default isTrue
. - 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.
True
tells the code to fade the backlight up and down between image display transitions.False
maintains max brightness on the backlight between image transitions. Default isTrue
. - auto_advance (bool) – Specify whether to automatically advance after dwell seconds.
True
if slideshow should auto play,False
if you want to control advancement manually. Default isTrue
. - 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 pulseio slideshow = SlideShow(board.DISPLAY, pulseio.PWMOut(board.TFT_BACKLIGHT), folder="/", loop=False, order=PlayBackOrder.ALPHABETICAL) while slideshow.update(): pass
Example code for Hallowing Express. Sets
dwell
to 0 seconds, turnsauto_advance
off, 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 pulseio 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, pulseio.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
()¶ Displays the next image. Returns True when a new image was displayed, False otherwise.
-
auto_advance
= None¶ Enable auto-advance based on dwell time. Set to
False
to manually control.
-
brightness
¶ Brightness of the backlight when an image is displaying. Clamps to 0 to 1.0
-
current_slide_name
¶ Returns the current image name.
-
direction
= None¶ Specify the playback direction. Default is
PlayBackDirection.FORWARD
. Can also bePlayBackDirection.BACKWARD
.
-
dwell
= None¶ The number of seconds each slide displays, in seconds.
-
fade_effect
= None¶ Whether to include the fade effect between slides.
True
tells the code to fade the backlight up and down between slide display transitions.False
maintains max brightness on the backlight between slide transitions.
-
h_align
¶ Get or Set the Horizontal Alignment
-
loop
= None¶ Specifies whether to loop through the slides continuously or play through the list once.
True
will continue to loop,False
will play only once.
-
order
¶ The order in which the images display. You can choose random (
RANDOM
) or alphabetical (ALPHA
).
-
update
()¶ Updates the slideshow to the next image.
-
v_align
¶ Get or Set the Vertical Alignment
- folder (str) – Specify the folder containing the image files, in quotes. Default is
the root directory,
-
class
adafruit_slideshow.
VerticalAlignment
¶ Defines possible vertical alignment orders.