Hello. I am developing an ESP32 project and I have set up an interrupt on a button press. When the button is pressed for 3 seconds, the ESP switches off. Here is the code I am using:
The problem is that powerOffDevice() is actually called when I release the button, after having pressed it for 3 seconds. Is there a way to call powerOffDevice() simply after 3 seconds of pressing the button?
Using pinMode INPUT_PULLUP I assume the button is wired between the input pin and GND.
The interrupt routine is set to interrupt when the button is activated duw to "FALLING", when pressed down and directly going asleep.
I can't tell if entering sleep inside an interrupt routine is good.
The return false looks strange. To where is that flase returned?
It does not enter sleep, it switches off. MCU_POWER_HOLD acts as a power switch. I have tried a non-interrupt approach, using millis() inside loop, with the same results.
@alto777
This is required by the arduino-timer.h library. It tells the timer that the task will not repeat (I have also tried returning true and nothing at all, which throws a warning). The library code for the timer function is the following: