Commit 737e27f5 authored by Caughlin Bohn's avatar Caughlin Bohn
Browse files

Back to ssh and fixed missing led. Make sure to reuse ssh connections

parent 131c7ae2
......@@ -2,7 +2,7 @@ import time
import sys
from neopixel import *
import argparse
from random import randint
from random import randint,choice
import socket
# LED strip configuration:
LED_COUNT = 100 # Number of LED pixels.
......@@ -58,8 +58,8 @@ NetLights ={
'DC' : [30,29,28,27,26,25,24,23,22],
'DE' : [31,50,51,52],
'ED' : [52,51,50,31],
'DG' : [31,32,33],
'GD' :[33,32,31],
'DG' : [31,32,33,34],
'GD' :[34,33,32,31],
'EM' :[52,53,54],
'ME' :[54,53,52],
'EN' :[52,55,56],
......@@ -74,8 +74,8 @@ NetLights ={
'HG' :[42,41,40,39],
'LG' :[36,35,34],
'GL' :[34,35,36],
'GK' :[34,37,38],
'KG' :[38,37,34],
'GK' :[33,34,37],
'KG' :[37,34,33],
'HI' :[43,44,45],
'IH' :[45,44,43],
'HJ' :[45,46,47],
......@@ -105,59 +105,38 @@ def find_path(graph, start, end, path=[]):
print("starting")
import random
iter = 0
HOST = '' # Symbolic name meaning all available interfaces
PORT = 50007 # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#sock = socket()
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((HOST, PORT))
s.listen(1)
#conn, addr = s.accept()
lastItem = 0
while 1:
conn, addr = s.accept()
data = conn.recv(1024)
conn.close()
tempData = data.split(" ")
while iter < int(sys.argv[3]):
iter = 0
if tempData[3] != lastItem:
print("I am lying about loops" , data)
for i in range(int(tempData[2])):
print(data,iter)
start = NodePath[tempData[0]]
end = NodePath[tempData[1]]
start = NodePath[sys.argv[1]]
end = NodePath[sys.argv[2]]
### To do random
start_path = find_path(NetPath,start,end)
path = []
try:
for i in range(0,len(start_path)-1):
path.append(start_path[i]+start_path[i+1])
except:
print("empty path")
try:
for a in path:
for i in NetLights.get(a):
r,g,b = 255,0,0
strip.setPixelColor(i,Color(r,g,b))
strip.show()
time.sleep(0.005)
for i in range(0,100):
strip.setPixelColor(i, Color(0,0,0))
### To do random
start_path = find_path(NetPath,start,end)
path = []
try:
for i in range(0,len(start_path)-1):
path.append(start_path[i]+start_path[i+1])
except:
print("empty path")
try:
r,g,b = choice([0,255]),choice([0,255]),choice([0,255])
for a in path:
data = 128
for i in NetLights.get(a):
strip.setPixelColor(i,Color(r,g,b))
strip.show()
time.sleep(0.05)
iter += 1
time.sleep(0.001)
for i in range(0,100):
strip.setPixelColor(i, Color(0,0,0))
strip.show()
time.sleep(0.05)
iter += 1
except Exception as e:
print(str(e))
x=0
print("ERROR")
lastItem = tempData[3]
#conn.close()
except Exception as e:
print(str(e))
x=0
print("ERROR")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment