We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fa0c95c commit 78746daCopy full SHA for 78746da
adafruit_pybadger.py
@@ -83,16 +83,18 @@ class PyBadger:
83
84
def __init__(self, i2c=None):
85
# Accelerometer
86
- try:
87
- if i2c is None:
+ if i2c is None:
+ try:
88
i2c = board.I2C()
89
+ except RuntimeError:
90
+ self._accelerometer = None
91
+
92
+ if i2c is not None:
93
int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT)
94
try:
95
self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, address=0x19, int1=int1)
96
except ValueError:
97
self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1)
- except RuntimeError:
- self._accelerometer = None
98
99
# Buttons
100
self._buttons = GamePadShift(digitalio.DigitalInOut(board.BUTTON_CLOCK),
0 commit comments