import pwmio
import touchio
from adafruit_slideshow import SlideShow, PlayBackDirection

# pylint: disable=no-member

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:
Example #2
0
# SPDX-FileCopyrightText: 2019 Anne Barela for Adafruit Industries
#
# SPDX-License-Identifier: MIT

# CircuitPython Slideshow - uses the adafruit_slideshow.mpy library
import board
from adafruit_slideshow import PlayBackOrder, SlideShow

# Create the slideshow object that plays through once alphabetically.
slideshow = SlideShow(board.DISPLAY,
                      folder="/images",
                      loop=True,
                      order=PlayBackOrder.ALPHABETICAL,
                      dwell=60)

while slideshow.update():
    pass
Example #3
0
import board
import pulseio
from adafruit_slideshow import PlayBackOrder, SlideShow
#pylint: disable=no-member

# 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
You must copy the images/ directory onto your CIRCUITPY drive.
"""
import board
from adafruit_slideshow import (
    PlayBackOrder,
    SlideShow,
    VerticalAlignment,
    HorizontalAlignment,
)

# pylint: disable=no-member

# Create the slideshow object that plays through once alphabetically.
slideshow = SlideShow(
    board.DISPLAY, None, folder="/images/", loop=True, order=PlayBackOrder.ALPHABETICAL,
)

aligns = [
    (VerticalAlignment.TOP, HorizontalAlignment.CENTER),
    (VerticalAlignment.TOP, HorizontalAlignment.RIGHT),
    (VerticalAlignment.CENTER, HorizontalAlignment.LEFT),
    (VerticalAlignment.CENTER, HorizontalAlignment.CENTER),
    (VerticalAlignment.CENTER, HorizontalAlignment.RIGHT),
    (VerticalAlignment.BOTTOM, HorizontalAlignment.LEFT),
    (VerticalAlignment.BOTTOM, HorizontalAlignment.CENTER),
    (VerticalAlignment.BOTTOM, HorizontalAlignment.RIGHT),
    (VerticalAlignment.TOP, HorizontalAlignment.LEFT),
]
i = 0
slideshow.h_align = aligns[i][1]
Example #5
0
import board
from adafruit_slideshow import PlayBackOrder, SlideShow
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
Example #6
0
import board
from adafruit_slideshow import SlideShow, PlayBackDirection
import touchio
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
Example #7
0
    text_scale=1,
)
magtag.set_text("  back        mute      pause/play     fwd", 1)
time.sleep(8)

timestamp = time.monotonic()
sound_toggle = True  # state of sound feedback
autoplay_toggle = True  # state of autoplay
auto_pause = 60  # time between slides in auto mode

# Create the slideshow object that plays through alphabetically.
slideshow = SlideShow(
    magtag.graphics.display,
    None,
    auto_advance=autoplay_toggle,
    folder="/slides",
    loop=True,
    order=PlayBackOrder.ALPHABETICAL,
    dwell=auto_pause,
)

while True:
    slideshow.update()
    if magtag.peripherals.button_a_pressed:
        if sound_toggle:
            magtag.peripherals.play_tone(220, 0.15)
        blink(YELLOW, 0.4)
        slideshow.direction = PlayBackDirection.BACKWARD
        time.sleep(5)
        slideshow.advance()
"""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
Example #9
0
import board
from adafruit_slideshow import SlideShow, PlayBackDirection, PlayBackOrder
import touchio
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="/images",
                      auto_advance=False,
                      order=PlayBackOrder.ALPHABETICAL,
                      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
Example #10
0
import rgbmatrix
from adafruit_slideshow import SlideShow

displayio.release_displays()
matrix = rgbmatrix.RGBMatrix(
    width=64,
    height=32,
    bit_depth=5,
    rgb_pins=[board.D6, board.D5, board.D9, board.D11, board.D10, board.D12],
    addr_pins=[board.A5, board.A4, board.A3, board.A2],
    clock_pin=board.D13,
    latch_pin=board.D0,
    output_enable_pin=board.D1,
)

