mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-16 07:42:37 +00:00
Fix button interrupt after light sleep (#3587)
* Make ButtonThread instance extern Previously was a static local instance in setup(). Now declared in ButtonThread.cpp, accessible via extern declaration in ButtonThread. * Extract attachInterrupt() calls to public method; create matching method for detachInterrupt() * Change suspension of button interrupts for light-sleep * Fix declaration for ARCH_PORTDUINO * Remove LOG_DEBUG used during testing * Don't assume device has a button.. * Guard entire constructor code * Don't use BUTTON_PIN with ARCH_PORTDUINO --------- Co-authored-by: Manuel <71137295+mverch67@users.noreply.github.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "GPS.h"
|
||||
#endif
|
||||
|
||||
#include "ButtonThread.h"
|
||||
#include "MeshRadio.h"
|
||||
#include "MeshService.h"
|
||||
#include "NodeDB.h"
|
||||
@@ -337,7 +338,10 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r
|
||||
#ifdef BUTTON_PIN
|
||||
// The enableLoraInterrupt() method is using ext0_wakeup, so we are forced to use GPIO wakeup
|
||||
gpio_num_t pin = (gpio_num_t)(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN);
|
||||
gpio_intr_disable(pin);
|
||||
|
||||
// Have to *fully* detach the normal button-interrupts first
|
||||
buttonThread->detachButtonInterrupts();
|
||||
|
||||
gpio_wakeup_enable(pin, GPIO_INTR_LOW_LEVEL);
|
||||
esp_sleep_enable_gpio_wakeup();
|
||||
#endif
|
||||
@@ -364,9 +368,9 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r
|
||||
assert(res == ESP_OK);
|
||||
|
||||
#ifdef BUTTON_PIN
|
||||
// Disable wake-on-button interrupt. Re-attach normal button-interrupts
|
||||
gpio_wakeup_disable(pin);
|
||||
// Would have thought that need gpio_intr_enable() here, but nope..
|
||||
// Works fine without it; crashes with it.
|
||||
buttonThread->attachButtonInterrupts();
|
||||
#endif
|
||||
|
||||
esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause();
|
||||
|
||||
Reference in New Issue
Block a user