Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
non-destructive text 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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
badge fixer
non-destructive text micropython
Commits
f2da6467
Commit
f2da6467
authored
Aug 27, 2016
by
Philip Potter
Committed by
Damien George
Aug 29, 2016
Browse files
Options
Downloads
Patches
Plain Diff
docs/pyboard: Update USB mouse tutorial to use pyb.USB_HID().
parent
57c92d90
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/pyboard/tutorial/usb_mouse.rst
+6
-4
6 additions, 4 deletions
docs/pyboard/tutorial/usb_mouse.rst
with
6 additions
and
4 deletions
docs/pyboard/tutorial/usb_mouse.rst
+
6
−
4
View file @
f2da6467
...
@@ -41,7 +41,8 @@ To get the py-mouse to do anything we need to send mouse events to the PC.
...
@@ -41,7 +41,8 @@ To get the py-mouse to do anything we need to send mouse events to the PC.
We will first do this manually using the REPL prompt. Connect to your
We will first do this manually using the REPL prompt. Connect to your
pyboard using your serial program and type the following::
pyboard using your serial program and type the following::
>>> pyb.hid((0, 10, 0, 0))
>>> hid = pyb.USB_HID()
>>> hid.send((0, 10, 0, 0))
Your mouse should move 10 pixels to the right! In the command above you
Your mouse should move 10 pixels to the right! In the command above you
are sending 4 pieces of information: button status, x, y and scroll. The
are sending 4 pieces of information: button status, x, y and scroll. The
...
@@ -52,7 +53,7 @@ Let's make the mouse oscillate left and right::
...
@@ -52,7 +53,7 @@ Let's make the mouse oscillate left and right::
>>> import math
>>> import math
>>> def osc(n, d):
>>> def osc(n, d):
... for i in range(n):
... for i in range(n):
...
pyb.hi
d((0, int(20 * math.sin(i / 10)), 0, 0))
...
hid.sen
d((0, int(20 * math.sin(i / 10)), 0, 0))
... pyb.delay(d)
... pyb.delay(d)
...
...
>>> osc(100, 50)
>>> osc(100, 50)
...
@@ -100,9 +101,10 @@ In ``main.py`` put the following code::
...
@@ -100,9 +101,10 @@ In ``main.py`` put the following code::
switch = pyb.Switch()
switch = pyb.Switch()
accel = pyb.Accel()
accel = pyb.Accel()
hid = pyb.USB_HID()
while not switch():
while not switch():
pyb.hi
d((0, accel.x(), accel.y(), 0))
hid.sen
d((0, accel.x(), accel.y(), 0))
pyb.delay(20)
pyb.delay(20)
Save your file, eject/unmount your pyboard drive, and reset it using the RST
Save your file, eject/unmount your pyboard drive, and reset it using the RST
...
@@ -112,7 +114,7 @@ the mouse around. Try it out, and see if you can make the mouse stand still!
...
@@ -112,7 +114,7 @@ the mouse around. Try it out, and see if you can make the mouse stand still!
Press the USR switch to stop the mouse motion.
Press the USR switch to stop the mouse motion.
You'll note that the y-axis is inverted. That's easy to fix: just put a
You'll note that the y-axis is inverted. That's easy to fix: just put a
minus sign in front of the y-coordinate in the ``
pyb.hi
d()`` line above.
minus sign in front of the y-coordinate in the ``
hid.sen
d()`` line above.
Restoring your pyboard to normal
Restoring your pyboard to normal
--------------------------------
--------------------------------
...
...
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