Procházet zdrojové kódy

add: FX SPEED-MASTER and SIZE-MASTER default master is 1

micha před 2 roky
rodič
revize
ad6cc17c64
2 změnil soubory, kde provedl 60 přidání a 27 odebrání
  1. 21 11
      _LibreLightDesk.py
  2. 39 16
      _console.py

+ 21 - 11
_LibreLightDesk.py

@@ -3814,7 +3814,7 @@ class ELEM_FADER():
         j=0
         font8 = ("FreeSans",8)
         frameS=self.frame
-        self.b = tk.Scale(frameS,bg="lightblue", width=11,from_=from_,to=to,command=self.event)
+        self.b = tk.Scale(frameS,bg="lightblue", width=18,from_=from_,to=to,command=self.event)
         self.b.pack(fill=tk.Y, side=tk.TOP)
         if init is not None:
             self.b.set(init)
@@ -3886,10 +3886,10 @@ class GUI_MasterWingLayout():
                 frameS = tk.Frame(self.frame,bg="#000",width=width,border=2)
                 frameS.pack(fill=tk.BOTH, side=tk.TOP)
                 p=j//pb+1
-                if p == 1:
-                    txt="SPEED-MASTER:{} {}-{}".format(p,p*pb-pb+1,p*pb) 
+                if j < 12:
+                    txt="x-MASTER:{} {}-{}".format(p,p*pb-pb+1,p*pb) 
                 else:
-                    txt="SIZE-MASTER:{} {}-{}".format(p,p*pb-pb+1,p*pb) 
+                    txt="x-MASTER:{} {}-{}".format(p,p*pb-pb+1,p*pb) 
                 self.b = tk.Label(frameS,bg="lightblue",text=txt,width=25,font=font8 )
                 self.header.append(self.b)
 
@@ -3901,22 +3901,31 @@ class GUI_MasterWingLayout():
                 c=0
             #print(frameS)
             e= ELEM_FADER(frameS,nr=j+1,cb=self.event_cb)
-            e.pack(from_=200,to=0,init=100)
+            if j >= 12:
+                e.pack(from_=400,to=0,init=100)
+            else:
+                e.pack(from_=200,to=0,init=100)
             self.elem.append(e)
             frameS.pack(fill=tk.X, side=tk.TOP)
             c+=1
             i+=1
         self.frame.pack()
         self._event_redraw()
+
     def event_cb(self,a1="",a2="",nr=None,**args):
         print("event_cb:",nr,a1,a2,args)
         nr += 1
         jdata= {"CMD":"SPEED-MASTER","NR":nr,"VALUE":int(a1)}
-        if nr > 12:
-            jdata["CMD"] = "SIZE-MASTER" 
-            jdata["NR"] = nr-12 
+        if nr <= 12:
+            jdata["CMD"] = "SIZE-MASTER"
+            jdata["NR"] = nr
+        else:
+            jdata["NR"] = nr-12
+
+        print("event_cb",jdata)
         j = [jdata]
         jclient_send(j)
+
     def set_name(self,_event=None):
         txt = self.name["text"]
         txt = tkinter.simpledialog.askstring("FIXTURE NAME:","NAME:",initialvalue=txt)
@@ -3939,9 +3948,9 @@ class GUI_MasterWingLayout():
             p=j+1
             #p=nr/pb
             if p == 1:
-                txt="SPEED-MASTER:{} {}-{}".format(p,p*pb-pb+1,p*pb) 
-            else:
                 txt="SIZE-MASTER:{} {}-{}".format(p,p*pb-pb+1,p*pb) 
+            else:
+                txt="SPEED-MASTER:{} {}-{}".format(p,p*pb-pb+1,p*pb) 
             #txt="BANK:{} {}-{}".format(p,p*pb-pb+nr,p*pb+nr) 
             print("---",j,txt,e)
             e["text"] = txt
@@ -4553,7 +4562,8 @@ if __run_main:
     window_manager.new(w,name)
 
     name="MASTER-WING"
