File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -83,16 +83,19 @@ class PyBadger:
83
83
84
84
def __init__ (self , i2c = None ):
85
85
# Accelerometer
86
- if i2c is None :
87
- i2c = board .I2C ()
88
- int1 = digitalio .DigitalInOut (board .ACCELEROMETER_INTERRUPT )
89
86
try :
90
- self . _accelerometer = adafruit_lis3dh . LIS3DH_I2C ( i2c , address = 0x19 , int1 = int1 )
91
- except ValueError :
92
- self . _accelerometer = adafruit_lis3dh . LIS3DH_I2C ( i2c , int1 = int1 )
87
+ if i2c is None :
88
+ i2c = board . I2C ()
89
+ int1 = digitalio . DigitalInOut ( board . ACCELEROMETER_INTERRUPT )
93
90
except RuntimeError :
94
91
self ._accelerometer = None
95
92
93
+ if i2c is not None :
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 )
98
+
96
99
# Buttons
97
100
self ._buttons = GamePadShift (digitalio .DigitalInOut (board .BUTTON_CLOCK ),
98
101
digitalio .DigitalInOut (board .BUTTON_OUT ),
You can’t perform that action at this time.
0 commit comments