Added check to ignore PushButton::TOUCH is compiling on ESP32-C3

The C3 does not have touch capability.  Compiler will throw an error is PushButton::TOUCH is referenced when compiling for C3.
This commit is contained in:
Gregg 2022-08-13 10:06:33 -05:00
parent ee55f268bd
commit dbcd9e267b
4 changed files with 6 additions and 8 deletions

View File

@ -712,7 +712,7 @@ class SpanButton : PushButton {
};
SpanButton(int pin, uint16_t longTime=2000, uint16_t singleTime=5, uint16_t doubleTime=200, pressTest_t pressed=GROUNDED);
SpanButton(int pin, pressTest_t pressed=GROUNDED, uint16_t longTime=2000, uint16_t singleTime=5, uint16_t doubleTime=200) : SpanButton(pin,longTime,singleTime,doubleTime,pressed){};
SpanButton(int pin, pressTest_t pressed, uint16_t longTime=2000, uint16_t singleTime=5, uint16_t doubleTime=200) : SpanButton(pin,longTime,singleTime,doubleTime,pressed){};
};

View File

@ -209,8 +209,10 @@ void PushButton::reset(){
//////////////////////////////////////
void PushButton::configureTouch(uint16_t measureTime, uint16_t sleepTime, uint16_t thresh){
#ifndef CONFIG_IDF_TARGET_ESP32C3
touchSetCycles(measureTime,sleepTime);
touchThreshold=thresh;
#endif
}
//////////////////////////////////////

View File

@ -99,7 +99,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)<touchThreshold);}
#endif
PushButton(int pin, pressTest_t pressed=GROUNDED);

View File

@ -12,13 +12,6 @@ CUSTOM_CHAR_STRING(DarkMode, AAAAAAAA-BBBB-AAAA-AAAA-AAAAAAAAAAAA, PR, "MY_VALUE
void setup() {
Serial.begin(115200);
touchSetCycles(4000,1000);
while(1){
Serial.println(touchRead(4));
delay(1000);
}
// homeSpan.setLogLevel(2);
// homeSpan.setStatusPin(13);