idk ... stuff happend ... is working better now
This commit is contained in:
@@ -35,8 +35,10 @@ def main(argv):
|
||||
sys.exit()
|
||||
elif opt == "-c":
|
||||
color_mode.color_cycle(arg)
|
||||
sys.exit()
|
||||
elif opt == "-d":
|
||||
server.start()
|
||||
sys.exit()
|
||||
|
||||
helpmenu()
|
||||
sys.exit()
|
||||
|
||||
+10
-9
@@ -19,14 +19,15 @@ def start():
|
||||
conn, address = server_socket.accept() # accept new connection
|
||||
print("Connection from: " + str(address))
|
||||
# receive data stream. it won't accept data packet greater than 1024 bytes
|
||||
data = conn.recv(1024).decode()
|
||||
if not data:
|
||||
print("Disconnected: " + str(address))
|
||||
break
|
||||
if validate_data(data):
|
||||
r,g,b = ws2801.hex_to_rgb(data)
|
||||
ws2801.set_color(r,g,b)
|
||||
else:
|
||||
print("incorrect format. use hex color code.")
|
||||
while True:
|
||||
data = conn.recv(1024).decode()
|
||||
if not data:
|
||||
print("Disconnected: " + str(address))
|
||||
break
|
||||
if validate_data(data):
|
||||
r,g,b = ws2801.hex_to_rgb(data)
|
||||
ws2801.set_color(r,g,b)
|
||||
else:
|
||||
print("incorrect format. use hex color code.")
|
||||
conn.close() # close the connection
|
||||
|
||||
|
||||
Reference in New Issue
Block a user