浏览代码

cleanup FX3 offset calculation

micha 2 天之前
父节点
当前提交
cb174f003a
共有 2 个文件被更改,包括 53 次插入17 次删除
  1. 1 0
      _LibreLightDesk.py
  2. 52 17
      tkgui/FX3.py

+ 1 - 0
_LibreLightDesk.py

@@ -398,6 +398,7 @@ class MC_PATCH():
                     val = json.dumps(val).encode() 
                     self.mc.set("PATCH-"+str(fix),val)
                     index_patch.append(fix)
+
                 val = json.dumps(index_patch).encode() 
                 self.mc.set("PATCH-INDEX",val)
             except Exception as e:

+ 52 - 17
tkgui/FX3.py

@@ -152,7 +152,6 @@ def update_dmx_adresses(grid_data2):
     patch = get_patch() 
     patch = patch_order_by_fix(patch)
     out=[]
-    offset = 0
     for i in grid_data2:
         ID = i["FIX"]
         attr = i["ATTR"]
@@ -171,30 +170,53 @@ def update_dmx_adresses(grid_data2):
         #cprint("333-- FX3:",i,color="yellow")
     return grid_data2
 
-def calculate_offset():
-    pass
+def extract_fixture_list(grid_data3):
+    print()
+    out = {}
+    for k,v in enumerate(grid_data3):
+        print("calc_off",k,v)
+        if v["FIX"] not in out:
+            out[v["FIX"]] = 0
+        else:
+            out[v["FIX"]] += 1
+    return out
+
+def calculate_offset(grid_data3):
+    fix = extract_fixture_list(grid_data3)
+    offset = {}
+    offset_len = len(fix)-1
+
+    print()
+    for i,f in enumerate(fix):
+
+        for k,v in enumerate(grid_data3):
+            if f != v["FIX"]:
+                continue
+
+            _offset = v["FX2"]["OFFSET"]
+            attr = v["ATTR"]
+            if attr not in offset:
+                offset[attr] = 0
+                offset[attr] +=  _offset/offset_len
+
+            nof = round( offset[attr]*i,2 ) # ID
+            v["FX2"]["OFFSET"] = nof
+            print("x_offset: ",k,v["FIX"],v["ATTR"],offset,nof)
 
 def merge_grid_and_programmer(programmer,grid_data2):
     out=[]
-    offset = {}
-    offset_len = len(programmer)
 
     for k,v in enumerate(programmer):
         attr = v["ATTR"]
         ID = v["ID"]
-        if attr not in offset:
-            offset[attr] = 0
         print("v",v)
-        _offset = 0
         if attr in grid_data2:
             tmp = copy.deepcopy(grid_data2[attr])
-            print(" ",tmp,_offset,offset_len)
+            print(" ",tmp)
             _offset = tmp["FX2"]["OFFSET"]
             tmp["ATTR"] = attr
             tmp["FIX"] = ID
-            tmp["FX2"]["OFFSET"] = round( offset[attr],2 ) # ID
             out.append(tmp)
-            offset[attr] +=  _offset/offset_len
     return out
 
 def log(x,name="log",color="yellow"):
@@ -238,6 +260,8 @@ class tk_event_fx():
             grid_data3 = merge_grid_and_programmer(programmer,grid_data2)
             log(grid_data3,name="B:")
 
+            calculate_offset(grid_data3)
+
             out = update_dmx_adresses(grid_data3)
             log(out,name="C:")
 
@@ -602,21 +626,21 @@ def _draw_fx3(frame,c,r,gui,mode="FX"):
                 elif xcomm == "BLUE":
                     rgb("blue")
                 elif xcomm == "MINI":
-                    size(10)
-                elif xcomm == "SMALL":
                     size(25)
-                elif xcomm == "NORMAL":
+                elif xcomm == "SMALL":
                     size(50)
-                elif xcomm == "BIG":
+                elif xcomm == "NORMAL":
                     size(100)
+                elif xcomm == "BIG":
+                    size(255)
                 elif xcomm == "SLOW":
                     speed(5)
                 elif xcomm == "MID":
                     speed(25)
                 elif xcomm == "FAST":
-                    speed(100)
+                    speed(80)
                 elif xcomm == "TURBO":
-                    speed(200)
+                    speed(160)
 
                 xcb(event) #,data)
             return XXX
@@ -636,6 +660,17 @@ def _draw_fx3(frame,c,r,gui,mode="FX"):
             b["text"] = comm
             b["bg"] = "#ffbf00"
 
+        if comm in ["SHUFFLE:","WING:","BASE:","START:","STOP","OFF"]:  # not implemented !
+            b["fg"] = "#aaa"
+            b.config(activebackground="#aaa")
+            #b.config(activebackground="#bbb")
+
+        if comm in ["SIZE:","WIDTH:","DIR:","WING:","ATTR:","TYPE:","SPEED:","OFFSET:"]: # OK
+            b["bg"] = "#bbb"
+            b.config(activebackground="#bbb")
+            b.config(activeforeground="#bbb")
+                    #activeForeground
+
         if comm == "START": 
             b["bg"] = "orange"
             b.config(activebackground="#dd0")