Skip to content

Commit a0692df

Browse files
authored
Merge pull request #96 from adafruit/tap-matching
Tap matching
2 parents 3c54032 + ec1bd72 commit a0692df

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

adafruit_circuitplayground/circuit_playground_base.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import audiocore
4545
except ImportError:
4646
import audioio as audiocore
47+
import os
4748
import analogio
4849
import board
4950
import busio
@@ -162,14 +163,26 @@ def detect_taps(self):
162163
@detect_taps.setter
163164
def detect_taps(self, value):
164165
self._detect_taps = value
165-
if value == 1:
166-
self._lis3dh.set_tap(
167-
value, 90, time_limit=4, time_latency=50, time_window=255
168-
)
169-
if value == 2:
170-
self._lis3dh.set_tap(
171-
value, 60, time_limit=10, time_latency=50, time_window=255
172-
)
166+
if (
167+
"nRF52840" in os.uname().machine
168+
): # If we're on a CPB, use a higher tap threshold
169+
if value == 1:
170+
self._lis3dh.set_tap(
171+
value, 100, time_limit=4, time_latency=50, time_window=255
172+
)
173+
if value == 2:
174+
self._lis3dh.set_tap(
175+
value, 70, time_limit=10, time_latency=50, time_window=255
176+
)
177+
else: # If we're on a CPX
178+
if value == 1:
179+
self._lis3dh.set_tap(
180+
value, 90, time_limit=4, time_latency=50, time_window=255
181+
)
182+
if value == 2:
183+
self._lis3dh.set_tap(
184+
value, 60, time_limit=10, time_latency=50, time_window=255
185+
)
173186

174187
@property
175188
def tapped(self):

0 commit comments

Comments
 (0)