Skip to content

Adding alignment example #24

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 3 commits into from
Nov 8, 2020
Merged
Show file tree
Hide file tree
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
Binary file added examples/images/blue_rectangle.bmp
Binary file not shown.
3 changes: 3 additions & 0 deletions examples/images/blue_rectangle.bmp.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2020 Foamyguy
#
# SPDX-License-Identifier: Unlicense
Binary file added examples/images/green_circle.bmp
Binary file not shown.
3 changes: 3 additions & 0 deletions examples/images/green_circle.bmp.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2020 Foamyguy
#
# SPDX-License-Identifier: Unlicense
Binary file added examples/images/purple_oval.bmp
Binary file not shown.
3 changes: 3 additions & 0 deletions examples/images/purple_oval.bmp.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2020 Foamyguy
#
# SPDX-License-Identifier: Unlicense
Binary file added examples/images/yellow_square.bmp
Binary file not shown.
3 changes: 3 additions & 0 deletions examples/images/yellow_square.bmp.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2020 Foamyguy
#
# SPDX-License-Identifier: Unlicense
52 changes: 52 additions & 0 deletions examples/slideshow_alignment_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""
This example runs best on a PyPortal or other device with a
display larger than 128px in both directions.

This example cycles through 4 different images and moves
them around to different positions on the screen each
time it updates by using the alignment feature.

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]
slideshow.v_align = aligns[i][0]
i += 1

prev_img = slideshow.current_image_name
while slideshow.update():
cur_img = slideshow.current_image_name
if prev_img != cur_img:
slideshow.h_align = aligns[i][1]
slideshow.v_align = aligns[i][0]
i += 1
if i >= len(aligns):
i = 0

prev_img = cur_img