Touch interrupt is not detaching.

Salakhov
Posts: 11
Joined: Sat Aug 24, 2019 2:08 pm

Touch interrupt is not detaching.

Postby Salakhov » Mon Nov 15, 2021 3:24 am

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

franzhoepfinger
Posts: 21
Joined: Wed Mar 04, 2020 7:14 pm

Re: Touch interrupt is not detaching.

Postby franzhoepfinger » Fri Nov 19, 2021 1:42 pm

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

Who is online

Users browsing this forum: Google [Bot] and 86 guests