From 9ccd8209597241948c9780206fce22347e8b7f50 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Mon, 17 May 2021 08:26:10 -0700 Subject: [PATCH] Improve Capacitive Touchpads with threshold --- adafruit_funhouse/peripherals.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_funhouse/peripherals.py b/adafruit_funhouse/peripherals.py index ed9bd86..35e0ffd 100755 --- a/adafruit_funhouse/peripherals.py +++ b/adafruit_funhouse/peripherals.py @@ -74,6 +74,7 @@ def __init__(self): board.CAP9, ): cap = touchio.TouchIn(pin) + cap.threshold = 20000 self._ctp.append(cap) self.i2c = board.I2C() @@ -180,8 +181,7 @@ def slider(self): val = 0 cap_map = b"\x01\x03\x02\x05\x04\x0c\x08\x18\x10" for cap in range(5): - raw = self._ctp[cap + 3].raw_value - if raw > 15000: + if self._ctp[cap + 3].value: val += 1 << (cap) for i, pos in enumerate(tuple(cap_map)): if val == pos: