diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index 0e021e9..2a00d7c 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -61,8 +61,6 @@ void Span::begin(Category catID, const char *displayName, const char *hostNameBa statusLED.init(statusPin,0,autoOffLED); - PushButton::configureTouch(4000,1000,10); // set default parameters for any touch-style pushbuttons - if(requestedMaxCon 0 + else if (pressed==TOUCH && threshold==0){ + for(int i=0;i %d.\n",pin,threshold); +#endif + } +#endif } @@ -209,15 +224,17 @@ void PushButton::reset(){ ////////////////////////////////////// void PushButton::configureTouch(uint16_t measureTime, uint16_t sleepTime, uint16_t thresh){ -#ifndef CONFIG_IDF_TARGET_ESP32C3 +#if SOC_TOUCH_SENSOR_NUM > 0 touchSetCycles(measureTime,sleepTime); - touchThreshold=thresh; + threshold=thresh; #endif } ////////////////////////////////////// -uint16_t PushButton::touchThreshold; +#if SOC_TOUCH_SENSOR_NUM > 0 + touch_value_t PushButton::threshold=0; +#endif //////////////////////////////// // Blinker // diff --git a/src/Utils.h b/src/Utils.h index 82e2a2b..38ec7c0 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -79,8 +79,11 @@ class PushButton{ uint32_t doubleAlarm; uint32_t longAlarm; int pressType; - - static uint16_t touchThreshold; + +#if SOC_TOUCH_SENSOR_NUM > 0 + static touch_value_t threshold; + static const int calibCount=20; +#endif protected: @@ -100,8 +103,10 @@ class PushButton{ static boolean GROUNDED(int pin){return(!digitalRead(pin));} static boolean POWERED(int pin){return(digitalRead(pin));} -#ifndef CONFIG_IDF_TARGET_ESP32C3 - static boolean TOUCH(int pin){return(touchRead(pin)threshold);} #endif PushButton(int pin, pressTest_t pressed=GROUNDED);