Page 1 of 1

Touch interrupt is not detaching.

Posted: Mon Nov 15, 2021 3:24 am
by Salakhov
Hello,
Touch interrupt is not detaching.

Code: Select all

int threshold = 20;
bool touch1detected = false;

void gotTouch1() {
  touch1detected = true;
}

void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.println("ESP32 Touch Interrupt Test");

  touchAttachInterrupt(T0, gotTouch1, threshold);
  delay(1000);
  detachInterrupt(T0);
  delay(1000);

}
void loop() {
  if (touch1detected) {
    detachInterrupt(T0);
    touch1detected = false;
    Serial.println("Touch 1 detected");
    Serial.println(touchRead(T0));

  }
}

06:47:12.228 -> Touch 1 detected
06:47:12.228 -> 15
06:47:12.275 -> Touch 1 detected
06:47:12.275 -> 0
06:47:12.275 -> Touch 1 detected
06:47:12.275 -> 9
06:47:12.322 -> Touch 1 detected
06:47:12.322 -> 8
06:47:12.322 -> Touch 1 detected
06:47:12.322 -> 6
06:47:12.368 -> Touch 1 detected
06:47:12.368 -> 5
06:47:12.368 -> Touch 1 detected
06:47:12.368 -> 6
06:47:12.415 -> Touch 1 detected
06:47:12.415 -> 5






How to solve the problem?

Thanks

Re: Touch interrupt is not detaching.

Posted: Fri Nov 19, 2021 1:42 pm
by franzhoepfinger
i found out similar things:

https://github.com/espressif/esp-idf/issues/7845
it seems the Touch Read interlocks itself if he see GND or 3.3V