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:
8383
8484 def __init__ (self , i2c = None ):
8585 # Accelerometer
86- if i2c is None :
87- i2c = board .I2C ()
88- int1 = digitalio .DigitalInOut (board .ACCELEROMETER_INTERRUPT )
8986 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 )
9390 except RuntimeError :
9491 self ._accelerometer = None
9592
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+
9699 # Buttons
97100 self ._buttons = GamePadShift (digitalio .DigitalInOut (board .BUTTON_CLOCK ),
98101 digitalio .DigitalInOut (board .BUTTON_OUT ),
You can’t perform that action at this time.
0 commit comments