espruino / Espruino

The Espruino JavaScript interpreter - Official Repo
http://www.espruino.com/
Other
2.75k stars 739 forks source link

Add function getWakeupCause for ESP32 #2359

Closed cwilling closed 1 year ago

cwilling commented 1 year ago

This function returns a number representing the reason that a device has woken from deep sleep. Example code:

var wakeupCause = ESP32.getWakeupCause();
if (wakeupCause == 0) {
  // Assume a reboot i.e.completely new start
  OnInit(); 
} else {
  // Wakeup from deep sleep.
  // Could check values 2-6 for explicit wakeup source
  OnWakeup();
}
gfwilliams commented 1 year ago

Looks great, thanks!

I really appreciate the docs in the JSON header too - those will make big difference when folks go to use it