Procházet zdrojové kódy

extend DELAY and ALIGN <> >< > <

micha před 6 dny
rodič
revize
af6cdbd962
5 změnil soubory, kde provedl 146 přidání a 28 odebrání
  1. 42 0
      _LibreLightDesk.py
  2. 1 1
      lib/execlib.py
  3. 59 2
      lib/meta.py
  4. 43 24
      lib/tkevent.py
  5. 1 1
      tksdl/fix.py

+ 42 - 0
_LibreLightDesk.py

@@ -1511,6 +1511,48 @@ class MASTER():
         #vcmd = reshape_exec( rdata ,value,[],xfade=xfade,fx=1) 
         #cprint(rdata,color="red")
         vcmd = execlib.reshape_exec( rdata ,value,xfade=xfade,ptfade=ptfade,DELAY=xdelay) 
+        #for row in data:
+        #    #cprint("reshape_exec in:",row)
+        #    line = {}
+        #    line["DELAY"]=delay
+        for i in vcmd:
+            i["DELAY"] = round(0,3)
+        
+        # ALIGN-DELAY
+        _xd = 0
+        if type(xdelay) in [int,float]:
+            _align = meta.ALIGN.val()
+            _len = len(vcmd)
+            _len_h = int(len(vcmd)/2)
+            if _align == ">":
+                for i in vcmd:
+                    i["DELAY"] = round(_xd,3)
+                    _xd += xdelay
+            elif _align == "<":
+                for i in vcmd[::-1]:
+                    i["DELAY"] = round(_xd,3)
+                    _xd += xdelay
+            elif _align == "><":
+                xdelay *= 2 
+                for i in vcmd[:_len_h]:
+                    i["DELAY"] = round(_xd,3)
+                    _xd += xdelay
+                _xd = 0
+                for i in vcmd[:_len_h-1:-1]:
+                    i["DELAY"] = round(_xd,3)
+                    _xd += xdelay
+            elif _align == "<>":
+                xdelay *= 2 
+                for i in vcmd[:_len_h-1][::-1]:
+                    i["DELAY"] = round(_xd,3)
+                    _xd += xdelay
+                _xd = 0
+                for i in vcmd[:_len_h:-1][::-1]:
+                    i["DELAY"] = round(_xd,3)
+                    _xd += xdelay
+
+        for i in vcmd:
+            print("1-->",i)
 
         cmd = []
         for i,_ in enumerate(fcmd):

+ 1 - 1
lib/execlib.py

@@ -26,7 +26,7 @@ def reshape_exec(data ,value=None,xfade=0,flash=0,ptfade=0,DELAY=None):
     for row in data:
         #cprint("reshape_exec in:",row)
         line = {}
-        line["DELAY"]=delay
+        line["DELAY"]=round(delay,3)
         if type(value) is float:
             line["VALUE"] = value #round(value,3)
         else:

+ 59 - 2
lib/meta.py

@@ -44,6 +44,25 @@ def ValueBuffer_check(data):
         data["value"] = data["max"]
         print("MAX !")
 
+def TextBuffer_cycle(data,_dir=1):
+    #ValueBuffer_clean(data)
+    _max = len(data["cycle"])-1
+    idx=data["cycle_idx"]
+    if _dir > 0:
+        idx += 1
+    else:
+        idx -= 1
+
+    if idx > _max:
+        idx = _max
+    if idx < 0:
+        idx=0
+
+    print( len(data["cycle"]),idx)
+    data["cycle_idx"]=idx
+    data["value"] = data["cycle"][idx]
+    return data["value"]
+
 def ValueBuffer_cycle(data): # middel mouse click
     ValueBuffer_clean(data)
     _len = len(data["cycle"])
@@ -138,6 +157,37 @@ def ValueBuffer_format(data):
         raise e
 
 
+# warp function to object
+class TextCycleBuffer():
+    def __init__(self,cycle=["a","b","c"]):
+        self.data = ValueBuffer_create_data(val=cycle[0],cycle=cycle)
+    def cycle(self,_dir=1): # middel mouse click
+        print(self.data)
+        return TextBuffer_cycle(self.data,_dir=_dir)
+    def check(self):
+        pass
+    def dec(self,value=None): #Mouse Wheel down
+        pass 
+    def inc(self,value=None): #Mouse Wheel up
+        pass
+    def val(self,value=None): # get or set value
+        return self.data["value"]
+    def reset(self): # right click
+        self.data["cycle_idx"] = 0
+        self.data["value"] = self.data["cycle"][0] 
+    def on(self): # left click
+        return ValueBuffer_on(self.data)
+    def off(self): # left click
+        return ValueBuffer_off(self.data)
+    def toggle(self):
+        return ValueBuffer_toggle(self.data)
+    def invert(self):
+        return 0 
+    def _is(self):
+        return ValueBuffer_is(self.data)
+    def format(self):
+        return ValueBuffer_format(self.data)
+
 # warp function to object
 class ValueBuffer():
     def __init__(self,val=2,_min=0,_max=255,_inc=1,cycle=[0,127,255]):
@@ -172,7 +222,8 @@ def create_default_FadeBuffer():
     return ValueBuffer(val=2,_min=0,_max=20,_inc=0.1)  
 
 def create_default_DelayBuffer():
-    return ValueBuffer(val=0.04,_min=-1,_max=1,_inc=0.01,cycle=[0.1,0.2,0.3,0.4,0.5])  
+    #return ValueBuffer(val=0.04,_min=-1,_max=1,_inc=0.01,cycle=[0.1,0.2,0.3,0.4,0.5])  
+    return ValueBuffer(val=0.1,_min=0,_max=3,_inc=0.05,cycle=[0.1,0.2,0.3,0.4,0.5])  
 
 
 FADE = create_default_FadeBuffer() 
