From 3d638bc20cbc11cf0c488fb20a50e01ba3df94cd Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Tue, 26 Nov 2019 17:21:41 -0800 Subject: [PATCH] Updated code to work on CP 4 and 5 --- adafruit_pyoa.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/adafruit_pyoa.py b/adafruit_pyoa.py index a97c24e..e874ea1 100644 --- a/adafruit_pyoa.py +++ b/adafruit_pyoa.py @@ -263,9 +263,11 @@ def display_card(self, card_num): self._display_background_for(card) self.backlight_fade(1.0) self._display_text_for(card) - - board.DISPLAY.refresh_soon() - board.DISPLAY.wait_for_frame() + try: + board.DISPLAY.refresh(target_frames_per_second=60) + except AttributeError: + board.DISPLAY.refresh_soon() + board.DISPLAY.wait_for_frame() self._play_sound_for(card) @@ -302,7 +304,10 @@ def play_sound(self, filename, *, wait_to_finish=True, loop=False): return # nothing more to do, just stopped filename = self._gamedirectory+"/"+filename print("Playing sound", filename) - board.DISPLAY.wait_for_frame() + try: + board.DISPLAY.refresh(target_frames_per_second=60) + except AttributeError: + board.DISPLAY.wait_for_frame() try: self._wavfile = open(filename, "rb") except OSError: @@ -369,8 +374,11 @@ def set_background(self, filename, *, with_fade=True): x=0, y=0) self._background_group.append(self._background_sprite) if with_fade: - board.DISPLAY.refresh_soon() - board.DISPLAY.wait_for_frame() + try: + board.DISPLAY.refresh(target_frames_per_second=60) + except AttributeError: + board.DISPLAY.refresh_soon() + board.DISPLAY.wait_for_frame() self.backlight_fade(1.0) def backlight_fade(self, to_light):