Skip to content

Allow text slides #27

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 13 commits into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
ignore hidden files first. ignore non .json files. remove extra slash…
… in _file_list items. Update simpletest
  • Loading branch information
FoamyGuy committed Nov 18, 2020
commit ee236f33f3b0d008e2bd81c2197faabc8bfc9670
22 changes: 11 additions & 11 deletions adafruit_slideshow.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import json
import displayio


try:
from adafruit_display_text import bitmap_label
import terminalio
Expand Down Expand Up @@ -202,13 +201,14 @@ def __init__(
):
def _check_json_file(file):
if TEXT_SLIDES_ENABLED:
with open(file) as _file_obj:
try:
json_data = json.loads(_file_obj.read())
if "text" in json_data:
return True
except ValueError:
return False
if file.endswith(".json"):
with open(file) as _file_obj:
try:
json_data = json.loads(_file_obj.read())
if "text" in json_data:
return True
except ValueError:
return False
return False

self.loop = loop
Expand All @@ -233,11 +233,11 @@ def _check_json_file(file):
# Load the image names before setting order so they can be reordered.
self._img_start = None
self._file_list = [
folder + "/" + f
folder + f
for f in os.listdir(folder)
if (
(f.endswith(".bmp") or _check_json_file(folder + "/" + f))
and not f.startswith(".")
not f.startswith(".")
and (f.endswith(".bmp") or _check_json_file(folder + f))
)
]

Expand Down
13 changes: 9 additions & 4 deletions examples/slideshow_simpletest.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
"""Basic demonstration script will create a slideshow
object that plays through once alphabetically."""
import board
import pulseio
from adafruit_slideshow import PlayBackOrder, SlideShow

# use built in display (PyPortal, PyGamer, PyBadge, CLUE, etc.)
# see guide for setting up external displays (TFT / OLED breakouts, RGB matrices, etc.)
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/display-and-display-bus
display = board.DISPLAY

# pylint: disable=no-member

# Create the slideshow object that plays through once alphabetically.
slideshow = SlideShow(
board.DISPLAY,
pulseio.PWMOut(board.TFT_BACKLIGHT),
folder="/",
None,
folder="/images/",
loop=False,
order=PlayBackOrder.ALPHABETICAL,
)
Expand Down