Skip to content

Commit bae59ed

Browse files
committed
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.
1 parent ae80514 commit bae59ed

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

adafruit_slideshow.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,15 @@ def advance(self):
283283
elif not self.loop:
284284
return False
285285
else:
286-
image_count = len(self._file_list) - 1
286+
image_count = len(self._file_list)
287287
if self._current_image < 0:
288288
self._current_image += image_count
289-
elif self._current_image > image_count:
289+
elif self._current_image >= image_count:
290290
self._current_image -= image_count
291291
self._reorder_images()
292292

293-
imagename = self._file_list[self._current_image]
294-
self._image_file = open(imagename, "rb")
293+
image_name = self._file_list[self._current_image]
294+
self._image_file = open(image_name, "rb")
295295
try:
296296
odb = displayio.OnDiskBitmap(self._image_file)
297297
except ValueError:

0 commit comments

Comments
 (0)