63 lines
955 B
Python
Executable File
63 lines
955 B
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import sys
|
|
import time
|
|
|
|
import blinkt
|
|
|
|
blinkt.set_clear_on_exit()
|
|
|
|
|
|
def usage():
|
|
print("Usage: {} <word or phrase>".format(sys.argv[0]))
|
|
print(sys.argv[1])
|
|
sys.exit(1)
|
|
|
|
|
|
if len(sys.argv) != 4:
|
|
usage()
|
|
|
|
# Exit if non integer value. int() will raise a ValueError
|
|
try:
|
|
r, g, b = [int(x) for x in sys.argv[1:]]
|
|
except ValueError:
|
|
usage()
|
|
|
|
# Exit if any of r, g, b are greater than 255
|
|
if max(r, g, b) > 255:
|
|
usage()
|
|
|
|
|
|
def show_all(state):
|
|
for i in range(blinkt.NUM_PIXELS):
|
|
val = state * 255
|
|
blinkt.set_pixel(i, val, val, val)
|
|
blinkt.show()
|
|
|
|
|
|
def dot():
|
|
show_all(1)
|
|
time.sleep(0.05)
|
|
show_all(0)
|
|
time.sleep(0.2)
|
|
|
|
|
|
def dash():
|
|
show_all(1)
|
|
time.sleep(0.2)
|
|
show_all(0)
|
|
time.sleep(0.2)
|
|
|
|
|
|
def space():
|
|
time.sleep(0.2)
|
|
|
|
|
|
print("Setting Blinkt to {r},{g},{b}".format(r=r, g=g, b=b))
|
|
|
|
blinkt.set_clear_on_exit(False)
|
|
|
|
blinkt.set_all(r, g, b)
|
|
|
|
blinkt.show()
|