display = framebufferio.FramebufferDisplay(matrix, auto_refresh=True)

slideshow = SlideShow(
    display,
    backlight_pwm=None,
    folder="/images",
    loop=True,
    order=0,
    fade_effect=False,
    dwell=8,
    auto_advance=True,
)

while slideshow.update():
    pass
Example #11
0
pose_time = 30  # choose the time to hold each pose in seconds

solenoid = DigitalInOut(board.D2)  # pad #2 on CLUE driving a MOSFET
solenoid.direction = Direction.OUTPUT
solenoid.value = False


def chime(repeat):
    for _ in range(repeat):
        solenoid.value = True
        time.sleep(0.03)
        solenoid.value = False
        time.sleep(0.25)


slideshow = SlideShow(clue.display, None, folder="/icons", auto_advance=False)

while True:
    if clue.proximity > 10:
        time.sleep(1)
        chime(1)
        time.sleep(pose_time)
        chime(2)
        slideshow.direction = PlayBackDirection.FORWARD
        slideshow.advance()

    if clue.button_b:  # skip ahead
        slideshow.direction = PlayBackDirection.FORWARD
        slideshow.advance()

    if clue.button_a:  # skip back
Example #12
0
pin_down = DigitalInOut(board.BUTTON_DOWN)
pin_down.switch_to_input(pull=Pull.UP)
button_down = Debouncer(pin_down)
pin_up = DigitalInOut(board.BUTTON_UP)
pin_up.switch_to_input(pull=Pull.UP)
button_up = Debouncer(pin_up)

align_right = True
auto_advance = True

slideshow = SlideShow(
    display,
    None,
    folder=IMAGE_FOLDER,
    order=0,
    auto_advance=False,
    fade_effect=False,
    dwell=IMAGE_DURATION,
    h_align=HorizontalAlignment.RIGHT,
)
last_advance = time.monotonic()


def advance():
    # pylint: disable=global-statement
    global align_right, last_advance
    align_right = not align_right
    if align_right:
        slideshow.h_align = HorizontalAlignment.RIGHT
    else:
        slideshow.h_align = HorizontalAlignment.LEFT
Example #13
0
            prettyprintname += "   "
        prettyprintname += file
        if isdir:
            prettyprintname += "/"
        print('{0:<20} Size: {1:>6}'.format(prettyprintname, sizestr))

        # recursively print directory contents
        if isdir:
            print_directory(path + "/" + file, tabs + 1)


try:
    print_directory(IMAGE_DIRECTORY)
except OSError as error:
    raise Exception("No images found on flash or SD Card")

# Create the slideshow object that plays through once alphabetically.
slideshow = SlideShow(board.DISPLAY,
                      None,
                      folder=IMAGE_DIRECTORY,
                      loop=True,
                      order=PlayBackOrder.ALPHABETICAL,
                      dwell=0)
while True:
    if not switch.value:
        print("Click!")
        slideshow.direction = PlayBackDirection.FORWARD
        slideshow.advance()
        while not switch.value:
            pass
Example #14
0
"""Display a series of bitmaps using the buttons to advance through the list. To use: place
supported bitmap files on your CIRCUITPY drive, then press the buttons on your CLUE to advance
through them.
 
Requires the Adafruit CircuitPython Slideshow library!"""

from adafruit_clue import clue
from adafruit_slideshow import SlideShow, PlayBackDirection

slideshow = SlideShow(clue.display, auto_advance=False)

while True:
    if clue.button_b:
        slideshow.direction = PlayBackDirection.FORWARD
        slideshow.advance()
    if clue.button_a:
        slideshow.direction = PlayBackDirection.BACKWARD
        slideshow.advance()
import board
from adafruit_slideshow import SlideShow, PlayBackDirection
import audioio
import digitalio
import touchio

# Create the slideshow object that plays through once alphabetically.
slideshow = SlideShow(board.DISPLAY)

