From ac273275ea2167235052bef044c28996e415fc38 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Wed, 13 Nov 2019 08:15:02 -0800 Subject: [PATCH] Fixed to work in CP 5.0 and 4.1 --- adafruit_pyportal.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index dfc5696..fc7f82b 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -226,7 +226,10 @@ def __init__(self, *, url=None, headers=None, json_path=None, regexp_path=None, self.set_backlight(i/100) time.sleep(0.005) self.set_background(bootscreen) - board.DISPLAY.wait_for_frame() + try: + board.DISPLAY.refresh(target_frames_per_second=60) + except AttributeError: + board.DISPLAY.wait_for_frame() for i in range(100): # dim up self.set_backlight(i/100) time.sleep(0.005) @@ -446,9 +449,13 @@ def set_background(self, file_or_color, position=None): else: raise RuntimeError("Unknown type of background") self._bg_group.append(self._bg_sprite) - board.DISPLAY.refresh_soon() - gc.collect() - board.DISPLAY.wait_for_frame() + try: + board.DISPLAY.refresh(target_frames_per_second=60) + gc.collect() + except AttributeError: + board.DISPLAY.refresh_soon() + gc.collect() + board.DISPLAY.wait_for_frame() def set_backlight(self, val): """Adjust the TFT backlight. @@ -498,8 +505,11 @@ def set_caption(self, caption_text, caption_position, caption_color): if self._caption: self._caption._update_text(str(caption_text)) # pylint: disable=protected-access - 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() return self._caption = Label(self._caption_font, text=str(caption_text))