At power-on, I would like to detect whether the OpenMV H7 Plus has been plugged in to a computer. Clearly it can figure this out because the green flashes for the boot loader appear only when connected to USB; they are skipped when powering from battery.
The pyb.USB_VCP().isconnected() method is not what I’m looking for; it reports whether the serial port has been connected… and it never has at the instant of power-on.
Is there a method in some class I missed or a hardware register somewhere I could look at? (I couldn’t see anything useful in pyb.info()… looks like mostly just memory management details.)
Thank you for your thoughts and suggestions!
Context, if helpful:
My application involves saving an image to the H7 Plus’s micro-SD card, then entering standby for 5 minutes (or perhaps longer).
At some point, users will need to collect these images by connecting the H7 Plus to USB and copying them from the micro-SD and then deleting the originals. I’d rather not make them remove the micro-SD card; few computers have readers built-in.
When connected to a computer, it is important not to run my usual code; entering standby would interrupt copying the images. I suspect it could also be problematic to write new images to the filesystem while the micro-SD is being read and written to by the host OS.
While plugged in to USB, I would also like to be able to look for a possible VCP connection to allow optional configuration of device parameters using a simple serial UI.