File tree Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -74,8 +74,21 @@ def play_wav(wav):
7474i2c = board .I2C () # uses board.SCL and board.SDA
7575# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
7676if IS_HALLOWING_M4 :
77- import adafruit_msa301
78- ACCEL = adafruit_msa301 .MSA301 (i2c )
77+ # i2c scan to determine which accelo
78+ while not i2c .try_lock ():
79+ pass
80+ ADDR = i2c .scan ()
81+ i2c .unlock ()
82+ if 0x26 in ADDR :
83+ # MSA301
84+ from adafruit_msa3xx import MSA301
85+ ACCEL = MSA301 (i2c )
86+ elif 0x62 in ADDR :
87+ # MSA311
88+ from adafruit_msa3xx import MSA311
89+ ACCEL = MSA311 (i2c )
90+ else :
91+ raise RuntimeError ("Accelerometer not found." )
7992else :
8093 import adafruit_lis3dh
8194 try :
Original file line number Diff line number Diff line change @@ -57,8 +57,21 @@ def load_wav(name):
5757i2c = board .I2C () # uses board.SCL and board.SDA
5858# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
5959if IS_HALLOWING_M4 :
60- import adafruit_msa301
61- ACCEL = adafruit_msa301 .MSA301 (i2c )
60+ # i2c scan to determine which accelo
61+ while not i2c .try_lock ():
62+ pass
63+ ADDR = i2c .scan ()
64+ i2c .unlock ()
65+ if 0x26 in ADDR :
66+ # MSA301
67+ from adafruit_msa3xx import MSA301
68+ ACCEL = MSA301 (i2c )
69+ elif 0x62 in ADDR :
70+ # MSA311
71+ from adafruit_msa3xx import MSA311
72+ ACCEL = MSA311 (i2c )
73+ else :
74+ raise RuntimeError ("Accelerometer not found." )
6275else :
6376 import adafruit_lis3dh
6477 try :
You can’t perform that action at this time.
0 commit comments