Skip to content

Commit 692dcd7

Browse files
committed
adding alignment example
1 parent a92f6ab commit 692dcd7

9 files changed

+62
-0
lines changed

examples/images/blue_rectangle.bmp

17.1 KB
Binary file not shown.
Lines changed: 3 additions & 0 deletions
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.
Lines changed: 3 additions & 0 deletions
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.
Lines changed: 3 additions & 0 deletions
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.
Lines changed: 3 additions & 0 deletions
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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
import board
10+
from adafruit_slideshow import (
11+
PlayBackOrder,
12+
SlideShow,
13+
VerticalAlignment,
14+
HorizontalAlignment,
15+
)
16+
17+
# pylint: disable=no-member
18+
19+
# Create the slideshow object that plays through once alphabetically.
20+
slideshow = SlideShow(
21+
board.DISPLAY, None, folder="/images/", loop=True, order=PlayBackOrder.ALPHABETICAL,
22+
)
23+
24+
aligns = [
25+
(VerticalAlignment.TOP, HorizontalAlignment.CENTER),
26+
(VerticalAlignment.TOP, HorizontalAlignment.RIGHT),
27+
(VerticalAlignment.CENTER, HorizontalAlignment.LEFT),
28+
(VerticalAlignment.CENTER, HorizontalAlignment.CENTER),
29+
(VerticalAlignment.CENTER, HorizontalAlignment.RIGHT),
30+
(VerticalAlignment.BOTTOM, HorizontalAlignment.LEFT),
31+
(VerticalAlignment.BOTTOM, HorizontalAlignment.CENTER),
32+
(VerticalAlignment.BOTTOM, HorizontalAlignment.RIGHT),
33+
(VerticalAlignment.TOP, HorizontalAlignment.LEFT),
34+
]
35+
i = 0
36+
slideshow.h_align = aligns[i][1]
37+
slideshow.v_align = aligns[i][0]
38+
i += 1
39+
40+
prev_img = slideshow.current_image_name
41+
while slideshow.update():
42+
cur_img = slideshow.current_image_name
43+
if prev_img != cur_img:
44+
slideshow.h_align = aligns[i][1]
45+
slideshow.v_align = aligns[i][0]
46+
i += 1
47+
if i >= len(aligns):
48+
i = 0
49+
50+
prev_img = cur_img

0 commit comments

Comments
 (0)