Browse Source

add meta.chang_grp init_ATTR ... motion("circle")

micha 1 month ago
parent
commit
f90e77a226
2 changed files with 96 additions and 21 deletions
  1. 27 7
      lib/meta.py
  2. 69 14
      tkgui/FX3.py

+ 27 - 7
lib/meta.py

@@ -1,5 +1,9 @@
 #!/usr/bin/python3
 
+def cb_dummy(options={}):
+    print("cb_dummy",options)
+    return options
+
 def ValueBuffer_create_data(val=2,_min=0,_max=255,_inc=1,cycle=[0,127,255]):
     data = {}
     data["value"] = val
@@ -12,6 +16,7 @@ def ValueBuffer_create_data(val=2,_min=0,_max=255,_inc=1,cycle=[0,127,255]):
     data["cycle_idx"] = 0
     data["format"] = "<format>{}"
     data["name"] = "<name>"
+    data["callback"] = cb_dummy
     return data
 
 def Buffer_clean(data,default={}):
@@ -22,7 +27,7 @@ def Buffer_clean(data,default={}):
     for k,v in a.items():
         #print("  ",id(data),[k,v])
         if k not in data:
-            print("ValueBuffer_clear key does not exist; adding key ",[k]," !")
+            print("   ValueBuffer_clear key does not exist; adding key ",[k]," !")
             data[k] = v
 
 def ValueBuffer_clean(data):
@@ -265,6 +270,7 @@ class OptionBuffer():# wrap function to object
     def dec(self):
         return OptionBuffer_dec(self.data)
     def val(self,val=None):
+        #self.data["callback"]({"val":val})
         return OptionBuffer_val(self.data,val=val)
     def set_init(self,val):
         return OptionBuffer_set_init(self.data,val)
@@ -277,6 +283,7 @@ class Elem_Container():
         self.elem = {}
 
 ATTR_GRP = {}
+ATTR_GRP[" "] = [" "]
 ATTR_GRP["POS"] = ["PAN","TILT"]
 ATTR_GRP["RGB"] = ["RED","GREEN","BLUE","AMBER","WHITE"]
 #ATTR_GRP["CMY"] = ["CYAN","MAGENTA","YELLOW"]
@@ -286,7 +293,7 @@ def Optionbuffer_create_ATTR_GRP(val=""):
     options = list(ATTR_GRP.keys())
     return OptionBuffer(val,options)
 
-FX_FUNC = ["SIN","COS","RAMP","RAMP2","FD","ON","STATIC"]
+FX_FUNC = ["SIN","COS","RAMP","RAMP2","FD","ON","STATIC","-","255"]
 def Optionbuffer_create_FX_FUNC(val=""):
     options = FX_FUNC
     return OptionBuffer(val,options)
@@ -303,9 +310,9 @@ def Optionbuffer_create_ATTR(attr_grp="",val=""):
     ob.reset()
     return ob
 
-fx_func_grp = Optionbuffer_create_ATTR_GRP()
-fx_func_attr = Optionbuffer_create_ATTR("POS")
-fx_func_func = Optionbuffer_create_FX_FUNC()
+#fx_func_grp = Optionbuffer_create_ATTR_GRP()
+#fx_func_attr = Optionbuffer_create_ATTR("POS")
+#fx_func_func = Optionbuffer_create_FX_FUNC()
 
 fx_prm_main = {}
 fx_prm_move = {"SIZE":40,"SPEED":8,"OFFSET":100,"BASE":"0","START":0,"MODE":0,"MO":0,"DIR":1,"INVERT":0,"SHUFFLE":0,"WING":2,"WIDTH":100}
@@ -362,11 +369,24 @@ for i,f in fx3_grid_cfg.items():
         k="{}{}".format(i,j+1)
         x.append(k)
         fx3_grid[k] = f()
+        fx3_grid[k].data["name"] = k #f()
 
     x.append("\n")
     print(":",x)
     fx3.labels.extend(x)
 
+def change_grp(name,val):
+    t,i = name.split(":",1)
+    print("--- change_grp",name,val,t,i)
+    k2 = "ATTR:"+i
+    print("change_grp:",(name,val),(t,i),k2,val)
+
+    fx3_grid[k2]  = Optionbuffer_create_ATTR(val) #,val)
+    fx3_grid[k2].data["name"] = "ATTR:"+i
+    #fx3_grid[k2].val(val) 
+    print("   ",k2,fx3_grid[k2].data) 
+
+
 #print("__ "*22)
 #fx3_grid["GRP:1"].val("RGB")
 #print([fx3_grid["GRP:1"].val()])
@@ -378,10 +398,10 @@ for i,f in fx3_grid_cfg.items():
 fx3.labels.extend([" "," "," "," "," ","\n"])
 fx3.labels.extend(["\n"])
 fx3.labels.extend([" ","START","STOP","OFF"," ","\n"])
-fx3.labels.extend(["SPEED:","SLOW","MID","FAST","TURBO","\n"])
-fx3.labels.extend(["SIZE:","MINI","SMALL","NORMAL","BIG","\n"])
 fx3.labels.extend(["  ","CIRCLE","PAN","TILT","FLAY","\n"])
 fx3.labels.extend([" ","RED","GREEN","BLUE","MAGENTA","\n"])
