Philip Potter | 0f8b1ba | 2016-08-28 18:05:40 +0100 | [diff] [blame] | 1 | .. currentmodule:: pyb |
Mike Causer | b1457db | 2017-10-11 01:24:44 +1100 | [diff] [blame] | 2 | .. _pyb.USB_HID: |
Philip Potter | 0f8b1ba | 2016-08-28 18:05:40 +0100 | [diff] [blame] | 3 | |
| 4 | class USB_HID -- USB Human Interface Device (HID) |
| 5 | ================================================= |
| 6 | |
| 7 | The USB_HID class allows creation of an object representing the USB |
| 8 | Human Interface Device (HID) interface. It can be used to emulate |
| 9 | a peripheral such as a mouse or keyboard. |
| 10 | |
| 11 | Before you can use this class, you need to use :meth:`pyb.usb_mode()` to set the USB mode to include the HID interface. |
| 12 | |
| 13 | Constructors |
| 14 | ------------ |
| 15 | |
| 16 | .. class:: pyb.USB_HID() |
| 17 | |
| 18 | Create a new USB_HID object. |
| 19 | |
| 20 | |
| 21 | Methods |
| 22 | ------- |
| 23 | |
Philip Potter | eb239b8 | 2016-08-29 22:42:38 +0100 | [diff] [blame] | 24 | .. method:: USB_HID.recv(data, \*, timeout=5000) |
| 25 | |
| 26 | Receive data on the bus: |
| 27 | |
| 28 | - ``data`` can be an integer, which is the number of bytes to receive, |
| 29 | or a mutable buffer, which will be filled with received bytes. |
| 30 | - ``timeout`` is the timeout in milliseconds to wait for the receive. |
| 31 | |
| 32 | Return value: if ``data`` is an integer then a new buffer of the bytes received, |
| 33 | otherwise the number of bytes read into ``data`` is returned. |
| 34 | |
Philip Potter | 0f8b1ba | 2016-08-28 18:05:40 +0100 | [diff] [blame] | 35 | .. method:: USB_HID.send(data) |
| 36 | |
| 37 | Send data over the USB HID interface: |
| 38 | |
| 39 | - ``data`` is the data to send (a tuple/list of integers, or a |
| 40 | bytearray). |