Secondly I want to detect the presence of a USB connection to either the HS or FS port on the 'D' or to the USB port on a Pyboard 1.x. At present I have
Code: Select all
mode = pyb.usb_mode()
if mode is None:
# ignore this bit of code
elif 'VCP' in mode: # User has enabled VCP in boot.py: establish if there is a physical connection
usb_conn = pyb.Pin.board.USB_VBUS.value() # USB is connected to pyb V1.x
if not usb_conn:
usb_conn = hasattr(pyb.Pin.board, 'USB_HS_DP') and pyb.Pin.board.USB_HS_DP.value()
if not usb_conn:
usb_conn = hasattr(pyb.Pin.board, 'USB_DP') and pyb.Pin.board.USB_DP.value()