diff --git a/src/Utils.cpp b/src/Utils.cpp index 21f57b4..4fd4c68 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -222,6 +222,4 @@ void PushButton::reset(){ ////////////////////////////////////// -#if SOC_TOUCH_SENSOR_NUM > 0 - touch_value_t PushButton::threshold=0; -#endif +touch_value_t PushButton::threshold=0; diff --git a/src/Utils.h b/src/Utils.h index 2883465..ecac65e 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -71,6 +71,12 @@ struct TempBuffer { // PushButton // //////////////////////////////// +#if SOC_TOUCH_VERSION_2 +typedef uint32_t touch_value_t; +#else +typedef uint16_t touch_value_t; +#endif + class PushButton{ int status; @@ -79,11 +85,9 @@ class PushButton{ uint32_t doubleAlarm; uint32_t longAlarm; int pressType; - -#if SOC_TOUCH_SENSOR_NUM > 0 + static touch_value_t threshold; static const int calibCount=20; -#endif protected: @@ -103,10 +107,12 @@ class PushButton{ static boolean TRIGGER_ON_LOW(int pin){return(!digitalRead(pin));} static boolean TRIGGER_ON_HIGH(int pin){return(digitalRead(pin));} -#if SOC_TOUCH_VERSION_1 // ESP32 - static boolean TRIGGER_ON_TOUCH(int pin){return(touchRead(pin) 0 +#if SOC_TOUCH_VERSION_2 static boolean TRIGGER_ON_TOUCH(int pin){return(touchRead(pin)>threshold);} +#else + static boolean TRIGGER_ON_TOUCH(int pin){return(touchRead(pin)