I was browsing through the documentation, trying to make sense of the various sleep modes on the Particle firmware.
This is what I got out of it. Can anybody confirm it or correct me?
Shut down the WiFI module
| Stop running loop()
| | Clear RAM and reset
| | | Wake on Pin
| | | | Wake on Timer
System.sleep(sec) X - - - X
System.sleep(pin, edge) X X - X -
System.sleep(pin, edge, sec) X X - X X
System.sleep(SLEEP_MODE_DEEP, sec) X X X - X
Also, System.sleep(pin, edge) does not clear RAM and and reset. The wording is confusing in the documentation, but it works like System.sleep(pin, edge, sec).
Thanks, fixed. I'll play around with those samples to check my table above.
In the meantime, someone should fix the documentation, because it's quite explicit on that point:
System.sleep(uint16_t wakeUpPin, uint16_t edgeTriggerMode) […] When the specific interrupt arrives, the device awakens from stop mode, it will behave as if the device is reset and run all user code from the beginning with no values being maintained in memory from before the stop mode.
You can edit the document yourself by using the Edit button in the upper right corner of most documentation pages. Or submit an issue on Github. But in this case I fixed it. The problem is that the behavior changed from the Core to Photon/Electron and only one of the two places that text is used had been fixed.