fixed errors caused by code restructure

This commit is contained in:
Lucca Ketterer 2020-06-08 00:02:50 +02:00
parent 282c3f3a39
commit f71718c5aa
2 changed files with 18 additions and 14 deletions

View File

@ -1,3 +1,7 @@
import sys
import time
import ws2801
def color_cycle(speed): def color_cycle(speed):
if int(speed) == 0: if int(speed) == 0:
delay = 0 delay = 0
@ -11,20 +15,20 @@ def color_cycle(speed):
while r > 0: while r > 0:
r = r-1 r = r-1
g = g+1 g = g+1
set_color(r,g,b) ws2801.set_color(r,g,b)
time.sleep(delay) time.sleep(delay)
while g > 0: while g > 0:
g = g-1 g = g-1
b = b+1 b = b+1
set_color(r,g,b) ws2801.set_color(r,g,b)
time.sleep(delay) time.sleep(delay)
while b > 0: while b > 0:
b = b-1 b = b-1
r = r+1 r = r+1
set_color(r,g,b) ws2801.set_color(r,g,b)
time.sleep(delay) time.sleep(delay)
def visualizer(): def visualizer():
for volume in sys.stdin: for volume in sys.stdin:
volume = int(volume) volume = int(volume)
set_color(volume,0,0) ws2801.set_color(volume,0,0)

View File

@ -1,10 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys import sys
import getopt import getopt
import time
import "ws2801" import ws2801
import "server" import server
import color_mode
def helpmenu(): def helpmenu():
print("Options:") print("Options:")
@ -15,7 +15,7 @@ def helpmenu():
def main(argv): def main(argv):
if not sys.stdin.isatty(): if not sys.stdin.isatty():
visualizer() color_mode.visualizer()
sys.exit() sys.exit()
try: try:
@ -30,14 +30,14 @@ def main(argv):
helpmenu() helpmenu()
sys.exit() sys.exit()
elif opt == "-s": elif opt == "-s":
r,g,b = hex_to_rgb(arg) r,g,b = ws2801.hex_to_rgb(arg)
set_color(r,g,b) ws2801.set_color(r,g,b)
sys.exit() sys.exit()
elif opt == "-c": elif opt == "-c":
color_cycle(arg) color_mode.color_cycle(arg)
elif opt == "-d": elif opt == "-d":
start_server() server.start()
helpmenu() helpmenu()
sys.exit() sys.exit()