Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Touch Interrupt on GPIO36 with Inkplate 6 Plus #170

Closed
claria opened this issue Nov 20, 2022 · 1 comment
Closed

Touch Interrupt on GPIO36 with Inkplate 6 Plus #170

claria opened this issue Nov 20, 2022 · 1 comment

Comments

@claria
Copy link

claria commented Nov 20, 2022

Hi,

this is less a bug report but a info for people having the same problem as I had.

I tried to use GPIO36 as interrupt for touch detection instead of polling all the time, since i am using multiple tasks:

attachInterrupt(GPIO_NUM_36, touch_pressed, FALLING);

However i had many, many ISR function calls triggered without touching anything. While investigating the issue i found the following bug reports from ESP-IDF link and link.

When i called adc_power_acquire() before attaching the interrupt everything worked (ISR was called twice however). So in the end i used something like this which works perfectly:


void touch_pressed() {
    static unsigned long last_interrupt_time = 0;
    unsigned long interrupt_time = millis();
    // If interrupts come faster than 200ms, assume it's a bounce and ignore
    if (interrupt_time - last_interrupt_time > 200) {
        // do stuff like notifying a task or so
        last_interrupt_time = interrupt_time;
    }
}

@claria
Copy link
Author

claria commented Nov 20, 2022

Closing it directly since it is no bug, but maybe helpful to another person.

@claria claria closed this as completed Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant