Browse Source

extend: vpu grid numbering/overlay

micha 2 years ago
parent
commit
73d1ea7ca8
3 changed files with 90 additions and 32 deletions
  1. 17 8
      _LibreLightDesk.py
  2. 13 4
      fix_gen.py
  3. 60 20
      vpu/vpu_live.py

+ 17 - 8
_LibreLightDesk.py

@@ -413,6 +413,11 @@ def _highlight(fix):
         data["VALUE"] = old_val 
         jclient_send([data])
 
+def highlight2(fix):
+    def x():
+        highlight(fix)
+    return x
+
 def highlight(fix):
     print("highlight",fix)
     thread.start_new_thread(_highlight,(fix,))
@@ -1444,9 +1449,13 @@ class Xevent():
                     val = "-"
             print("SHIFT",val,_shift_key)
             if val:
-                if self.attr == "DIM" and self.fix == 0 and val == "click":
-                    pass    
-                else:
+                #if self.attr == "DIM" and self.fix == 0 and val == "click":
+                #if self.fix == 0 and val == "click":
+                #if self.attr == "DIM" and self.fix == 0 and val == "click":
+                #if self.attr == "DIM" and self.fix == 0 and val == "click":
+                #    pass    
+                #else:
+                if 1:
                     FIXTURES.encoder(fix=self.fix,attr=self.attr,xval=val)
                 
             master.refresh_fix()
@@ -1944,13 +1953,13 @@ class ExecButton(MiniButton):
                     elif ts == 7:
                         xfont = self.x7font
                     elif ts == 6:
-                        xfont = self.x6font
+                        xfont = self.x7font
                     elif ts == 5:
-                        xfont = self.x5font
+                        xfont = self.x7font
 
                 
-                #self.l = self.bb.create_text(37,z*10+9,text=t,anchor="c",tag="label",fill=self.fg,font=xfont)
-                self.l = self.bb.create_text(37,z*10+9,text=t,anchor="c",tag="label",fill=self.fg)
+                self.l = self.bb.create_text(37,z*10+9,text=t,anchor="c",tag="label",fill=self.fg,font=xfont)
+                #self.l = self.bb.create_text(37,z*10+9,text=t,anchor="c",tag="label",fill=self.fg)
             else:
                 self.l = self.bb.create_text(37,z*10+9,text=t,anchor="c",tag="label",fill=self.fg)
             z+=1
@@ -2601,7 +2610,7 @@ class GUI_PATCH():
                 v=data[k]
                 #b = tk.Button(xframe,bg="grey", text=str(k)+' '+str(v),width=8)
 
-                command = _SET_PATCH(k,v,fix,data,_cb=self.draw)
+                command = _SET_PATCH(k,v,fix,data) #,_cb=highlight2(fix) ) #,_cb=self.draw)
                 b = tk.Button(xframe,bg="grey", text=str(v),width=2,command=command.attr)
                 command.set_button(b)
                 

+ 13 - 4
fix_gen.py

@@ -10,7 +10,7 @@ nr=0
 dmx=1
 def add(jdata,att):
     global nr,dmx,name,fix,sub
-    print("======", "{}_{} {:02}".format( name,fix,sub) )
+    print("======", "{}_{} {:03}".format( name,fix,sub) )
     #for i in jdata:
     #    print(i )
 
@@ -39,13 +39,16 @@ sub =1
 name="VPU"
 dmx=1
 univ=2
-for i in range(9*13): # fixtures
+#for i in range(9*13): # fixtures
+#for i in range(8+1*12+1): # fixtures
+#for i in range((8*2)+1*(12*2)+1): # fixtures
+for i in range(240): # fixtures
     print("====================================")
     rdata='{"DMX": 1, "UNIVERS": 2, "NAME": "VPU_01", "TYPE": "MOVER", "VENDOR": "AYERTON", "ATTRIBUT":{}}'
     jdata = json.loads(rdata,object_pairs_hook=OrderedDict)
 
     jdata["NAME"] = "{}_{}{:02}".format( name,fix,sub)
-    jdata["NAME"] = "{}_{}".format( name,fix)#,sub)
+    jdata["NAME"] = "{}_{:03}".format( name,fix)#,sub)
     nr=1
 
     jdata["UNIVERS"] = univ
@@ -77,6 +80,8 @@ for i in range(9*13): # fixtures
 
     add(jdata,att)
     fnr="{}{:02}".format(fix,sub)
+    fnr="{}".format(fix,sub)
+    fnr="{:04}".format(fix,sub)
     f_out.write("{}\t{}\t{}\n".format(fnr,fnr,json.dumps(jdata) ) )
     f_out.flush()   
 
@@ -86,7 +91,7 @@ for i in range(9*13): # fixtures
 
     if 0:#for i in range(3):
         sub+=1
-        jdata["NAME"] = "{}_{}{:02}".format( name,fix,sub)
+        jdata["NAME"] = "{}_{:03}{:03}".format( name,fix,sub)
 
         dmx+=nr-1
         univ=2
@@ -103,9 +108,13 @@ for i in range(9*13): # fixtures
 
         add(jdata,att)
         fnr="{}{:02}".format(fix,sub)
+        fnr="{:04}".format(fix,sub)
         f_out.write("{}\t{}\t{}\n".format(fnr,fnr,json.dumps(jdata) ) )
         f_out.flush()
     fix += 1
     sub=1
     dmx+=nr-1
+    if dmx >= 512:
+        univ +=1
+        dmx = 1
 

+ 60 - 20
vpu/vpu_live.py

@@ -34,10 +34,10 @@ def select_ip(ips, univ=2): # artnet univ
 
 
 
-r = ""
 
 def read_dmx(ip):
     global frame
+    r = ""
     if ip:
         #t = int(math.sin(time.time() - s)*10)
         r = mc.get(ip) #"2.0.0.13:2")
@@ -97,8 +97,8 @@ font15 = pygame.font.SysFont("freemonobold",15)
 #font = pygame.font.SysFont(None,30)
 fr = font.render("hallo" ,1, (200,0,255))
 
-main_size=(600,300)
-main_size=(280,200)
+main_size=(600,500)
+#main_size=(280,200)
 
 window = pygame.display.set_mode(main_size,pg.RESIZABLE)#,32)#,pygame.FULLSCREEN) #x left->right ,y top-> bottom
 pg.display.set_caption('LibreLight LED-SCREEN')
@@ -122,8 +122,8 @@ def event():
                         NR = 0
                 if "button" in event.dict and event.dict["button"] == 3:  #event.button)
                     NR -= 1
-                    if NR <= 0:
-                        NR = 0
+                    if NR < 0:
+                        NR = 2
 
         except Exception as e:
             print(e)
@@ -185,11 +185,11 @@ class Fix():
         self.rgb = [r,g,b]
         return self.rgb
      
-    def POS(self,x=0,y=0):
+    def POS(self,x=0,y=0,a=0,b=0):
         A = self.pos[0]*self.block[0]
         B = self.pos[1]*self.block[1]
-        C = self.block[0]-1
-        D = self.block[1]-1
+        C = self.block[0]-a
+        D = self.block[1]-b
         return [x+A,y+B,C,D]
 
 
@@ -198,17 +198,28 @@ def init_gird():
     #init loop
     dmx = 1-1
     ch = 4
-    block = [16,16]
-    block = [8,8]
-    _x = 12
-    _y = 8
 
-    _x = 24
-    _y = 16
+    block = [22,22]
+    _x = 6
+    _y = 3
+
+    HD = 1
+    if HD:
+        block = [8,8]
+        _x = 24
+        _y = 16
+    else:
+        block = [16,16]
+        _x = 12
+        _y = 8
+
+        _x = 24
+        _y = 16
+
 
     y=0
     x=0
-    for i in range((_y+1)*(_x+1)):
+    for i in range((_y)*(_x)):
         if i%_x == 0:
             x=0
             y+=1
@@ -225,7 +236,7 @@ def init_gird():
 
 
 NR = 0
-
+START_UNIV=2
 def main():
     global IP,GRIP
     GRID =  init_gird()
@@ -245,18 +256,30 @@ def main():
         draw_overlay()
 
         ips = read_index()
-        ip = select_ip(ips,univ=2)
+        ip = select_ip(ips,univ=START_UNIV)
         IP = ip
         #print("IP",ip)
 
         data = read_dmx(ip)
 
+        ip = select_ip(ips,univ=START_UNIV+1)
+        data3 = read_dmx(ip)
+        data.extend(data3)
+
+        #ip = select_ip(ips,univ=START_UNIV+2)
+        #data3 = read_dmx(ip)
+        #data.extend(data3)
+
+        #ip = select_ip(ips,univ=START_UNIV+4)
+        #data3 = read_dmx(ip)
+        #data.extend(data3)
         # GRID loop
         i = 0
+        dmx = 1
         for fix in GRID:
             fix.calc(data)
 
-            pos = fix.POS(40,40)
+            pos = fix.POS(40,40,-2,-2)
             rgb = fix.rgb
 
             #print(fix.dmx,rgb,pos)
@@ -265,8 +288,25 @@ def main():
                 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))
+                univ = int(dmx/512)
+                _dmx = dmx
+                if univ:
+                    _dmx = dmx%512
+                    #_dmx += 1
+
+                fr = font12.render("{:2} {}".format(univ+START_UNIV,_dmx) ,1, (200,0,255))
+                window.blit(fr,(pos[0],pos[1]+3))
+
+            if 1:
+                if fix.pos[0] == 0:
+                    fr = font12.render("{}".format(fix.pos[1]) ,1, (200,200,200))
+                    #fr = font12.render("-" ,1, (100,100,255))
+                    window.blit(fr,(10,pos[1]+3 ))
+                if fix.pos[1] == 1:
+                    fr = font12.render("{}".format(fix.pos[0]+1) ,1, (200,200,200))
+                    #fr = font12.render("-" ,1, (100,100,255))
+                    window.blit(fr,(pos[0]+2,35 ))
+            dmx += 4
             i += 1
 
         pygame.display.flip()