-    w = GUIWindow(name,master=0,width=730,height=205,left=L1-80,top=TOP+H1-200)
+    #w = GUIWindow(name,master=0,width=730,height=205,left=L1-80,top=TOP+H1-200)
+    w = GUIWindow(name,master=0,width=90,height=405,left=0,top=TOP+H1-220)
     w1 = ScrollFrame(w.tk,width=W1,height=H1)
     data=[]
     for i in range(12*2):

+ 39 - 16
_console.py

@@ -255,24 +255,34 @@ class Fade():
         pass
 
 class _MASTER():
-    def __init__(self):
+    def __init__(self,name="None"):
         self.__data = {}
+        self.name = name
     def val(self,name,value=None):
-        value = 100 #% 
-        if name in self.__data:
-            if value is not None:
-                self.__data[name] = value
-            else:
-                value = self.__data[name] 
-        return value 
+        _value = 100 #% 
+        name = str(name)
+
+        if name not in self.__data:
+            self.__data[name] = 100
+
+
+        _value = self.__data[name] 
+        if value is not None:
+            if _value != value:
+                print(self.name,"CHANGE MASTER",name,_value)
+            self.__data[name] = value
+
+        _value = self.__data[name] 
+
+        return _value /100.
         
 class SPEED_MASTER(_MASTER):
     def __init__(self):
-        super().__init__()
+        super().__init__("SPEED")
 
 class SIZE_MASTER(_MASTER):
     def __init__(self):
-        super().__init__()
+        super().__init__("SIZE")
 
 
 size_master  = SIZE_MASTER()
@@ -346,7 +356,6 @@ class MASTER_FX():
             #print( count)
             self.count=count
             
-
         idx = self.__data.index(child) 
         offset = self.offsets[idx]
 
@@ -354,10 +363,11 @@ class MASTER_FX():
         
 
 class FX():
-    def __init__(self,xtype="sinus",size=10,speed=10,invert=0,width=100,start=0,offset=0,base="",clock=0,master=None):
+    def __init__(self,xtype="sinus",size=10,speed=10,invert=0,width=100,start=0,offset=0,base="",clock=0,master=None,master_id=1):
         self.__xtype=xtype
         self.__size  = size
         self.__start = start
+        self.__master_id = master_id
         if width > 200:
             width = 200
         if width <= 0:
@@ -370,6 +380,8 @@ class FX():
         self.__offset = offset
         self.__clock = clock
         self.__clock_curr = clock
+        self.__clock_delta = 0
+        self.__clock_old = self.__clock_curr
         self.out = 0
         self.old_v = -1
         self.run = 1
@@ -400,9 +412,19 @@ class FX():
     def next(self,clock=None):
         if type(clock) is float or type(clock) is int:#not None:
             self.__clock_curr = clock
-        t = self.__clock_curr  * self.__speed / 60
+        
+        self.__clock_delta += (self.__clock_curr - self.__clock_old) * ( speed_master.val(self.__master_id)-1)
+        #print(self.__clock_delta )
+        self.__clock_old = self.__clock_curr
+
+        
+        t = self.__clock_curr
+        t += self.__clock_delta
+        t *= self.__speed / 60 
         t += self.__offset / 100 #255 #1024 #255
         t += self.__start  / 1024 #255
+        #t = t*speed_master.val(self.__master_id)
+
         tw = t%1
         count = t//1
         t = t * (100/self.__width)
@@ -534,7 +556,8 @@ class FX():
         out = v *size +base 
         self.out = out
         self.count = count
-        return out #* (self.__fade_in_master /255.)
+        return out * size_master.val(self.__master_id)  #* (self.__fade_in_master /255.)
+        #= master_id
 
 class DMXCH(object):
     def __init__(self):
@@ -683,9 +706,9 @@ def JCB(data): #json client input
                 if "CMD" in x:
                     print("CMD:",x)
                     if "SPEED-MASTER" == x["CMD"]:
-                        speed_master.val("SPEED-{}".format(x["NR"]),x["VALUE"])
+                        speed_master.val(x["NR"],x["VALUE"])
                     if "SIZE-MASTER" == x["CMD"]:
-                        size_master.val("SIZE-{}".format(x["NR"]),x["VALUE"])
+                        size_master.val(x["NR"],x["VALUE"])
                 else:
                     if "DMX" in x:
                         DMX = int(x["DMX"])