Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
0f8b1ba8
Commit
0f8b1ba8
authored
8 years ago
by
Philip Potter
Committed by
Damien George
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
docs/library: Add reference for pyb.usb_mode and pyb.USB_HID.
parent
f2da6467
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/library/pyb.USB_HID.rst
+28
-0
28 additions, 0 deletions
docs/library/pyb.USB_HID.rst
docs/library/pyb.rst
+29
-1
29 additions, 1 deletion
docs/library/pyb.rst
with
57 additions
and
1 deletion
docs/library/pyb.USB_HID.rst
0 → 100644
+
28
−
0
View file @
0f8b1ba8
.. currentmodule:: pyb
class USB_HID -- USB Human Interface Device (HID)
=================================================
The USB_HID class allows creation of an object representing the USB
Human Interface Device (HID) interface. It can be used to emulate
a peripheral such as a mouse or keyboard.
Before you can use this class, you need to use :meth:`pyb.usb_mode()` to set the USB mode to include the HID interface.
Constructors
------------
.. class:: pyb.USB_HID()
Create a new USB_HID object.
Methods
-------
.. method:: USB_HID.send(data)
Send data over the USB HID interface:
- ``data`` is the data to send (a tuple/list of integers, or a
bytearray).
This diff is collapsed.
Click to expand it.
docs/library/pyb.rst
+
29
−
1
View file @
0f8b1ba8
...
@@ -188,7 +188,7 @@ Miscellaneous functions
...
@@ -188,7 +188,7 @@ Miscellaneous functions
Takes a 4-tuple (or list) and sends it to the USB host (the PC) to
Takes a 4-tuple (or list) and sends it to the USB host (the PC) to
signal a HID mouse-motion event.
signal a HID mouse-motion event.
.. note:: This function is deprecated. Use pyb.USB_HID
()
.send(
...
) instead.
.. note:: This function is deprecated. Use
:meth:`
pyb.USB_HID.send()
`
instead.
.. function:: info([dump_alloc_table])
.. function:: info([dump_alloc_table])
...
@@ -254,6 +254,33 @@ Miscellaneous functions
...
@@ -254,6 +254,33 @@ Miscellaneous functions
Returns a string of 12 bytes (96 bits), which is the unique ID of the MCU.
Returns a string of 12 bytes (96 bits), which is the unique ID of the MCU.
.. function:: usb_mode([modestr], vid=0xf055, pid=0x9801, hid=pyb.hid_mouse)
If called with no arguments, return the current USB mode as a string.
If called with ``modestr`` provided, attempts to set USB mode.
This can only be done when called from ``boot.py`` before
:meth:`pyb.main()` has been called. The following values of
``modestr`` are understood:
- ``None``: disables USB
- ``'VCP'``: enable with VCP (Virtual COM Port) interface
- ``'VCP+MSC'``: enable with VCP and MSC (mass storage device class)
- ``'VCP+HID'``: enable with VCP and HID (human interface device)
For backwards compatibility, ``'CDC'`` is understood to mean
``'VCP'`` (and similarly for ``'CDC+MSC'`` and ``'CDC+HID'``).
The ``vid`` and ``pid`` parameters allow you to specify the VID
(vendor id) and PID (product id).
If enabling HID mode, you may also specify the HID details by
passing the ``hid`` keyword parameter. It takes a tuple of
(subclass, protocol, max packet length, polling interval, report
descriptor). By default it will set appropriate values for a USB
mouse. There is also a ``pyb.hid_keyboard`` constant, which is an
appropriate tuple for a USB keyboard.
Classes
Classes
-------
-------
...
@@ -277,4 +304,5 @@ Classes
...
@@ -277,4 +304,5 @@ Classes
pyb.Switch.rst
pyb.Switch.rst
pyb.Timer.rst
pyb.Timer.rst
pyb.UART.rst
pyb.UART.rst
pyb.USB_HID.rst
pyb.USB_VCP.rst
pyb.USB_VCP.rst
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment