From bae59edcd6b0a0dc493ceee6b95f2dd5b45170de Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Thu, 11 Oct 2018 13:15:11 -0400 Subject: [PATCH] Fixes issue with one/two images failing If only one image was present, it was failing on the second loop. With two images, it showed the first image only on the first pass and the second image only after that. Resolves this issue. --- adafruit_slideshow.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/adafruit_slideshow.py b/adafruit_slideshow.py index 2396025..4433c28 100755 --- a/adafruit_slideshow.py +++ b/adafruit_slideshow.py @@ -283,15 +283,15 @@ def advance(self): elif not self.loop: return False else: - image_count = len(self._file_list) - 1 + image_count = len(self._file_list) if self._current_image < 0: self._current_image += image_count - elif self._current_image > image_count: + elif self._current_image >= image_count: self._current_image -= image_count self._reorder_images() - imagename = self._file_list[self._current_image] - self._image_file = open(imagename, "rb") + image_name = self._file_list[self._current_image] + self._image_file = open(image_name, "rb") try: odb = displayio.OnDiskBitmap(self._image_file) except ValueError: