File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -64,13 +64,18 @@ def __init__(self):
6464 self ._accelerometer = None
6565
6666 if i2c is not None :
67- int1 = digitalio .DigitalInOut (board .ACCELEROMETER_INTERRUPT )
68- try :
69- self ._accelerometer = adafruit_lis3dh .LIS3DH_I2C (
70- i2c , address = 0x19 , int1 = int1
71- )
72- except ValueError :
73- self ._accelerometer = adafruit_lis3dh .LIS3DH_I2C (i2c , int1 = int1 )
67+ while not i2c .try_lock ():
68+ pass
69+ _i2c_devices = i2c .scan ()
70+ i2c .unlock ()
71+ if (int (0x18 ) in _i2c_devices ): # PyBadge LC doesn't have accelerometer
72+ int1 = digitalio .DigitalInOut (board .ACCELEROMETER_INTERRUPT )
73+ try :
74+ self ._accelerometer = adafruit_lis3dh .LIS3DH_I2C (
75+ i2c , address = 0x19 , int1 = int1
76+ )
77+ except ValueError :
78+ self ._accelerometer = adafruit_lis3dh .LIS3DH_I2C (i2c , int1 = int1 )
7479
7580 # NeoPixels
7681 self ._neopixels = neopixel .NeoPixel (
You can’t perform that action at this time.
0 commit comments