Skip to content

Commit 781c8e7

Browse files
authored
Merge pull request #59 from rsbohn/master
Support boards that don't have a fixed I2C bus.
2 parents 0a5a9aa + b4e475f commit 781c8e7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

adafruit_seesaw/tftshield18.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ class TFTShield18(Seesaw):
6666
# TypeError: unsupported operand type(s) for <<: 'int' and '_MockObject'
6767
_button_mask = 0xFF
6868

69-
def __init__(self, i2c_bus=board.I2C(), addr=0x2E):
69+
def __init__(self, i2c_bus=None, addr=0x2E):
70+
if i2c_bus is None:
71+
try:
72+
i2c_bus = board.I2C()
73+
except AttributeError as attrError:
74+
raise ValueError("Board has no default I2C bus.") from attrError
7075
super().__init__(i2c_bus, addr)
7176
self.pin_mode(_TFTSHIELD_RESET_PIN, self.OUTPUT)
7277
self.pin_mode_bulk(self._button_mask, self.INPUT_PULLUP)

0 commit comments

Comments
 (0)