pyb.USB_HID.rst 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. .. currentmodule:: pyb
  2. .. _pyb.USB_HID:
  3. class USB_HID -- USB Human Interface Device (HID)
  4. =================================================
  5. The USB_HID class allows creation of an object representing the USB
  6. Human Interface Device (HID) interface. It can be used to emulate
  7. a peripheral such as a mouse or keyboard.
  8. Before you can use this class, you need to use :meth:`pyb.usb_mode()` to set the USB mode to include the HID interface.
  9. Constructors
  10. ------------
  11. .. class:: pyb.USB_HID()
  12. Create a new USB_HID object.
  13. Methods
  14. -------
  15. .. method:: USB_HID.recv(data, \*, timeout=5000)
  16. Receive data on the bus:
  17. - ``data`` can be an integer, which is the number of bytes to receive,
  18. or a mutable buffer, which will be filled with received bytes.
  19. - ``timeout`` is the timeout in milliseconds to wait for the receive.
  20. Return value: if ``data`` is an integer then a new buffer of the bytes received,
  21. otherwise the number of bytes read into ``data`` is returned.
  22. .. method:: USB_HID.send(data)
  23. Send data over the USB HID interface:
  24. - ``data`` is the data to send (a tuple/list of integers, or a
  25. bytearray).