+fx3.labels.extend(["SIZE:","MINI","SMALL","NORMAL","BIG","\n"])
+fx3.labels.extend(["SPEED:","SLOW","MID","FAST","TURBO","\n"])
 
 fx_cfg = Elem_Container()
 fx_cfg.labels =[

+ 69 - 14
tkgui/FX3.py

@@ -105,14 +105,20 @@ def basic():
         MAIN.meta.fx3_grid[k].data["max"] = 1
 basic()
 
-def circle():
+def motion(code="circle"):
     #basic()
 
     k = "GRP:1" #.format(i+1)
     MAIN.meta.fx3_grid[k].val("POS")
+    MAIN.meta.change_grp(name=k,val="POS")
     k = "GRP:2" #.format(i+1)
     MAIN.meta.fx3_grid[k].val("POS")
+    MAIN.meta.change_grp(name=k,val="POS")
 
+    k = "GRP:3" #.format(i+1)
+    MAIN.meta.fx3_grid[k].val(" ")
+    MAIN.meta.change_grp(name=k,val=" ")
+    
     k = "ATTR:1" #.format(i+1)
     MAIN.meta.fx3_grid[k].val("PAN")
     k = "ATTR:2" #.format(i+1)
@@ -120,10 +126,21 @@ def circle():
     k = "ATTR:3" #.format(i+1)
     MAIN.meta.fx3_grid[k].val(" ")
 
-    k = "TYPE:1" 
-    MAIN.meta.fx3_grid[k].val("SIN")
-    k = "TYPE:2" 
-    MAIN.meta.fx3_grid[k].val("COS")
+    if code == "circle":
+        k = "TYPE:1" 
+        MAIN.meta.fx3_grid[k].val("SIN")
+        k = "TYPE:2" 
+        MAIN.meta.fx3_grid[k].val("COS")
+    if code == "pan":
+        k = "TYPE:1" 
+        MAIN.meta.fx3_grid[k].val("SIN")
+        k = "TYPE:2" 
+        MAIN.meta.fx3_grid[k].val("-")
+    if code == "tilt":
+        k = "TYPE:1" 
+        MAIN.meta.fx3_grid[k].val("-")
+        k = "TYPE:2" 
+        MAIN.meta.fx3_grid[k].val("COS")
 
 
 def size(val=255):
@@ -140,13 +157,16 @@ def speed(val=255):
         MAIN.meta.fx3_grid[k].val(val)
     __refresh_fx3(_filter="SPEED")
 
-def rgb():
+def rgb(code="red"):
     #basic()
     k = "GRP:1" 
+    MAIN.meta.change_grp(name=k,val="RGB")
     MAIN.meta.fx3_grid[k].val("RGB")
     k = "GRP:2" 
+    MAIN.meta.change_grp(name=k,val="RGB")
     MAIN.meta.fx3_grid[k].val("RGB")
     k = "GRP:3" 
+    MAIN.meta.change_grp(name=k,val="RGB")
     MAIN.meta.fx3_grid[k].val("RGB")
 
     k = "ATTR:1"
@@ -157,11 +177,30 @@ def rgb():
     MAIN.meta.fx3_grid[k].val("BLUE")
 
     k = "TYPE:1" 
-    MAIN.meta.fx3_grid[k].val("FD")
+    MAIN.meta.fx3_grid[k].val("255")
     k = "TYPE:2" 
-    MAIN.meta.fx3_grid[k].val("STATIC")
+    MAIN.meta.fx3_grid[k].val("255")
     k = "TYPE:3" 
-    MAIN.meta.fx3_grid[k].val("STATIC")
+    MAIN.meta.fx3_grid[k].val("255")
+    k = "TYPE:4" 
+    MAIN.meta.fx3_grid[k].val("255")
+
+    if code == "red":
+        k = "TYPE:1" 
+        MAIN.meta.fx3_grid[k].val("FD")
+    if code == "green":
+        k = "TYPE:2" 
+        MAIN.meta.fx3_grid[k].val("FD")
+    if code == "blue":
+        k = "TYPE:3" 
+        MAIN.meta.fx3_grid[k].val("FD")
+    if code == "blue":
+        k = "TYPE:3" 
+        MAIN.meta.fx3_grid[k].val("FD")
+    if code == "blue":
+        k = "TYPE:3" 
+        MAIN.meta.fx3_grid[k].val("FD")
+
     __refresh_fx3()
 
 def clear():
@@ -188,13 +227,13 @@ def clear():
     MAIN.meta.fx3_grid[k].val(" ")
 
 
-circle()
+motion("circle")
 
 def _refresh_fx3x(): #frame,c,r,gui,mode="FX"):
     time.sleep(5)
     while 1:
         print("Ö " *22)
-        circle()
+        motion("circle")
         time.sleep(3)
         rgb()
         time.sleep(3)
@@ -214,7 +253,15 @@ def __refresh_fx3(_filter=""):
         if comm in MAIN.meta.fx3_grid:
             if _filter and _filter != comm:
                 continue
-
+        
+            #MAIN.meta.fx3_grid[comm].val("X")
+            v2 = MAIN.meta.fx3_grid[comm].val()
+            v1 = b["text"]
+            #if "ATTR" in comm or "GRP" in comm:
+            #    print([comm,v1,v2,b])
+            if "ATTR" in comm:
+                pass #MAIN.meta.fx3_grid[comm].val("PAN")
+                #print(MAIN.meta.fx3_grid[comm].data)
             v2 = MAIN.meta.fx3_grid[comm].val()
             v1 = b["text"]
             if "ATTR" in comm or "GRP" in comm:
@@ -258,9 +305,17 @@ def _draw_fx3(frame,c,r,gui,mode="FX"):
                 print("xXx "*22)
                 print("XXX",event,data)
                 if xcomm == "CIRCLE":
-                    circle()
+                    motion("circle")
+                elif xcomm == "PAN":
+                    motion("pan")
+                elif xcomm == "TILT":
+                    motion("tilt")
                 elif xcomm == "RED":
-                    rgb()
+                    rgb("red")
+                elif xcomm == "GREEN":
+                    rgb("green")
+                elif xcomm == "BLUE":
+                    rgb("blue")
                 elif xcomm == "MINI":
                     size(10)
                 elif xcomm == "SMALL":