Skip to content

Commit c7c1db3

Browse files
authored
Merge pull request #5 from kattni/off-by-one-fix
Fixes issue with one/two images failing
2 parents ae80514 + bae59ed commit c7c1db3

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)