Hello together,
thank you for the great work on OpenMV.
I’m using openMV camera M7 in a battery powered setup outdoors. To record only when something is happening my aim is to always have the openmv system to low-power mode, except sensor signals a HIGH on e.g. pin P0.
I read the documentation about low power states. I require to resume the openmv fast, ~0.3s . Therefore pyb.standby() is not helpful, as it triggers a full system reset on wakeup.
pyb.stop() seems the way to go. Resume execution directly.
I try to build an example:
import sensor, image, time, machine, pyb
from pyb import LED
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
led = LED(1) # red led
def main(x):
global extint, led
led.toggle()
extint.enable()
while(True):
clock.tick()
img = sensor.snapshot()
print(clock.fps())
pyb.stop()
######## Configure external wakeup pin for sleep ######
extint = pyb.ExtInt("P0", pyb.ExtInt.IRQ_RISING, pyb.Pin.PULL_DOWN, main)
#######################################################
main(0)
After script start we directly go into sleep state. openmv disconnects from IDE. A 3.3V HIGH on P0 does toggle the led for the first external interrupt. System seems to come up partially. IDE can not connect again, OpenMV COM port does not show up again.
Documentation of pyb.stop() and pyb.ExtInt are conflicting. pyb.stop() documentation tells that “Upon waking execution continues where it left off.” whereas triggering a pyb.ExtInt() event does execute a callback function. Even assuming that i would always call main with the callback for pyb.ExtInt, callstack would increase with every triggering of callback. Bad for long a long run…
- What is the difference betwen pyb.stop() and machine.sleep()?
- How to resume execution after an external interrupt at the code line of pyb.stop()?
I’m currently using fw build from commit a07fb2f600df48929dbbb4b9edd42a33fd14799b.
Thank you in advance.
Best wishes!