46 lines
932 B
Python
Executable File
46 lines
932 B
Python
Executable File
#!/usr/bin/env python3
|
|
import sys
|
|
import getopt
|
|
import time
|
|
|
|
import "ws2801"
|
|
import "server"
|
|
|
|
def helpmenu():
|
|
print("Options:")
|
|
print("-h show help")
|
|
print("-s <color> color in hex")
|
|
print("-c <speed> colorcycle")
|
|
|
|
def main(argv):
|
|
|
|
if not sys.stdin.isatty():
|
|
visualizer()
|
|
sys.exit()
|
|
|
|
try:
|
|
opts, args = getopt.getopt(argv,"hds:c:r")
|
|
except getopt.GetoptError:
|
|
print("ws2801.py: invalid option")
|
|
print("Try 'ws2801.py -h' for help")
|
|
sys.exit(2)
|
|
|
|
for opt, arg in opts:
|
|
if opt == "-h":
|
|
helpmenu()
|
|
sys.exit()
|
|
elif opt == "-s":
|
|
r,g,b = hex_to_rgb(arg)
|
|
set_color(r,g,b)
|
|
sys.exit()
|
|
elif opt == "-c":
|
|
color_cycle(arg)
|
|
elif opt == "-d":
|
|
start_server()
|
|
|
|
helpmenu()
|
|
sys.exit()
|
|
|
|
if __name__ == "__main__":
|
|
main(sys.argv[1:])
|