From: Melissa LeBlanc-Williams Date: Thu, 6 May 2021 21:21:54 +0000 (-0700) Subject: Check if pins are in locals instead of try/except X-Git-Tag: 6.7.0^2 X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/commitdiff_plain/3fb96d8f4c44dc949119627833897f1ef58b81e5 Check if pins are in locals instead of try/except --- diff --git a/src/board.py b/src/board.py index 3852a77..9cdd379 100755 --- a/src/board.py +++ b/src/board.py @@ -224,7 +224,7 @@ elif "sphinx" in sys.modules: else: raise NotImplementedError("Board not supported {}".format(board_id)) -try: +if "SCL" in locals() and "SDA" in locals(): def I2C(): """The singleton I2C interface""" @@ -233,17 +233,10 @@ try: return busio.I2C(SCL, SDA) -except NameError: - pass - -try: +if "SCLK" in locals() and "MOSI" in locals() and "MISO" in locals(): def SPI(): """The singleton SPI interface""" import busio return busio.SPI(SCLK, MOSI, MISO) - - -except NameError: - pass