idk ... stuff happend ... is working better now

This commit is contained in:
2020-06-08 00:59:51 +02:00
parent bf797da205
commit c04dc20af6
3 changed files with 34 additions and 13 deletions
+2
View File
@@ -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
View File
@@ -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