Browse Source

Initial commit

with files copied from EOS OSC module
eLandon 4 years ago
commit
0eea87d361
2 changed files with 441 additions and 0 deletions
  1. 108 0
      BT_OSCcontroller.js
  2. 333 0
      module.json

+ 108 - 0
BT_OSCcontroller.js

@@ -0,0 +1,108 @@
+function sendCommand(command)
+{
+	local.send("/eos/cmd", command+"#");
+}
+
+function getCommandTarget(target, id, startID, endID)
+{
+	var globalStart = local.parameters.startChannel.get();
+	if(target == "one") return "Chan "+(globalStart+id);
+	if(target == "range") return "Chan "+(globalStart+startID)+" Thru "+(globalStart+endID);
+	if(target == "all") return "Group "+globalStart;
+}
+
+function getColorMessage(color, showRest)
+{
+	var r = parseInt(color[0]*100);
+	var g = parseInt(color[1]*100);
+	var b = parseInt(color[2]*100);
+	if(r < 10) r = "0"+r;
+	if(g < 10) g = "0"+g;
+	if(b < 10) b = "0"+b;
+
+	return "Red @ "+r+" Green @ "+g+" Blue @ "+b+(showRest?" Cyan @ 0 Amber @ 0 Indigo @ 0 White @ 0":"");
+}
+
+function valueCallback(target, id, startID, endID, value)
+{
+	var v = parseInt(value*100);
+	if(v < 10) v = "0"+v;
+	var cmd = getCommandTarget(target, id, startID, endID)+" @ "+v;
+	sendCommand(cmd);
+}
+
+function colorCallback(target, id, startID, endID, color)
+{
+	var cmd = getCommandTarget(target, id, startID, endID);
+	var colCmd  = getColorMessage(color);
+	sendCommand(cmd+" "+colCmd);
+}
+
+function blackOutCallback(target, propID, startID, endID)
+{
+	var cmd = getCommandTarget(target, id, startID, endID);
+	var colCmd  = getColorMessage(color, true);
+	sendCommand(cmd+" "+colCmd);
+
+	cmd = getCommandTarget(target, id, startID, endID)+" @ 0";
+	sendCommand(cmd);
+}
+
+//Advanced functions
+function gradientCallback(startID, endID, color1, color2)
+{
+	if(startID == endID) 
+	{
+		colorCallback("one",startID,0,0,color1);
+		return;
+	}
+	var r1 = color1[0];
+	var g1 = color1[1];
+	var b1 = color1[2];
+
+	var r2 = color2[0];
+	var g2 = color2[1];
+	var b2 = color2[2];
+
+	var minID = Math.min(startID, endID);
+	var maxID = Math.max(startID, endID);
+
+	for(var i=minID;i<=maxID;i++)
+	{
+		var p = (i-minID)*1.0/(maxID-minID);
+
+		var r = (r1+(r2-r1)*p);
+		var g = (g1+(g2-g1)*p);
+		var b = (b1+(b2-b1)*p);
+
+		var cmd = getCommandTarget("one",i);
+		var colorCmd = getColorMessage([r,g,b]);
+
+		sendCommand(cmd+" "+colorCmd);
+	} 
+}
+
+function pointCallback(startID, endID, position, size, fade, color)
+{
+	var r = color[0];
+	var g = color[1];
+	var b = color[2];
+
+	for(var i=startID;i<=endID;i++)
+	{
+		var p = (i-startID)*1.0/(endID-startID);
+
+		var cmd = getCommandTarget("one",i);
+		var colorCmd;
+		if(Math.abs(position-p) < size) 
+		{
+			var fac = Math.min(Math.max(1-Math.abs((p-position)*fade*3/size),0),1);
+			colorCmd = getColorMessage([r*fac, g*fac, b*fac]);
+		}else
+		{
+			colorCmd = getColorMessage([0,0,0]);
+		}
+
+		sendCommand(cmd+" "+colorCmd);
+	}
+}

+ 333 - 0
module.json

