AtomVM icon indicating copy to clipboard operation
AtomVM copied to clipboard

ESP32: add support to light sleep

Open bettio opened this issue 5 months ago • 3 comments

Allow putting ESP32 to light sleep, and wake it up using a GPIO or a timer.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

bettio avatar Aug 08 '25 13:08 bettio

There is something that I'd like to here the opinion about:

Should we use the avm_pubsub for pushing power manager events when returning from sleep? Such as different 3rd party drivers might need to check if any IRQ pin has been raised during sleep, or any other process might need to know that everything was suspend for a certain amount of time. So we have either 2 options: leave the caller handle this when returning from sleep, or standardizing some kind of mechanism for informing drivers and anything else that there was a power management related event.

bettio avatar Aug 10 '25 10:08 bettio

There is something that I'd like to here the opinion about:

Should we use the avm_pubsub for pushing power manager events when returning from sleep? Such as different 3rd party drivers might need to check if any IRQ pin has been raised during sleep, or any other process might need to know that everything was suspend for a certain amount of time. So we have either 2 options: leave the caller handle this when returning from sleep, or standardizing some kind of mechanism for informing drivers and anything else that there was a power management related event.

We could use monitor/2 to get the event.

BEAM documentation reads:

The monitor functionality is expected to be extended. That is, other Types and Items are expected to be supported in a future release.

pguyot avatar Aug 10 '25 12:08 pguyot

We could use monitor/2 to get the event.

This is an interesting suggestion, and might be useful to expose an API for pushing other “monitored” events, like acquiring or loosing a network connection.

I think some standardized notification system would be good, but it should be opt in, so extra resources are not consumed if they are not used.

UncleGrumpy avatar Aug 11 '25 16:08 UncleGrumpy