From f6479fd4c568319188c7712ebf041beb367e3d67 Mon Sep 17 00:00:00 2001 From: dherrada Date: Fri, 17 Jul 2020 12:49:35 -0400 Subject: [PATCH 1/6] Detect taps setter now checks to see which board it's on and adjusts the threshold accordingly --- .../circuit_playground_base.py | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/adafruit_circuitplayground/circuit_playground_base.py b/adafruit_circuitplayground/circuit_playground_base.py index eebd682..85d843f 100755 --- a/adafruit_circuitplayground/circuit_playground_base.py +++ b/adafruit_circuitplayground/circuit_playground_base.py @@ -162,14 +162,24 @@ def detect_taps(self): @detect_taps.setter def detect_taps(self, value): self._detect_taps = value - if value == 1: - self._lis3dh.set_tap( - value, 90, time_limit=4, time_latency=50, time_window=255 - ) - if value == 2: - self._lis3dh.set_tap( - value, 60, time_limit=10, time_latency=50, time_window=255 - ) + if hasattr(board, 'A0'): # If we're on a CPX or CPC + if value == 1: + self._lis3dh.set_tap( + value, 90, time_limit=4, time_latency=50, time_window=255 + ) + if value == 2: + self._lis3dh.set_tap( + value, 60, time_limit=10, time_latency=50, time_window=255 + ) + else: # If we're on a CPB + if value == 1: + self._lis3dh.set_tap( + value, 93, time_limit=4, time_latency=50, time_window=255 + ) + if value == 2: + self._lis3dh.set_tap( + value, 63, time_limit=10, time_latency=50, time_window=255 + ) @property def tapped(self): From 1d41884fc1f4f22b429f80062e93d7f9f465708b Mon Sep 17 00:00:00 2001 From: dherrada Date: Fri, 17 Jul 2020 12:51:21 -0400 Subject: [PATCH 2/6] Formatted --- adafruit_circuitplayground/circuit_playground_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_circuitplayground/circuit_playground_base.py b/adafruit_circuitplayground/circuit_playground_base.py index 85d843f..e4ad023 100755 --- a/adafruit_circuitplayground/circuit_playground_base.py +++ b/adafruit_circuitplayground/circuit_playground_base.py @@ -162,7 +162,7 @@ def detect_taps(self): @detect_taps.setter def detect_taps(self, value): self._detect_taps = value - if hasattr(board, 'A0'): # If we're on a CPX or CPC + if hasattr(board, "A0"): # If we're on a CPX or CPC if value == 1: self._lis3dh.set_tap( value, 90, time_limit=4, time_latency=50, time_window=255 @@ -171,7 +171,7 @@ def detect_taps(self, value): self._lis3dh.set_tap( value, 60, time_limit=10, time_latency=50, time_window=255 ) - else: # If we're on a CPB + else: # If we're on a CPB if value == 1: self._lis3dh.set_tap( value, 93, time_limit=4, time_latency=50, time_window=255 From f1626cd6105bec92c06cad8d8da56980704f4081 Mon Sep 17 00:00:00 2001 From: dherrada Date: Fri, 17 Jul 2020 13:00:28 -0400 Subject: [PATCH 3/6] Tweaked the offset by a bit --- adafruit_circuitplayground/circuit_playground_base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_circuitplayground/circuit_playground_base.py b/adafruit_circuitplayground/circuit_playground_base.py index e4ad023..acf0e62 100755 --- a/adafruit_circuitplayground/circuit_playground_base.py +++ b/adafruit_circuitplayground/circuit_playground_base.py @@ -174,11 +174,11 @@ def detect_taps(self, value): else: # If we're on a CPB if value == 1: self._lis3dh.set_tap( - value, 93, time_limit=4, time_latency=50, time_window=255 + value, 100, time_limit=4, time_latency=50, time_window=255 ) if value == 2: self._lis3dh.set_tap( - value, 63, time_limit=10, time_latency=50, time_window=255 + value, 70, time_limit=10, time_latency=50, time_window=255 ) @property From 809a084ac17dd994ec7f9ce50f43d4f837e80fd9 Mon Sep 17 00:00:00 2001 From: dherrada Date: Fri, 17 Jul 2020 13:45:28 -0400 Subject: [PATCH 4/6] Added more explanation --- adafruit_circuitplayground/circuit_playground_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_circuitplayground/circuit_playground_base.py b/adafruit_circuitplayground/circuit_playground_base.py index acf0e62..6119eef 100755 --- a/adafruit_circuitplayground/circuit_playground_base.py +++ b/adafruit_circuitplayground/circuit_playground_base.py @@ -162,7 +162,7 @@ def detect_taps(self): @detect_taps.setter def detect_taps(self, value): self._detect_taps = value - if hasattr(board, "A0"): # If we're on a CPX or CPC + if hasattr(board, "A0"): # If we're on a CPX or CPC, use a higher tap threshold if value == 1: self._lis3dh.set_tap( value, 90, time_limit=4, time_latency=50, time_window=255 From fd55f39f75da45c0bfaa038dc1f83f6a18fdec04 Mon Sep 17 00:00:00 2001 From: dherrada Date: Fri, 17 Jul 2020 15:23:29 -0400 Subject: [PATCH 5/6] Using os.uname to check for board instead --- .../circuit_playground_base.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/adafruit_circuitplayground/circuit_playground_base.py b/adafruit_circuitplayground/circuit_playground_base.py index 6119eef..2ed2088 100755 --- a/adafruit_circuitplayground/circuit_playground_base.py +++ b/adafruit_circuitplayground/circuit_playground_base.py @@ -44,6 +44,7 @@ import audiocore except ImportError: import audioio as audiocore +import os import analogio import board import busio @@ -162,23 +163,25 @@ def detect_taps(self): @detect_taps.setter def detect_taps(self, value): self._detect_taps = value - if hasattr(board, "A0"): # If we're on a CPX or CPC, use a higher tap threshold + if ( + "nRF52840" in os.uname().machine + ): # If we're on a CPB, use a higher tap threshold if value == 1: self._lis3dh.set_tap( - value, 90, time_limit=4, time_latency=50, time_window=255 + value, 100, time_limit=4, time_latency=50, time_window=255 ) if value == 2: self._lis3dh.set_tap( - value, 60, time_limit=10, time_latency=50, time_window=255 + value, 70, time_limit=10, time_latency=50, time_window=255 ) - else: # If we're on a CPB + else: # If we're on a CPX or CPC if value == 1: self._lis3dh.set_tap( - value, 100, time_limit=4, time_latency=50, time_window=255 + value, 90, time_limit=4, time_latency=50, time_window=255 ) if value == 2: self._lis3dh.set_tap( - value, 70, time_limit=10, time_latency=50, time_window=255 + value, 60, time_limit=10, time_latency=50, time_window=255 ) @property From ec1bd7250ee83d60d3e47395a914c12ace5cca06 Mon Sep 17 00:00:00 2001 From: dherrada <33632497+dherrada@users.noreply.github.com> Date: Fri, 17 Jul 2020 16:24:45 -0400 Subject: [PATCH 6/6] Remove cpc reference --- adafruit_circuitplayground/circuit_playground_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_circuitplayground/circuit_playground_base.py b/adafruit_circuitplayground/circuit_playground_base.py index 2ed2088..febc396 100755 --- a/adafruit_circuitplayground/circuit_playground_base.py +++ b/adafruit_circuitplayground/circuit_playground_base.py @@ -174,7 +174,7 @@ def detect_taps(self, value): self._lis3dh.set_tap( value, 70, time_limit=10, time_latency=50, time_window=255 ) - else: # If we're on a CPX or CPC + else: # If we're on a CPX if value == 1: self._lis3dh.set_tap( value, 90, time_limit=4, time_latency=50, time_window=255