Skip to content

Commit 2ac4518

Browse files
authored
Merge pull request #24 from FoamyGuy/alignment_example
Adding alignment example
2 parents a92f6ab + bd6a7cd commit 2ac4518

9 files changed

+64
-0
lines changed

examples/images/blue_rectangle.bmp

17.1 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-FileCopyrightText: 2020 Foamyguy
2+
#
3+
# SPDX-License-Identifier: Unlicense

examples/images/green_circle.bmp

17.1 KB
Binary file not shown.
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-FileCopyrightText: 2020 Foamyguy
2+
#
3+
# SPDX-License-Identifier: Unlicense

examples/images/purple_oval.bmp

17.1 KB
Binary file not shown.
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-FileCopyrightText: 2020 Foamyguy
2+
#
3+
# SPDX-License-Identifier: Unlicense

examples/images/yellow_square.bmp

17.1 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-FileCopyrightText: 2020 Foamyguy
2+
#
3+
# SPDX-License-Identifier: Unlicense

examples/slideshow_alignment_test.py

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
"""
2+
This example runs best on a PyPortal or other device with a
3+
display larger than 128px in both directions.
4+
5+
This example cycles through 4 different images and moves
6+
them around to different positions on the screen each
7+
time it updates by using the alignment feature.
8+
9+
You must copy the images/ directory onto your CIRCUITPY drive.
10+
"""
11+
import board
12+
from adafruit_slideshow import (
13+
PlayBackOrder,
14+
SlideShow,
15+
VerticalAlignment,
16+
HorizontalAlignment,
17+
)
18+
19+
# pylint: disable=no-member
20+
21+
# Create the slideshow object that plays through once alphabetically.
22+
slideshow = SlideShow(
23+
board.DISPLAY, None, folder="/images/", loop=True, order=PlayBackOrder.ALPHABETICAL,
24+
)
25+
26+
aligns = [
27+
(VerticalAlignment.TOP, HorizontalAlignment.CENTER),
28+
(VerticalAlignment.TOP, HorizontalAlignment.RIGHT),
29+
(VerticalAlignment.CENTER, HorizontalAlignment.LEFT),
30+
(VerticalAlignment.CENTER, HorizontalAlignment.CENTER),
31+
(VerticalAlignment.CENTER, HorizontalAlignment.RIGHT),
32+
(VerticalAlignment.BOTTOM, HorizontalAlignment.LEFT),
33+
(VerticalAlignment.BOTTOM, HorizontalAlignment.CENTER),
34+
(VerticalAlignment.BOTTOM, HorizontalAlignment.RIGHT),
35+
(VerticalAlignment.TOP, HorizontalAlignment.LEFT),
36+
]
37+
i = 0
38+
slideshow.h_align = aligns[i][1]
39+
slideshow.v_align = aligns[i][0]
40+
i += 1
41+
42+
prev_img = slideshow.current_image_name
43+
while slideshow.update():
44+
cur_img = slideshow.current_image_name
45+
if prev_img != cur_img:
46+
slideshow.h_align = aligns[i][1]
47+
slideshow.v_align = aligns[i][0]
48+
i += 1
49+
if i >= len(aligns):
50+
i = 0
51+
52+
prev_img = cur_img

0 commit comments

Comments
 (0)