Hello,
I’m developping a simple “get an image and send it” (BTW, any such code “ready to go” is welcome, …)
From my experiments, there is an interference between the pyb.USB_VCP and sensor (and maybe led) modules.
Code is below. In a nutshell, I have the red led blinking each time the usb.readline() is empty, and if something to read, send something back with green led blinking. This part works well (as standalone once the cam is reset)
Now I add sensor.reset(): blinking and usb communication still ok. I add sensor.skip_frames(): still ok.
BUT if I add anything else, e.g., “sensor.set_framesize(sensor.QVGA)”, red led blinking is not happening anymore (???) even if communication is still ok, and if I add an “img = sensor.snapshot()” (or even set_pixformat), the communication is not working anymore.
Note that under the IDE, the led is blinking (!), but not when resetting the cam. I tested many things to turn around (switching lines, adding delays)
Maybe I’m missing something, or there is a problem.
I’m under Windows 10.
I hope someone can help.
Thanks for the attention and regards,
Pascal Mayer
########################## code ######################
import time, pyb, sensor, image
RedLed = pyb.LED(1)
GreenLed = pyb.LED(2)
usb = pyb.USB_VCP()
sensor.reset() # Initialize the camera sensor.
sensor.set_framesize(sensor.QQVGA)
#sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
sensor.skip_frames(10) # Let new settings take affect.
#sensor.set_whitebal(False) # Turn off white balance.
#sensor.set_framesize(sensor.QQVGA) # or sensor.QQVGA (or others)
#sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
#sensor.skip_frames(10) # Let new settings take affect.
#img = sensor.snapshot()
while(True):
----line = usb.readline()
----if (line):
--------GreenLed.on()
--------pyb.delay(300)
--------GreenLed.off()
--------pyb.delay(300)
--------s = str(line,“utf-8”)
--------if (“go” in s):
------------usb.write(“YES GO\n”)
------------s3 = “Size " + str(5.3) + " " + str(123) + " \n”
------------usb.write(s3)
--------else:
------------s2 = s + " Rodger"
------------usb.write(s2)
----else:
--------RedLed.on()
--------pyb.delay(300)
--------RedLed.off()
--------pyb.delay(300)