Skip to content

Commit c9f2d95

Browse files
authored
Merge pull request #2955 from caternuson/hallo_jump_update
Update HalloWing jump sound
2 parents 38f661b + f70eaa5 commit c9f2d95

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

Hallowing_Jump_Sound/jump-sound/code.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,21 @@ def play_wav(wav):
7474
i2c = board.I2C() # uses board.SCL and board.SDA
7575
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
7676
if 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.")
7992
else:
8093
import adafruit_lis3dh
8194
try:

Hallowing_Jump_Sound/stomp-and-roar/code.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,21 @@ def load_wav(name):
5757
i2c = board.I2C() # uses board.SCL and board.SDA
5858
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
5959
if 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.")
6275
else:
6376
import adafruit_lis3dh
6477
try:

0 commit comments

Comments
 (0)