From e1e47183809da43b9af7390953a011f75aaf1d17 Mon Sep 17 00:00:00 2001 From: brentru Date: Mon, 29 Jul 2019 11:13:18 -0400 Subject: [PATCH] fix tft-in-use-error --- adafruit_pyportal.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index b4f2668..a541c71 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -167,11 +167,12 @@ def __init__(self, *, url=None, headers=None, json_path=None, regexp_path=None, self._debug = debug - if hasattr(board, 'TFT_BACKLIGHT'): - self._backlight = pulseio.PWMOut(board.TFT_BACKLIGHT) # pylint: disable=no-member - elif hasattr(board, 'TFT_LITE'): - self._backlight = pulseio.PWMOut(board.TFT_LITE) # pylint: disable=no-member - else: + try: + if hasattr(board, 'TFT_BACKLIGHT'): + self._backlight = pulseio.PWMOut(board.TFT_BACKLIGHT) # pylint: disable=no-member + elif hasattr(board, 'TFT_LITE'): + self._backlight = pulseio.PWMOut(board.TFT_LITE) # pylint: disable=no-member + except ValueError: self._backlight = None self.set_backlight(1.0) # turn on backlight