# Set the touch objects to the first and last teeth
back_pin = board.TOUCH1
forward_pin = board.TOUCH4

# Perform a couple extra steps for the HalloWing M4
try:
    if getattr(board, "CAP_PIN"):
        # Create digitalio objects and pull low for HalloWing M4
        cap_pin = digitalio.DigitalInOut(board.CAP_PIN)
        cap_pin.direction = digitalio.Direction.OUTPUT
        cap_pin.value = False
    if getattr(board, "SPEAKER_ENABLE"):
        # Enable the Speaker
        speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
        speaker_enable.direction = digitalio.Direction.OUTPUT
        speaker_enable.value = True
except AttributeError:
    pass

# Create the touchio objects for HalloWing M0
back_button = touchio.TouchIn(back_pin)
forward_button = touchio.TouchIn(forward_pin)
"""
Slideshow Example using the CircuitPlayground and TFT Gizmo

Written by Melissa LeBlanc-Williams for Adafruit Industries
"""

import board
import digitalio
from adafruit_gizmo import tft_gizmo
from adafruit_slideshow import SlideShow, PlayBackDirection

display = tft_gizmo.TFT_Gizmo()

forward_button = digitalio.DigitalInOut(board.BUTTON_A)
forward_button.switch_to_input(pull=digitalio.Pull.DOWN)
back_button = digitalio.DigitalInOut(board.BUTTON_B)
back_button.switch_to_input(pull=digitalio.Pull.DOWN)

slideshow = SlideShow(display, None, 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()
Example #17
0
import board
from adafruit_slideshow import PlayBackOrder, SlideShow, PlayBackDirection
import audioio
import pulseio
import touchio

# Create the slideshow object that plays through once alphabetically.
slideshow = SlideShow(board.DISPLAY,
                      pulseio.PWMOut(board.TFT_BACKLIGHT),
                      folder="/",
                      loop=True,
                      order=PlayBackOrder.ALPHABETICAL)

# Create the touch objects on the first and last teeth
back_button = touchio.TouchIn(board.TOUCH1)
forward_button = touchio.TouchIn(board.TOUCH4)

# Setup the speaker output
a = audioio.AudioOut(board.SPEAKER)


# Helper function that takes in the file name string, splits it at the period, and keeps only the
# beginning of the string. i.e. kitten.bmp becomes kitten.
def basename(file_name):
    return file_name.rsplit('.', 1)[0]


# Helper function to handle wav file playback
def play_file(wav_file_name):
    try:
        data = open(wav_file_name, "rb")
Example #18
0
button_down = Debouncer(pin_down)
pin_up = DigitalInOut(board.BUTTON_UP)
pin_up.switch_to_input(pull=Pull.UP)
button_up = Debouncer(pin_up)

ALIGN_RIGHT = True
auto_advance = True

i = 0
NUM_FOLDERS = 2  #first folder is numbered 0

slideshow = SlideShow(
    display,
    None,
    folder=IMAGE_FOLDER[i],
    order=0,
    auto_advance=False,
    fade_effect=False,
    dwell=IMAGE_DURATION[i],
    h_align=HorizontalAlignment.RIGHT,
)

LAST_ADVANCE = time.monotonic()
last_movement = time.monotonic()
MODE = 1


def advance():
    ''' go to the next slide '''
    # pylint: disable=global-statement
    global ALIGN_RIGHT, LAST_ADVANCE
    ALIGN_RIGHT = not ALIGN_RIGHT
import board
from adafruit_slideshow import PlayBackOrder, SlideShow
import pulseio

# Create the slideshow object that plays through once alphabetically.
slideshow = SlideShow(board.DISPLAY,
                      pulseio.PWMOut(board.TFT_BACKLIGHT),
                      folder="/images",
                      loop=True,
                      order=PlayBackOrder.ALPHABETICAL,
                      dwell=2.5)

while slideshow.update():
    pass