QUERY · ISSUE
rp2: Can't wake from lightsleep with Pin IRQ
port-rp2
On a pin change this code sample toggles the LED but never outputs "got here".
from machine import Pin, lightsleep
p25 = Pin(25, Pin.OUT)
p0 = Pin(0, Pin.IN, Pin.PULL_UP)
def foo(_):
p25(not p25()) # Toggle the LED
p0.irq(foo, trigger=Pin.IRQ_FALLING)
while True:
lightsleep()
print('Got here')
The docs indicate that to fix this, the IRQ should be instantiated with wake=machine.SLEEP. Unfortunately this constant does not exist.
CANDIDATE · ISSUE
RP2350 / Pico 2 machine.lightsleep not working correctly
bugport-rp2
Port, board and/or hardware
Pico 2 / RP2350
MicroPython version
MicroPython v1.24.0-preview.201.g269a0e0e1 on 2024-08-09; Raspberry Pi Pico2 with RP2350
Reproduction
- Install latest Firmware from https://micropython.org/download/RPI_PICO2/
- Implement
machine.lightsleep(5000)in your code - Run code.
Expected behaviour
Expected Pico 2 to enter lightsleep mode for 5 seconds, then continue to next bit of code.
Observed behaviour
lightsleep is maybe entered for a cycle or so, but code carries on and never stops executing for any time value I enter for lightsleep.
Additional Information
Complete code example:
# Lightsleep MicroPython example.
from machine import Pin
import time
led = Pin(25, Pin.OUT)
while True:
led.toggle()
time.sleep_ms(5000)
led.toggle()
machine.lightsleep(5000)
Code of Conduct
Yes, I agree