Переглянути джерело

add: highlight to PATCH-Window

micha 2 роки тому
батько
коміт
151b9e12a5
2 змінених файлів з 105 додано та 14 видалено
  1. 71 0
      _LibreLightDesk.py
  2. 34 14
      vpu/vpu_live.py

+ 71 - 0
_LibreLightDesk.py

@@ -367,6 +367,56 @@ def jclient_send(data):
     cprint("{:0.04} sec.".format(time.time()-t_start),color="yellow")
     cprint("{:0.04} tick".format(time.time()),color="yellow")
 
+
+def _highlight(fix):
+    print("highlight",fix,"1")
+
+    if fix not in FIXTURES.fixtures:
+        return None
+
+    d = FIXTURES.fixtures[fix]
+
+    #for k,v in d.items():
+    #    print("-",k,v)
+    DMX = d["DMX"] + d["UNIVERS"]*512
+    if "ATTRIBUT" in d:
+        ATTR= d["ATTRIBUT"]
+        data = {"VALUE":200,"DMX":1}
+        attr = ""
+
+        if "RED" in ATTR:
+            attr = "RED"
+        elif "DIM" in ATTR:
+            attr = "DIM"
+        else:
+            return #stop
+        
+    
+        print(attr,ATTR[attr])
+        old_val = ATTR[attr]["VALUE"]
+        data["DMX"] = DMX + ATTR[attr]["NR"]-1
+        print(attr,ATTR[attr])
+        print(data)
+        for i in range(4):
+            print("highlight",fix,"0")
+            data["VALUE"] = 0
+            jclient_send([data])
+            time.sleep(0.1)
+
+            print("highlight",fix,"1")
+            data["VALUE"] = 200
+            jclient_send([data])
+            time.sleep(0.1)
+
+        
+        print("highlight",fix,"0")
+        data["VALUE"] = old_val 
+        jclient_send([data])
+
+def highlight(fix):
+    print("highlight",fix)
+    thread.start_new_thread(_highlight,(fix,))
+
 class ValueBuffer():
     def __init__(self,_min=0,_max=255):
         self._value = 2
@@ -2480,6 +2530,9 @@ class GUI_PATCH():
         b = tk.Button(xframe,bg="#ddd", text="DMX-SUM",width=1)
         b.grid(row=r, column=c, sticky=tk.W+tk.E)
         c+=1
+        b = tk.Button(xframe,bg="#ddd", text="TEST",width=1)
+        b.grid(row=r, column=c, sticky=tk.W+tk.E)
+        c+=1
         b = tk.Button(xframe,bg="#ddd", text="DMX Collision!",width=12)
         b.grid(row=r, column=c, sticky=tk.W+tk.E)
         c+=1
@@ -2579,6 +2632,24 @@ class GUI_PATCH():
             b = tk.Button(xframe,bg="#aaa",fg="#225", text="{} : {:03}".format(z,dmx_ch_sum),width=6,anchor="w")
             b.grid(row=r, column=c, sticky=tk.W+tk.E)
 
+
+
+            c+=1
+            def x(fix):
+                def xx():
+                    print("TEST",fix)
+                    if fix in FIXTURES.fixtures:
+                        data = FIXTURES.fixtures[fix]
+                        # print(data)
+                        highlight(fix)
+                return xx
+
+            #print(fix)
+            b = tk.Button(xframe,bg="#aaa",fg="#225", text="TEST",width=4,anchor="w",command=x(fix))
+            b.grid(row=r, column=c, sticky=tk.W+tk.E)
+            #b.command = x
+            #exit()
+
             c+=1
             bg = "#252"
             if collision:

+ 34 - 14
vpu/vpu_live.py

@@ -92,6 +92,7 @@ for i in f:
 
 font = pygame.font.SysFont("freemonobold",22)
 font10 = pygame.font.SysFont("freemonobold",10)
+font12 = pygame.font.SysFont("freemonobold",12)
 font15 = pygame.font.SysFont("freemonobold",15)
 #font = pygame.font.SysFont(None,30)
 fr = font.render("hallo" ,1, (200,0,255))
@@ -116,10 +117,13 @@ def event():
             print(event.dict ) #event.button)
             if event.type == 5:
                 if "button" in event.dict and event.dict["button"] == 1:  #event.button)
-                    if NR:
+                    NR += 1
+                    if NR > 2:
+                        NR = 0
+                if "button" in event.dict and event.dict["button"] == 3:  #event.button)
+                    NR -= 1
+                    if NR <= 0:
                         NR = 0
-                    else:
-                        NR = 1
 
         except Exception as e:
             print(e)
@@ -166,7 +170,7 @@ class Fix():
         self.bmp = 250
 
     def calc(self,data):
-        dmx_sub = [10]*10
+        dmx_sub = [210]*10
         if self.dmx+self.ch < len(data):
             dmx_sub = data[self.dmx:self.dmx+self.ch]
         dim = dmx_sub[0]/255
@@ -195,20 +199,33 @@ def init_gird():
     dmx = 1-1
     ch = 4
     block = [16,16]
-
-    for y in range(8): # row
-        for x in range(12): # column
-            pos=[x,y]
-            f = Fix(pos,dmx,ch)
-            f.block = block
-            GRID.append(f)
-            #print(f)
-            dmx += ch
+    block = [8,8]
+    _x = 12
+    _y = 8
+
+    _x = 24
+    _y = 16
+
+    y=0
+    x=0
+    for i in range((_y+1)*(_x+1)):
+        if i%_x == 0:
+            x=0
+            y+=1
+        
+        pos=[x,y]
+        f = Fix(pos,dmx,ch)
+        f.block = block
+        GRID.append(f)
+        #print(f)
+        dmx += ch
+        x+=1
     return GRID
 
 
 
 NR = 0
+
 def main():
     global IP,GRIP
     GRID =  init_gird()
@@ -244,9 +261,12 @@ def main():
 
             #print(fix.dmx,rgb,pos)
             pygame.draw.rect(window,rgb,pos)
-            if NR:
+            if NR == 1:
                 fr = font15.render("{:2}".format(i+1) ,1, (200,0,255))
                 window.blit(fr,(pos[0]+2,pos[1]+3))
+            elif NR == 2:
+                fr = font12.render("{:2}".format(i*4+1) ,1, (200,0,255))
+                window.blit(fr,(pos[0]+2,pos[1]+3))
             i += 1
 
         pygame.display.flip()