Use of callback function in sleep mode

Discussion related to "under the hood" OpenMV topics.
User avatar
chrisPyres66
Posts: 61
Joined: Mon Jul 16, 2018 9:22 am
Location: France

Use of callback function in sleep mode

Postby chrisPyres66 » Thu Nov 22, 2018 10:28 am

Dear all,

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

Code: Select all

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
User avatar
kwagyeman
Posts: 2606
Joined: Sun May 24, 2015 2:10 pm

Re: Use of callback function in sleep mode

Postby kwagyeman » Thu Nov 22, 2018 1:25 pm

Ibrahim needs to check this.
Nyamekye,
User avatar
iabdalkader
Posts: 654
Joined: Sun May 24, 2015 3:53 pm

Re: Use of callback function in sleep mode

Postby iabdalkader » Thu Nov 22, 2018 3:38 pm

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:

Code: Select all

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()
User avatar
chrisPyres66
Posts: 61
Joined: Mon Jul 16, 2018 9:22 am
Location: France

Re: Use of callback function in sleep mode

Postby chrisPyres66 » Fri Nov 23, 2018 2:48 am

Ok i try to get rtc and rebuild !
Or wait for new release if i dont success !
User avatar
chrisPyres66
Posts: 61
Joined: Mon Jul 16, 2018 9:22 am
Location: France

Re: Use of callback function in sleep mode

Postby chrisPyres66 » Fri Nov 30, 2018 6:15 am

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

Code: Select all

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,
User avatar
iabdalkader
Posts: 654
Joined: Sun May 24, 2015 3:53 pm

Re: Use of callback function in sleep mode

Postby iabdalkader » Fri Nov 30, 2018 10:50 am

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
User avatar
chrisPyres66
Posts: 61
Joined: Mon Jul 16, 2018 9:22 am
Location: France

Re: Use of callback function in sleep mode

Postby chrisPyres66 » Tue Dec 04, 2018 9:15 am

Ok, you are right i should do :

Code: Select all

git checkout .
git pull
i confirm callback funtion in sleep and deepsleep mode
Thanks,

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 4 guests