Skip to content

Commit 7a5bf7a

Browse files
authored
Merge pull request #62 from makermelissa/master
Slight performance improvement to animated gif player
2 parents 87b1f29 + 298cfc8 commit 7a5bf7a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

examples/rgb_display_pillow_animated_gif.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,16 @@ def play(self):
126126
return False
127127
while True:
128128
for frame_object in self._frames:
129+
start_time = time.monotonic()
129130
self.display.image(frame_object.image)
130131
if not self.advance_button.value:
131132
self.advance()
132133
return False
133134
if not self.back_button.value:
134135
self.back()
135136
return False
136-
time.sleep(frame_object.duration / 1000)
137+
while time.monotonic() < (start_time + frame_object.duration / 1000):
138+
pass
137139

138140
if self._loop == 1:
139141
return True

0 commit comments

Comments
 (0)