From 4dd8599ab3c2ff211538c472ae4d944af4e09192 Mon Sep 17 00:00:00 2001 From: Fisch Date: Thu, 13 Oct 2022 22:47:40 +0200 Subject: [PATCH] improve touch filtering --- touchcontroller/src/main.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/touchcontroller/src/main.cpp b/touchcontroller/src/main.cpp index 33d13b7..a23284c 100644 --- a/touchcontroller/src/main.cpp +++ b/touchcontroller/src/main.cpp @@ -7,11 +7,14 @@ uint16_t rawIn[INPUTS]; uint16_t countedLow[INPUTS]; //count the times input was below threshold (touched) #define TOUCHTHRESHOLD 1000 //below which value input counts as touched. 00) { + countedLow[i]--; //decrease counter + } } } @@ -70,10 +75,19 @@ void loop() { } + + for (uint8_t i=0;i=COUNTEDLOWTHRESHOLD) { //key pressed/touched + last_output[i]=true; + }else if (countedLow[i]<=COUNTEDLOWTHRESHOLD_OFF) { //key pressed/touched + last_output[i]=false; + } + } + // ## Calculate Byte ## byte newTouch=0; for (uint8_t i=0;i=COUNTEDLOWTHRESHOLD) { //key pressed/touched + if (last_output[i]) { //key pressed/touched newTouch^=1<