How to assign a class method as an interrupt handler?

I need a driver DHT11-A2302 for ESP32. No arduino, only ESP-IDF !!!

Found a library using interrupts: GitHub - chaeplin/PietteTech_DHT-8266: DHT Sensor Library for esp8266. The problem is that it was written for Arduino, which absolutely does not suit me.

I’m trying to redo it. The problem is that
gpio_isr_handler_add ((gpio_num_t) _sensorGPIO, isrGpioHandler, this);
does not accept a class method as an interrupt handler, only static. And without this, all this work loses all meaning, because all data and timings are stored in private class variables. How to make interrupts work with class ???

1 Like

You’re going to have to implement something akin to what the people in the Arduino-ESP32 already do to enable abitrary lambdas and members functions as interrupts functions – use std::function.

For their implementation, see the FunctionalInterrupt.* files and examples.

The base ISR function must be a static void function with no arguments, not a member function of the class. However, you can store the to be called function expression in a std::function and call into that object later, just like their implementation does.

Thank you very much, we will try