-
Notifications
You must be signed in to change notification settings - Fork 17
/
scanline.py
33 lines (28 loc) · 1.09 KB
/
scanline.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""Simple animation example using blinkytape.py"""
from blinkytape import BlinkyTape
from time import sleep
import optparse
parser = optparse.OptionParser()
parser.add_option("-p", "--port", dest="portname",
help="serial port (ex: /dev/ttyUSB0)", default=None)
parser.add_option("-c", "--count", dest="ledcount",
help="LED count", default=60, type=int)
parser.add_option("-s", "--size", dest="size",
help="Size of the light wave", default=20, type=int)
(options, args) = parser.parse_args()
if options.portname is not None:
port = options.portname
else:
print("Usage: python scanline.py -p <port name>")
print("(ex.: python scanline.py -p /dev/ttypACM0)")
exit()
blinky = BlinkyTape(port, options.ledcount)
while True:
for position in range(-options.size, options.ledcount + options.size):
for led in range(options.ledcount):
if abs(position - led) < options.size:
blinky.sendPixel(255, 0, 200)
else:
blinky.sendPixel(0, 0, 0)
blinky.show()
sleep(0.005)