@@ -184,6 +235,12 @@ DELAY.data["name"]   = "DELAY"
 DELAY.data["format"] = "DELAY:\n{val:0.2f}"
 DELAY.off()
 
+#class TextCycleBuffer():
+ALIGN = TextCycleBuffer(cycle=["<>","><",">","<"])
+ALIGN.data["name"]   = "ALIGN"
+ALIGN.data["format"] = "ALIGN:\n{val:}"
+ALIGN.on()
+
 FADE_move = create_default_FadeBuffer() 
 FADE_move.data["name"]   = "FADE_move"
 FADE_move.data["format"] = "PAN/TILT\nFADE:{val:0.2f}"
@@ -320,7 +377,7 @@ fx_prm_move = {"SIZE":40,"SPEED":8,"OFFSET":100,"BASE":"0","START":0,"MODE":0,"M
 
 live_prm = Elem_Container()
 live_prm.labels = ["FADE","DELAY","PAN/TILT\nFADE","PAN/TILT\nDELAY","-","-"]
-live_prm.labels = ["FADE","DELAY","PAN/TILT\nFADE","-","-","-"]
+live_prm.labels = ["FADE","-","PAN/TILT\nFADE","-","DELAY","ALIGN"]
 
 #fx_color = {"A":"red","B":"blue"} 
 fx_prm = {"SIZE":255,"SPEED":10,"OFFSET":100,"BASE":"-","START":0,"MODE":0,"MO":0,"DIR":1,"INVERT":1,"SHUFFLE":0,"WING":2,"WIDTH":25,"2D-X":1,"2D:MODE":0}

+ 43 - 24
lib/tkevent.py

@@ -155,7 +155,32 @@ class tk_event():
         if self.mode != "LIVE":
             return 0
                 
-        if "FADE" in self.attr or "DELAY" in self.attr:
+        if "ALIGN" in self.attr:
+            ct =None
+            if self.attr == "ALIGN":
+                ct = MAIN.meta.ALIGN
+
+            value = ct.val()
+            cprint("EVENT CHANGE:",[self.mode,value,self.attr])
+            if ct is None:
+                cprint("err live",[self.attr],color="red")
+                cprint(" ",ct,color="red")
+                return
+            value = ct.val()
+            cprint("EVENT CHANGE:",[self.mode,value,self.attr])
+    
+            if event.num == 1:
+                v = ct.toggle()
+            elif event.num == 2:
+                ct.invert()
+            elif event.num == 3:
+                ct.reset()
+            elif event.num == 4:
+                ct.cycle(_dir=1) 
+            elif event.num == 5:
+                ct.cycle(_dir=-1)
+
+        elif "FADE" in self.attr or "DELAY" in self.attr:
             ct =None
             if self.attr == "FADE":
                 ct = MAIN.meta.FADE
@@ -165,6 +190,7 @@ class tk_event():
                 ct = MAIN.meta.FADE_move
             elif "PAN/TILT\nDELAY" in self.attr:
                 ct = MAIN.meta.FADE_move_delay
+
             if ct is None:
                 cprint("err live",[self.attr],color="red")
                 cprint(" ",ct,color="red")
@@ -172,21 +198,8 @@ class tk_event():
             value = ct.val()
             cprint("EVENT CHANGE:",[self.mode,value,self.attr])
     
-            b = None        
-            if MAIN.meta.live_prm.elem[self.attr]:
-                b = MAIN.meta.live_prm.elem[self.attr]
-            if b is None:
-                cprint("err LIVE live_prm has no elem:",self.attr,color="red")
-                return 0
-
             if event.num == 1:
                 v = ct.toggle()
-                if v:
-                    b["bg"] = "grey"
-                    b.config(activebackground="grey")
-                else:
-                    b["bg"] = "green"
-                    b.config(activebackground="lightgreen")
             elif event.num == 2:
                 ct.invert()
             elif event.num == 3:
@@ -196,18 +209,24 @@ class tk_event():
             elif event.num == 5:
                 ct.dec()
 
-            value = ct.val()
+        # GUI ELM UPDATE
+        b = None        
+        if self.attr in MAIN.meta.live_prm.elem: 
+            if MAIN.meta.live_prm.elem[self.attr]:
+                b = MAIN.meta.live_prm.elem[self.attr]
+        if b is None:
+            cprint("err LIVE live_prm has no elem:",self.attr,color="red")
+            return 0
 
 
-            b["text"] = ct.format()
-            #if self.attr == "FADE":
-            #    b["text"] = "FADE:\n{:0.2f}".format(value)
-            #elif self.attr == "DELAY":
-            #    b["text"] = "DELAY:\n{:0.2f}".format(value)
-            #elif "PAN/TILT\nFADE" in self.attr:
-            #    b["text"] = "PAN/TILT\nFADE:{:0.2f}".format(value)
-            #elif "PAN/TILT\nDELAY" in self.attr:
-            #    b["text"] = "PAN/TILT\nD:{:0.2f}".format(value)
+        if ct._is():
+            b["bg"] = "green"
+            b.config(activebackground="lightgreen")
+        else:
+            b["bg"] = "grey"
+            b.config(activebackground="grey")
+
+        b["text"] = ct.format()
 
 
 

+ 1 - 1
tksdl/fix.py

@@ -1069,7 +1069,7 @@ while 1:
 
         scroll_bar.draw()
 
-        clock.tick(6)
+        clock.tick(4)#6)
 
     except Exception as e:
         err.append([int((time.time()-boot)*100),e])