Skip to content

Commit e4fe9ef

Browse files
authored
Merge pull request #15 from makermelissa/master
Updated code to work on CP 4 and 5
2 parents 5dca5dd + 3d638bc commit e4fe9ef

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

adafruit_pyoa.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,11 @@ def display_card(self, card_num):
263263
self._display_background_for(card)
264264
self.backlight_fade(1.0)
265265
self._display_text_for(card)
266-
267-
board.DISPLAY.refresh_soon()
268-
board.DISPLAY.wait_for_frame()
266+
try:
267+
board.DISPLAY.refresh(target_frames_per_second=60)
268+
except AttributeError:
269+
board.DISPLAY.refresh_soon()
270+
board.DISPLAY.wait_for_frame()
269271

270272
self._play_sound_for(card)
271273

@@ -302,7 +304,10 @@ def play_sound(self, filename, *, wait_to_finish=True, loop=False):
302304
return # nothing more to do, just stopped
303305
filename = self._gamedirectory+"/"+filename
304306
print("Playing sound", filename)
305-
board.DISPLAY.wait_for_frame()
307+
try:
308+
board.DISPLAY.refresh(target_frames_per_second=60)
309+
except AttributeError:
310+
board.DISPLAY.wait_for_frame()
306311
try:
307312
self._wavfile = open(filename, "rb")
308313
except OSError:
@@ -369,8 +374,11 @@ def set_background(self, filename, *, with_fade=True):
369374
x=0, y=0)
370375
self._background_group.append(self._background_sprite)
371376
if with_fade:
372-
board.DISPLAY.refresh_soon()
373-
board.DISPLAY.wait_for_frame()
377+
try:
378+
board.DISPLAY.refresh(target_frames_per_second=60)
379+
except AttributeError:
380+
board.DISPLAY.refresh_soon()
381+
board.DISPLAY.wait_for_frame()
374382
self.backlight_fade(1.0)
375383

376384
def backlight_fade(self, to_light):

0 commit comments

Comments
 (0)