add descriptions

This commit is contained in:
Cole Deck 2024-05-08 15:18:09 -05:00
parent dc4cf5c222
commit faf33aede7
3 changed files with 64 additions and 14 deletions

View File

@ -3,7 +3,7 @@ core:
serverip: 172.26.178.114
clientip: 172.26.176.1
server: Hyper-Vd
loopspeed: 40 # fps
loopspeed: 100 # fps
arm:
ip: 192.168.1.145
@ -29,7 +29,7 @@ cameras:
port: 32200
led:
fps: 90
fps: 100
timeout: 1
controllers:
- universe: 1

View File

@ -309,7 +309,19 @@ class LEDSystem():
self.mode = stmode
return self
def setrange(self, start, end, r,g,b):
val = (r,g,b)
for x in range(start,end):
self.data[x] = val
def setallrings(self, r,g,b, exclude):
startidx1 = self.rings[0][2]
endidx2 = self.rings[-1][3]
endidx1 = self.rings[exclude][2]
startidx2 = self.rings[exclude][3]+1
self.setrange(startidx, endidx, r,g,b)
def setring(self, r,g,b,idx):
ring = self.rings[idx]
@ -319,7 +331,7 @@ class LEDSystem():
#senduniverse(data, ring[2])
return self
def runmodes(self, ring = -1, speed = 1):
def runmodes(self, ring = -1, arm_position = None):
#fprint("Mode: " + str(self.mode))
if self.mode == "Startup":
# loading animation. cable check
@ -387,6 +399,28 @@ class LEDSystem():
else:
self.setring(0,50,100,ring)
self.setmode("idle")
elif self.mode == "Moving":
if self.firstrun:
self.firstrun = False
posxy = arm_position[0:1]
posxy[0] = int(posxy[0] * 1000)
posxy[0] = int(posxy[1] * 1000)
radius = int(arm_position[2] * 1000)
base = (0,50,100)
target = (100,100,100)
deltar = target[0] - base[0]
deltag = target[0] - base[0]
#deltab = target[0] - base[0]
# reset!
self.setallringsexcept(0,50,100, ring)
# fade outwards
for idx,led in enumerate(self.leds):
dist = int(math.srqt(math.pow(int(posxy[0] - led[0]), 2) + math.pow(int(posxy[1] - led[1]), 2)))
if dist < radius:
ratio = dist/radius
self.data[idx] = (int(base[0] + ratio * deltar), int(base[1] + ratio * deltag), 100) #base[2] + ratio * deltab)
elif self.mode == "idle":
time.sleep(0)
@ -523,6 +557,9 @@ class LEDSystem():
else:
self.data[num] = (int(r), int(g), int(b))
return self
def setpixelfast3(self, rgb, num):
self.data[num] = rgb
def close(self):
time.sleep(0.5)
@ -574,7 +611,7 @@ class LEDSystem():
time.sleep(0.00001)
return self
def mainloop(self, stmode, ring = -1, fps = 100, preview = False):
def mainloop(self, stmode, ring = -1, fps = 100, preview = False, arm_position = None):
while uptime() - self.start < 1/fps:
time.sleep(0.00001)
#fprint("Running LED loop with ring " + str(ring) + " and set mode " + str(stmode))
@ -584,7 +621,7 @@ class LEDSystem():
self.setmode(stmode)
#if self.
self.runmodes(ring)
self.runmodes(ring, arm_position)
if preview:
self.drawdata()
return self

31
run.py
View File

@ -69,6 +69,7 @@ sensors = [0,0,0,0]
websocket_process = None
arm_updates = Queue()
animation_wait = False
arm_position = (0,0,0,0,0,0)
def arm_start_callback(res):
fprint("Arm action complete.")
@ -165,10 +166,15 @@ def check_server():
for idx in range(len(cable_list)):
if cable_list[idx] is not False:
cabledata = jbs.get_position(str(idx))
fs = cabledata["fullspecs"]
tmp1 = {"part_number": cable_list[idx], "position": idx, "name": cable_list[idx], "brand": cabledata["brand"] }
if "image" in cabledata:
tmp1 = {"part_number": cable_list[idx], "position": idx, "name": cable_list[idx], "brand": cabledata["brand"], "image": cabledata["image"], "description": "Blah", "short_description": "Bla"}
else:
tmp1 = {"part_number": cable_list[idx], "position": idx, "name": cable_list[idx], "brand": cabledata["brand"], "description": "Blah", "short_description": "Bla"}
tmp1["image"] = cabledata["image"]
if "Product Overview" in fs and "Product Category" in fs["Product Overview"]:
tmp1["short_description"] = fs["Product Overview"]["Product Category"]
if "Product Overview" in fs and "Suitable Applications" in fs["Product Overview"]:
tmp1["description"] = fs["Product Overview"]["Suitable Applications"]
tmp.append(tmp1)
out = {"map": tmp}
fprint(out)
@ -262,7 +268,7 @@ def check_server():
sleep(0.001) # Sleep to prevent tight loop
#sleep(0.001) # Sleep to prevent tight loop
@ -448,6 +454,7 @@ def mainloop_server(pool):
global oldmode
global arm_updates
global animation_wait
global arm_position
if mode != oldmode:
print(" ***** Running mode:", mode, "***** ")
@ -464,12 +471,18 @@ def mainloop_server(pool):
arm_updates.get()
ledsys.mainloop(None, ring_animation)
elif ring_animation is not None and real:
if animation_wait:
if not arm_updates.empty():
animation_wait = False
val = arm_updates.get()
if animation_wait and not arm_updates.empty():
animation_wait = False
val = None
while not arm_updates.empty():
tmp = arm_updates.get()
if type(tmp) != tuple:
val = tmp
else:
arm_position = tmp
if val is not None:
ledsys.mainloop(led_set_mode, ring_animation)
led_set_mode = None
led_set_mode = None
else:
pass
#fprint("Not triggering LED loop: no ring animation")