Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4997

MicroPython • Re: Lets talk about lightsleep on PICO

$
0
0
In an earlier post, I said I was proposing to oblsolete lightsleep.
I meant that only with respect to RP2040 and RP2350.
For that to be accepted, you'd have to have equivalent code for all of the MicroPython ports.
There is clear precedent that is not required.
I looked at the source code several ports do support lightsleep in a limited fashion.

mimxrt - implements lightsleep but it raises mp_raise_NotImplementedError exception. Basically unsupported in anyway.
nrf - implements lightsleep but it does not support sleeping for a specific time.
cc3200 - also does not support sleeping for a specific time.

Several other ports do not seem to have an implementation at all.
For instance the unix port (which I built and ran on my RPI 4) does not implement it.

Code:

>>> import machine>>> help(machine)object <module 'machine'> is of type module  __name__ -- machine  mem8 -- <8-bit memory>  mem16 -- <16-bit memory>  mem32 -- <32-bit memory>  soft_reset -- <function>  idle -- <function>  time_pulse_us -- <function>  PinBase -- <class 'PinBase'>  Signal -- <class 'Signal'>

Remember, the micropython documentation lightsleep is intentionally ambiguous about what lightsleep does (emphasis mine):
Stops execution in an attempt to enter a low power state.
...
With or without a timeout, execution may resume at any time if there are events that require processing.
...
The precise behaviour and power-saving capabilities of lightsleep and deepsleep is highly dependent on the underlying hardware.
The rp2 port can go its own way and implement something different.
It just needs to be captured in the official documentation.

Statistics: Posted by cpottle9 — Wed Dec 18, 2024 8:19 pm



Viewing all articles
Browse latest Browse all 4997

Trending Articles