Skip to content

Commit 0503f11

Browse files
authored
Merge pull request #22 from tlyu/fix-clue-mic
fix mic on Clue demo
2 parents 58c8cb6 + 493ee62 commit 0503f11

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

examples/ble_adafruit_clue.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,12 @@
114114
clue._mic.record( # pylint: disable=protected-access
115115
mic_samples, len(mic_samples)
116116
)
117+
# Need to create an array of the correct type, because ulab
118+
# seems to get broadcasting of builtin Python types wrong.
119+
offset = np.array([32768], dtype=np.uint16)
117120
# This subtraction yields unsigned values which are
118121
# reinterpreted as signed after passing.
119-
mic_svc.sound_samples = mic_samples - 32768
122+
mic_svc.sound_samples = mic_samples - offset
120123
mic_last_update = now_msecs
121124

122125
neopixel_values = neopixel_svc.values

0 commit comments

Comments
 (0)