When I do this:
Code: Select all
>>> import pyb
>>> pyb.usb_mode()
'VCP+MSC'
>>> pyb.usb_mode('VCP+HID')
>>> pyb.usb_mode()
'VCP+MSC'
Am I missing something obvious?
Should this work?
I have also tried this code in boot.py.
Thanks!
Code: Select all
>>> import pyb
>>> pyb.usb_mode()
'VCP+MSC'
>>> pyb.usb_mode('VCP+HID')
>>> pyb.usb_mode()
'VCP+MSC'
I've done this and it doesn't work. Here's my boot.py:
Code: Select all
# boot.py -- run on boot-up
import pyb
pyb.country('US') # ISO 3166-1 Alpha-2 code, eg US, GB, DE, AU
#pyb.main('main.py') # main script to run after this oneice
pyb.usb_mode('VCP+HID') # act as a serial device and a mouse
Code: Select all
MicroPython v1.15-126-g29718221d-dirty on 2021-05-18; PYBv1.1 with STM32F405RG
Type "help()" for more information.
>>> pyb.usb_mode()
'VCP+HID'
>>>
Code: Select all
MicroPython v1.17-123-g7f1434442 on 2021-12-16; PYBv1.1 with STM32F405RG
Type "help()" for more information.
>>>
>>> pyb.usb_mode()
'VCP+HID'
>>>
Code: Select all
# simple joystick with 8-bit x,y,z
pyb.usb_mode('VCP+HID', hid=(1, 2, 3, 8, bytes([0x05, 0x01, 0x09, 0x04, 0xa1, 0x01, 0x09, 0x01, 0xa1, 0x00, 0x09, 0x30, 0x09, 0x31, 0x09, 0x32, 0x25, 0x7f, 0x15, 0x81, 0x75, 0x08, 0x95, 0x03, 0x81, 0x02, 0xc0, 0xc0])))
# Send joystick report. Values are -127 to +127.
# hid = pyb.USB_HID()
# hid.send((x, y, z))