@@ -0,0 +1,333 @@
+{
+	"name":"EOS OSC",
+	"type":"OSC",
+	"path":"Software",
+	
+	"version":"1.0.0",
+	"description":"Mike's special module to control EOS Light Console through OSC via commands",
+	"url":"https://github.com/benkuper/EOS-OSC-Chataigne-Module",
+	"downloadURL":"https://github.com/benkuper/EOS-OSC-Chataigne-Module/archive/master.zip",
+
+	"hasInput":true,
+	"hasOutput":true, 
+
+	"hideDefaultCommands":false,
+	
+	"defaults":
+	{		
+		"baudRate":115200,
+		"autoAdd":false,
+		"OSC Input":
+		{
+			"localPort":9001
+		},
+		"OSC Output":
+		{
+			"remotePort":9000
+		}
+	},
+
+	"parameters":
+	{
+		"Start Channel":
+		{
+			"type":"Integer"
+		}
+	},
+
+
+	"hideDefaultParameters":
+	[
+		"autoAdd",
+		"splitArguments",
+		"autoRange",
+		"autoFeedback"
+	],
+
+
+	"scripts":
+	[
+		"EOSOSC.js"
+	],
+
+	"values":
+	{
+	},
+
+	"commands":
+	{
+		
+		"Set Value":
+		{
+			"menu":"",
+			"callback":"valueCallback",
+			"parameters":
+			{
+				"Target":
+				{
+					"type":"Enum",
+					"options":
+					{
+						"All":"all",
+						"One":"one",
+						"Range":"range"
+					}
+				},
+
+				"ID":
+				{
+					"type":"Integer",
+					"dependency": 
+					{
+						"source":"target",
+						"value":"one",
+						"check":"equals",
+						"action":"show"
+					}
+				},
+
+				"Start ID":
+				{
+					"type":"Integer",
+					"dependency": 
+					{
+						"source":"target",
+						"value":"range",
+						"check":"equals",
+						"action":"show"
+					}
+				},
+				
+				"End ID":
+				{
+					"type":"Integer",
+					"default":1,
+					"dependency": 
+					{
+						"source":"target",
+						"value":"range",
+						"check":"equals",
+						"action":"show"
+					}
+				},
+
+				"Value":
+				{
+					"type":"Float",
+					"min":0,
+					"max":1,
+					"default":0
+				}
+				
+			}
+		},
+
+		"Set Color":
+		{
+			"menu":"",
+			"callback":"colorCallback",
+			"parameters":
+			{
+				"Target":
+				{
+					"type":"Enum",
+					"options":
+					{
+						"All":"all",
+						"One":"one",
+						"Range":"range"
+					}
+				},
+
+				"ID":
+				{
+					"type":"Integer",
+					"dependency": 
+					{
+						"source":"target",
+						"value":"one",
+						"check":"equals",
+						"action":"show"
+					}
+				},
+
+				"Start ID":
+				{
+					"type":"Integer",
+					"dependency": 
+					{
+						"source":"target",
+						"value":"range",
+						"check":"equals",
+						"action":"show"
+					}
+				},
+				
+				"End ID":
+				{
+					"type":"Integer",
+					"default":1,
+					"dependency": 
+					{
+						"source":"target",
+						"value":"range",
+						"check":"equals",
+						"action":"show"
+					}
+				},
+
+				"Color":
+				{
+					"type":"Color",
+					"default":[1,0,0,1]
+				}
+				
+			}
+		},
+
+		"Black Out":
+		{
+			"menu":"",
+			"callback":"blackOutCallback",
+			"parameters":
+			{
+				"Target":
+				{
+					"type":"Enum",
+					"options":
+					{
+						"All":"all",
+						"One":"one",
+						"Range":"range"
+					}
+				},
+
+				"ID":
+				{
+					"type":"Integer",
+					"dependency": 
+					{
+						"source":"target",
+						"value":"one",
+						"check":"equals",
+						"action":"show"
+					}
+				},
+
+				"Start ID":
+				{
+					"type":"Integer",
+					"dependency": 
+					{
+						"source":"target",
+						"value":"range",
+						"check":"equals",
+						"action":"show"
+					}
+				},
+				
+				"End ID":
+				{
+					"type":"Integer",
+					"default":1,
+					"dependency": 
+					{
+						"source":"target",
+						"value":"range",
+						"check":"equals",
+						"action":"show"
+					}
+				}
+			}
+		},
+
+		"Gradient":
+		{
+			"menu":"Advanced",
+			"callback":"gradientCallback",
+			"parameters":
+			{
+				"Start ID":
+				{
+					"type":"Integer",
+					"min":0,
+					"max":15
+				},
+				
+				"End ID":
+				{
+					"type":"Integer",
+					"default":1,
+					"min":0,
+					"max":15
+				},
+
+				"Start Color":
+				{
+					"type":"Color",
+					"default":[1,0,0,1]
+				},
+
+				"End Color":
+				{
+					"type":"Color",
+					"default":[0,0,1,1]
+				}
+				
+			}
+		},
+
+		"Point":
+		{
+			"menu":"Advanced",
+			"callback":"pointCallback",
+			"parameters":
+			{
+				"Start ID":
+				{
+					"type":"Integer",
+					"min":0,
+					"max":15
+				},
+				
+				"End ID":
+				{
+					"type":"Integer",
+					"default":1,
+					"min":0,
+					"max":15
+				},
+
+				"Position":
+				{
+					"type":"Float",
+					"default":0.5,
+					"min":0,
+					"max":1,
+				},
+
+				"Size":
+				{
+					"type":"Float",
+					"default":0.1,
+					"min":0,
+					"max":1
+				},
+
+				"Fade":
+				{
+					"type":"Float",
+					"default":0.5,
+					"min":0,
+					"max":1
+				},
+
+				"Color":
+				{
+					"type":"Color",
+					"default":[1,1,1,1]
+				}
+			}
+		}
+	}
+}