Skip to content

Commit ee236f3

Browse files
committed
ignore hidden files first. ignore non .json files. remove extra slash in _file_list items. Update simpletest
1 parent 99cb770 commit ee236f3

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

adafruit_slideshow.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import json
4747
import displayio
4848

49-
5049
try:
5150
from adafruit_display_text import bitmap_label
5251
import terminalio
@@ -202,13 +201,14 @@ def __init__(
202201
):
203202
def _check_json_file(file):
204203
if TEXT_SLIDES_ENABLED:
205-
with open(file) as _file_obj:
206-
try:
207-
json_data = json.loads(_file_obj.read())
208-
if "text" in json_data:
209-
return True
210-
except ValueError:
211-
return False
204+
if file.endswith(".json"):
205+
with open(file) as _file_obj:
206+
try:
207+
json_data = json.loads(_file_obj.read())
208+
if "text" in json_data:
209+
return True
210+
except ValueError:
211+
return False
212212
return False
213213

214214
self.loop = loop
@@ -233,11 +233,11 @@ def _check_json_file(file):
233233
# Load the image names before setting order so they can be reordered.
234234
self._img_start = None
235235
self._file_list = [
236-
folder + "/" + f
236+
folder + f
237237
for f in os.listdir(folder)
238238
if (
239-
(f.endswith(".bmp") or _check_json_file(folder + "/" + f))
240-
and not f.startswith(".")
239+
not f.startswith(".")
240+
and (f.endswith(".bmp") or _check_json_file(folder + f))
241241
)
242242
]
243243

examples/slideshow_simpletest.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1+
"""Basic demonstration script will create a slideshow
2+
object that plays through once alphabetically."""
13
import board
2-
import pulseio
34
from adafruit_slideshow import PlayBackOrder, SlideShow
45

6+
# use built in display (PyPortal, PyGamer, PyBadge, CLUE, etc.)
7+
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
8+
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
9+
display = board.DISPLAY
10+
511
# pylint: disable=no-member
612

7-
# Create the slideshow object that plays through once alphabetically.
813
slideshow = SlideShow(
914
board.DISPLAY,
10-
pulseio.PWMOut(board.TFT_BACKLIGHT),
11-
folder="/",
15+
None,
16+
folder="/images/",
1217
loop=False,
1318
order=PlayBackOrder.ALPHABETICAL,
1419
)

0 commit comments

Comments
 (0)