Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Fadecandy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
scanlime
Fadecandy
Commits
7455cbe7
Commit
7455cbe7
authored
11 years ago
by
Micah Elizabeth Scott
Browse files
Options
Downloads
Patches
Plain Diff
Basic USB example; currently displays random frames very slowly
parent
46b9909a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/usb-basic.py
+41
-0
41 additions, 0 deletions
examples/usb-basic.py
with
41 additions
and
0 deletions
examples/usb-basic.py
0 → 100755
+
41
−
0
View file @
7455cbe7
#!/usr/bin/env python
#
# Basic example for Fadecandy, talking directly to the
# Teensy using PyUSB.
#
# Micah Elizabeth Scott
# This example code is released into the public domain.
#
import
usb.core
import
usb.util
import
random
import
time
import
binascii
dev
=
usb
.
core
.
find
(
idVendor
=
0x1d50
,
idProduct
=
0x607a
)
if
not
dev
:
raise
IOError
(
"
No Fadecandy interfaces found
"
)
dev
.
set_configuration
()
print
"
Serial number: %s
"
%
usb
.
util
.
get_string
(
dev
,
255
,
dev
.
iSerialNumber
)
while
True
:
for
index
in
range
(
25
):
if
index
==
24
:
# Final
control
=
index
|
0x20
else
:
control
=
index
data
=
chr
(
control
)
+
''
.
join
(
chr
(
random
.
randrange
(
256
))
for
i
in
range
(
63
))
dev
.
write
(
1
,
data
)
print
binascii
.
b2a_hex
(
data
)
time
.
sleep
(
0.1
)
print
time
.
sleep
(
2
)
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