fix: device sleep (part 1) (#3590)

* fix sleep part 1

* always show wakeup reason in debug log

* fix screen turn on issue

* avoid unnecessary reboot when entering light sleep

* set DIO1 based on radio type

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
Manuel
2024-04-12 17:01:24 +02:00
committed by GitHub
parent 8fd32f3452
commit 4c9646f7d9
4 changed files with 76 additions and 24 deletions

View File

@@ -102,18 +102,21 @@ static void lsIdle()
powerFSM.trigger(EVENT_SERIAL_CONNECTED);
break;
case ESP_SLEEP_WAKEUP_GPIO:
// GPIO wakeup is now used for all ESP32 devices during light sleep
powerFSM.trigger(EVENT_PRESS);
break;
default:
// We woke for some other reason (device interrupt?)
LOG_INFO("wakeCause2 %d\n", wakeCause2);
// We woke for some other reason (button press, device IRQ interrupt)
// Let the NB state handle the IRQ (and that state will handle stuff like IRQs etc)
// we lie and say "wake timer" because the interrupt will be handled by the regular IRQ code
powerFSM.trigger(EVENT_WAKE_TIMER);
#ifdef BUTTON_PIN
bool pressed = !digitalRead(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN);
#else
bool pressed = false;
#endif
if (pressed) { // If we woke because of press, instead generate a PRESS event.
powerFSM.trigger(EVENT_PRESS);
} else {
// Otherwise let the NB state handle the IRQ (and that state will handle stuff like IRQs etc)
// we lie and say "wake timer" because the interrupt will be handled by the regular IRQ code
powerFSM.trigger(EVENT_WAKE_TIMER);
}
break;
}
} else {