Use of callback function in sleep mode

Dear all,

I try to use a callback function when the camera wakeup from a sleep with this code :

import pyb, machine, time

red_led   = pyb.LED(1)
red_led.off()

def test(line) :
   red_led.toggle()
   return

rtc = pyb.RTC()
rtc.datetime((2014, 5, 1, 4, 13, 0, 0, 0))
rtc.wakeup(500, test(1) )

while(True):
   machine.sleep()
   #test(0)
   #time.sleep(500)

When i run the programm, the led is just lighting once but never toggle after.

Thanks for your help

Ibrahim needs to check this.

Hi, there’s a bug in our RTC interrupt handler, the fix will be in the next release (unless you want to build from source). Also note your code has a few issues, it won’t work either way. This works fine:

import pyb, machine, time

red_led = pyb.LED(1)
red_led.off()

def test(arg):
    red_led.toggle()
   
rtc = pyb.RTC()
rtc.datetime((2014, 5, 1, 4, 13, 0, 0, 0))

while (True):
    rtc.wakeup(1000, test)
    machine.sleep()

Ok i try to get rtc and rebuild !
Or wait for new release if i dont success !

Hello,

I cloned the last git i think with
git clone --recursive https://github.com/openmv/openmv.git

compiled and program the firmware but the code below does not work

import pyb, machine, time
red_led = pyb.LED(1)
red_led.off()
def test(arg):
    red_led.toggle()
    return 
rtc = pyb.RTC()
rtc.datetime((2014, 5, 1, 4, 13, 0, 0, 0))
while (True):
    rtc.wakeup(1000, test)
    machine.sleep()

Do i something wrong ?

Thanks,

No, it should work. Try git pull, and make clean and build again. Make sure you upload the firmware you build. It should be version 3.3.0

Ok, you are right i should do :

git checkout .
git pull

i confirm callback funtion in sleep and deepsleep mode
Thanks,