Skip to content

Commit

Permalink
Merge pull request #1 from margau/switch_dmxnet
Browse files Browse the repository at this point in the history
Switch dmxnet
  • Loading branch information
margau authored Aug 25, 2018
2 parents 0bf77c0 + 7839b5f commit 1bcfcff
Show file tree
Hide file tree
Showing 3 changed files with 1,626 additions and 20 deletions.
25 changes: 14 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

var prefix= "o2a";
var prefix= "o2a";
// OSC: /o2a/(universe)/(channel) value
/*
Universe in decimal!
Expand All @@ -10,12 +10,12 @@ Universe: last 4 bits
Example: Subnet 1 (0x1) DMX-Universe 0 (0x0) = 0x10 = 0d16 = Dezimal 16
*/
//Set up Artnet
var art_options = {
}
var artnet = require('artnet')(art_options);
//Load dmxnet as libary
var dmxlib=require("dmxnet");
//Create new dmxnet instance
var dmxnet = new dmxlib.dmxnet({});
//Create senders array for universes
var senders=[];
// Create an osc.js UDP Port listening
var osc = require("osc");
var udpPort = new osc.UDPPort({
Expand All @@ -35,18 +35,21 @@ udpPort.on("message", function (oscMsg) {
//Check for valid Universe
if ((typeof uri_parts[2] !== 'undefined')&&(parseInt(uri_parts[2])>=0 && parseInt(uri_parts[2])<256)) {
var universe=parseInt(uri_parts[2]);
if(senders[universe]===undefined) {
console.log("Create new Sender Object for universe "+universe);
//Create new Sender instance
senders[universe]=dmxnet.newSender({ip:"255.255.255.255",subuni:universe,net:0});
}
//Check for valid Channel
if ((typeof uri_parts[3] !== 'undefined')&&(parseInt(uri_parts[3])>=0 && parseInt(uri_parts[3])<512)) {
var channel=parseInt(uri_parts[3]);
//Check for valid Value
if ((typeof oscMsg.args[0].value !== 'undefined')&&(!isNaN(oscMsg.args[0].value))) {
var value=parseInt(oscMsg.args[0].value);
if(value>=0&&value<256) {
console.log("SendArtnet: U"+universe+" Ch."+channel+" Val."+value);
console.log("SendArtnet: Universe "+universe+" Ch."+channel+" Val."+value);
//Send ArtNet
artnet.set(universe, channel, value, function (err, res) {

});
senders[universe].setChannel(channel, value);
}
}
}
Expand Down
Loading

0 comments on commit 1bcfcff

Please sign in to comment.