|
| 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