blob: 70270443548d97b2c341c0cae80ea79d0dd5251f [file] [log] [blame]
Philip Potter0f8b1ba2016-08-28 18:05:40 +01001.. currentmodule:: pyb
Mike Causerb1457db2017-10-11 01:24:44 +11002.. _pyb.USB_HID:
Philip Potter0f8b1ba2016-08-28 18:05:40 +01003
4class USB_HID -- USB Human Interface Device (HID)
5=================================================
6
7The USB_HID class allows creation of an object representing the USB
8Human Interface Device (HID) interface. It can be used to emulate
9a peripheral such as a mouse or keyboard.
10
11Before you can use this class, you need to use :meth:`pyb.usb_mode()` to set the USB mode to include the HID interface.
12
13Constructors
14------------
15
16.. class:: pyb.USB_HID()
17
18 Create a new USB_HID object.
19
20
21Methods
22-------
23
Philip Pottereb239b82016-08-29 22:42:38 +010024.. 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 Potter0f8b1ba2016-08-28 18:05:40 +010035.. 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).