File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,8 @@ def __init__(self, i2c=None):
9090 self ._accelerometer = adafruit_lis3dh .LIS3DH_I2C (i2c , address = 0x19 , int1 = int1 )
9191 except ValueError :
9292 self ._accelerometer = adafruit_lis3dh .LIS3DH_I2C (i2c , int1 = int1 )
93+ except RuntimeError :
94+ self ._accelerometer = None
9395
9496 # Buttons
9597 self ._buttons = GamePadShift (digitalio .DigitalInOut (board .BUTTON_CLOCK ),
@@ -202,7 +204,10 @@ def light(self):
202204 @property
203205 def acceleration (self ):
204206 """Accelerometer data."""
205- return self ._accelerometer .acceleration
207+ acceleration = None
208+ if self ._accelerometer is not None :
209+ acceleration = self ._accelerometer .acceleration
210+ return acceleration
206211
207212 @property
208213 def brightness (self ):
You can’t perform that action at this time.
0 commit comments