File tree Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -64,13 +64,24 @@ 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+ _i2c_devices = []
68+
69+ for _ in range (10 ):
70+ # try lock 10 times to avoid infinite loop in sphinx build
71+ if i2c .try_lock ():
72+ _i2c_devices = i2c .scan ()
73+ i2c .unlock ()
74+ break
75+
76+ # PyBadge LC doesn't have accelerometer
77+ if int (0x18 ) in _i2c_devices or int (0x19 ) in _i2c_devices :
78+ int1 = digitalio .DigitalInOut (board .ACCELEROMETER_INTERRUPT )
79+ try :
80+ self ._accelerometer = adafruit_lis3dh .LIS3DH_I2C (
81+ i2c , address = 0x19 , int1 = int1
82+ )
83+ except ValueError :
84+ self ._accelerometer = adafruit_lis3dh .LIS3DH_I2C (i2c , int1 = int1 )
7485
7586 # NeoPixels
7687 self ._neopixels = neopixel .NeoPixel (
You can’t perform that action at this time.
0 commit comments