Change DMX addressing to start at channel 1
This wastes one byte on each universe buffer and will require you to update your configs and animations but hopefully prevent confusion and off-by-one errors in the future.
This commit is contained in:
parent
e133a52dec
commit
00d960e441
9 changed files with 53 additions and 49 deletions
4
demo.js
4
demo.js
|
@ -9,8 +9,8 @@ var dmx = new DMX()
|
||||||
// var universe = dmx.addUniverse('demo', 'enttec-open-usb-dmx', '/dev/cu.usbserial-6AVNHXS8')
|
// var universe = dmx.addUniverse('demo', 'enttec-open-usb-dmx', '/dev/cu.usbserial-6AVNHXS8')
|
||||||
var universe = dmx.addUniverse('demo', 'null')
|
var universe = dmx.addUniverse('demo', 'null')
|
||||||
|
|
||||||
universe.update({0: 1, 1: 0})
|
universe.update({1: 1, 2: 0})
|
||||||
universe.update({15: 1, 16: 255})
|
universe.update({16: 1, 17: 255})
|
||||||
universe.update({1: 255, 3: 120, 4: 230, 5: 30, 6: 110, 7: 255, 8: 10, 9: 255, 10: 255, 11: 0})
|
universe.update({1: 255, 3: 120, 4: 230, 5: 30, 6: 110, 7: 255, 8: 10, 9: 255, 10: 255, 11: 0})
|
||||||
|
|
||||||
function done() {console.log('DONE')}
|
function done() {console.log('DONE')}
|
||||||
|
|
|
@ -12,31 +12,31 @@
|
||||||
{
|
{
|
||||||
"label": "White",
|
"label": "White",
|
||||||
"values": {
|
"values": {
|
||||||
"office": { "0":16, "1":255, "2":0, "3":255, "4": 255, "5":255, "15":16, "16":255, "17":0, "18":255, "19": 255, "20":255 }
|
"office": { "1": 16, "2": 255, "3": 0, "4": 255, "5": 255, "6": 255, "16": 16, "17": 255, "18": 0, "19": 255, "20": 255, "21": 255 }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Natural",
|
"label": "Natural",
|
||||||
"values": {
|
"values": {
|
||||||
"office": { "0":16, "1":255, "2":0, "3":255, "4": 190, "5":140, "15":16, "16":255, "17":0, "18":255, "19": 190, "20":140 }
|
"office": { "1": 16, "2": 255, "3": 0, "4":255, "5": 190, "6": 140, "16": 16, "17": 255, "18": 0, "19": 255, "20": 190, "21":140 }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Worklight",
|
"label": "Worklight",
|
||||||
"values": {
|
"values": {
|
||||||
"office": { "0":16, "1":130, "2":0, "3":255, "4": 165, "5":0, "15": 1, "16":255, "17":0, "18":255, "19": 190, "20":140, "21":0, "22": 0, "23":0, "24":255, "25": 190, "26":140 }
|
"office": { "1": 16, "2": 130, "3": 0, "4": 255, "5": 165, "6": 0, "16": 1, "17": 255, "18": 0, "19": 255, "20": 190, "21": 140, "22": 0, "23": 0, "24": 0, "25": 255, "26": 190, "27": 140 }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Chill",
|
"label": "Chill",
|
||||||
"values": {
|
"values": {
|
||||||
"office": { "0":16, "1":255, "2":0, "3":255, "4": 39, "5":0, "15": 1, "16":255, "17":0, "18":255, "19": 255, "20":0, "21":0, "22": 0, "23":0, "24":128, "25": 0, "26":255, "31":255, "32": 60 }
|
"office": { "1": 16, "2": 255, "3": 0, "4": 255, "5": 39, "6": 0, "16": 1, "17": 255, "18": 0, "19": 255, "20": 255, "21": 0, "22": 0, "23": 0, "24": 0, "25": 128, "26": 0, "27": 255, "32": 255, "33": 60 }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Cinema",
|
"label": "Cinema",
|
||||||
"values": {
|
"values": {
|
||||||
"office": { "0":16, "1":30, "2":0, "3":255, "4": 39, "5":0, "15":0, "31":255, "32":0 }
|
"office": { "1": 16, "2": 30, "3":0, "4": 255, "5": 39, "6": 0, "16": 0, "32": 255, "33": 0 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -49,15 +49,15 @@
|
||||||
"devices": [
|
"devices": [
|
||||||
{
|
{
|
||||||
"type": "eurolite-led-bar",
|
"type": "eurolite-led-bar",
|
||||||
"address": 0
|
"address": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "eurolite-led-bar",
|
"type": "eurolite-led-bar",
|
||||||
"address": 15
|
"address": 16
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "showtec-multidim2",
|
"type": "showtec-multidim2",
|
||||||
"address": 31
|
"address": 32
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "stairville-led-par-56",
|
"type": "stairville-led-par-56",
|
||||||
|
@ -73,23 +73,23 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "oppsk-cob-uv-par",
|
"type": "oppsk-cob-uv-par",
|
||||||
"address": 99
|
"address": 100
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "lixda-par12-led",
|
"type": "lixda-par12-led",
|
||||||
"address": 109
|
"address": 110
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "lixda-par12-led",
|
"type": "lixda-par12-led",
|
||||||
"address": 119
|
"address": 120
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "lixda-par12-led",
|
"type": "lixda-par12-led",
|
||||||
"address": 129
|
"address": 130
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "lixda-par12-led",
|
"type": "lixda-par12-led",
|
||||||
"address": 139
|
"address": 140
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -104,15 +104,15 @@
|
||||||
"devices": [
|
"devices": [
|
||||||
{
|
{
|
||||||
"type": "eurolite-led-bar",
|
"type": "eurolite-led-bar",
|
||||||
"address": 0
|
"address": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "eurolite-led-bar",
|
"type": "eurolite-led-bar",
|
||||||
"address": 15
|
"address": 16
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "showtec-multidim2",
|
"type": "showtec-multidim2",
|
||||||
"address": 31
|
"address": 32
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "stairville-led-par-56",
|
"type": "stairville-led-par-56",
|
||||||
|
@ -139,15 +139,15 @@
|
||||||
"devices": [
|
"devices": [
|
||||||
{
|
{
|
||||||
"type": "eurolite-led-bar",
|
"type": "eurolite-led-bar",
|
||||||
"address": 0
|
"address": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "eurolite-led-bar",
|
"type": "eurolite-led-bar",
|
||||||
"address": 15
|
"address": 16
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "showtec-multidim2",
|
"type": "showtec-multidim2",
|
||||||
"address": 31
|
"address": 32
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "stairville-led-par-56",
|
"type": "stairville-led-par-56",
|
||||||
|
|
|
@ -11,7 +11,7 @@ function EnttecODE(device_id, options) {
|
||||||
self.universe_id = new Buffer([0x00, 0x00])
|
self.universe_id = new Buffer([0x00, 0x00])
|
||||||
self.length = new Buffer([0x02, 0x00])
|
self.length = new Buffer([0x02, 0x00])
|
||||||
|
|
||||||
self.universe = new Buffer(512)
|
self.universe = new Buffer(513)
|
||||||
self.universe.fill(0)
|
self.universe.fill(0)
|
||||||
|
|
||||||
self.sleepTime = 24
|
self.sleepTime = 24
|
||||||
|
@ -31,7 +31,7 @@ EnttecODE.prototype.send_universe = function() {
|
||||||
this.physical,
|
this.physical,
|
||||||
this.universe_id,
|
this.universe_id,
|
||||||
this.length,
|
this.length,
|
||||||
this.universe
|
this.universe.slice(1)
|
||||||
])
|
])
|
||||||
|
|
||||||
this.dev.send(pkg, 0, pkg.length, this.port, this.host)
|
this.dev.send(pkg, 0, pkg.length, this.port, this.host)
|
||||||
|
@ -57,7 +57,7 @@ EnttecODE.prototype.update = function(u) {
|
||||||
}
|
}
|
||||||
|
|
||||||
EnttecODE.prototype.updateAll = function(v) {
|
EnttecODE.prototype.updateAll = function(v) {
|
||||||
for (var i = 0; i < 512; i++) {
|
for (var i = 1; i <= 512; i++) {
|
||||||
this.universe[i] = v
|
this.universe[i] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
|
|
||||||
var dgram = require('dgram')
|
var dgram = require('dgram')
|
||||||
|
|
||||||
|
var UNIVERSE_LEN = 512
|
||||||
|
|
||||||
function BBDMX(device_id, options) {
|
function BBDMX(device_id, options) {
|
||||||
var self = this
|
var self = this
|
||||||
self.options = options || {}
|
self.options = options || {}
|
||||||
self.universe = new Buffer(512)
|
self.universe = new Buffer(UNIVERSE_LEN + 1)
|
||||||
self.universe.fill(0)
|
self.universe.fill(0)
|
||||||
self.host = device_id || '127.0.0.1'
|
self.host = device_id || '127.0.0.1'
|
||||||
self.port = self.options.port || 9930
|
self.port = self.options.port || 9930
|
||||||
|
@ -16,9 +18,9 @@ function BBDMX(device_id, options) {
|
||||||
|
|
||||||
BBDMX.prototype.send_universe = function() {
|
BBDMX.prototype.send_universe = function() {
|
||||||
var channel
|
var channel
|
||||||
var messageBuffer = new Buffer(this.universe.length.toString())
|
var messageBuffer = new Buffer(UNIVERSE_LEN.toString())
|
||||||
|
|
||||||
for (var i = 0; i < this.universe.length; i++) {
|
for (var i = 1; i <= UNIVERSE_LEN; i++) {
|
||||||
channel = new Buffer(' ' + this.universe[i])
|
channel = new Buffer(' ' + this.universe[i])
|
||||||
messageBuffer = Buffer.concat([messageBuffer, channel])
|
messageBuffer = Buffer.concat([messageBuffer, channel])
|
||||||
}
|
}
|
||||||
|
@ -45,7 +47,7 @@ BBDMX.prototype.update = function(u) {
|
||||||
}
|
}
|
||||||
|
|
||||||
BBDMX.prototype.updateAll = function(v) {
|
BBDMX.prototype.updateAll = function(v) {
|
||||||
for (var i = 0; i < 512; i++) {
|
for (var i = 1; i <= UNIVERSE_LEN; i++) {
|
||||||
this.universe[i] = v
|
this.universe[i] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
|
|
||||||
var SerialPort = require("serialport")
|
var SerialPort = require("serialport")
|
||||||
|
|
||||||
|
var UNIVERSE_LEN = 512
|
||||||
|
|
||||||
function DMX4ALL(device_id, options) {
|
function DMX4ALL(device_id, options) {
|
||||||
var self = this
|
var self = this
|
||||||
options = options || {}
|
options = options || {}
|
||||||
this.universe = new Buffer(512)
|
this.universe = new Buffer(UNIVERSE_LEN + 1)
|
||||||
this.universe.fill(0)
|
this.universe.fill(0)
|
||||||
|
|
||||||
this.dev = new SerialPort(device_id, {
|
this.dev = new SerialPort(device_id, {
|
||||||
|
@ -28,11 +30,11 @@ DMX4ALL.prototype.send_universe = function() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var msg = Buffer(this.universe.length * 3)
|
var msg = Buffer(UNIVERSE_LEN * 3)
|
||||||
for(var i = 0; i < this.universe.length; i++) {
|
for(var i = 0; i < UNIVERSE_LEN; i++) {
|
||||||
msg[i * 3 + 0] = (i < 256) ? 0xE2 : 0xE3
|
msg[i * 3 + 0] = (i < 256) ? 0xE2 : 0xE3
|
||||||
msg[i * 3 + 1] = i
|
msg[i * 3 + 1] = i
|
||||||
msg[i * 3 + 2] = this.universe[i]
|
msg[i * 3 + 2] = this.universe[i + 1]
|
||||||
}
|
}
|
||||||
this.dev.write(msg)
|
this.dev.write(msg)
|
||||||
}
|
}
|
||||||
|
@ -52,7 +54,7 @@ DMX4ALL.prototype.update = function(u) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DMX4ALL.prototype.updateAll = function(v){
|
DMX4ALL.prototype.updateAll = function(v){
|
||||||
for(var i = 0; i < 512; i++) {
|
for(var i = 1; i <= 512; i++) {
|
||||||
this.universe[i] = v
|
this.universe[i] = v
|
||||||
}
|
}
|
||||||
this.send_universe()
|
this.send_universe()
|
||||||
|
|
|
@ -14,7 +14,7 @@ var DMXKING_ULTRA_DMX_PRO_DMX_STARTCODE = 0x00
|
||||||
function DMXKingUltraDMXPro(device_id, options) {
|
function DMXKingUltraDMXPro(device_id, options) {
|
||||||
var self = this
|
var self = this
|
||||||
this.options = options || {}
|
this.options = options || {}
|
||||||
this.universe = new Buffer(512)
|
this.universe = new Buffer(513)
|
||||||
this.universe.fill(0)
|
this.universe.fill(0)
|
||||||
|
|
||||||
this.sendDMXReq = DMXKING_ULTRA_DMX_PRO_SEND_DMX_RQ
|
this.sendDMXReq = DMXKING_ULTRA_DMX_PRO_SEND_DMX_RQ
|
||||||
|
@ -43,14 +43,14 @@ DMXKingUltraDMXPro.prototype.send_universe = function() {
|
||||||
var hdr = Buffer([
|
var hdr = Buffer([
|
||||||
DMXKING_ULTRA_DMX_PRO_START_OF_MSG,
|
DMXKING_ULTRA_DMX_PRO_START_OF_MSG,
|
||||||
this.sendDMXReq,
|
this.sendDMXReq,
|
||||||
(this.universe.length + 1) & 0xff,
|
(this.universe.length) & 0xff,
|
||||||
((this.universe.length + 1) >> 8) & 0xff,
|
((this.universe.length) >> 8) & 0xff,
|
||||||
DMXKING_ULTRA_DMX_PRO_DMX_STARTCODE
|
DMXKING_ULTRA_DMX_PRO_DMX_STARTCODE
|
||||||
])
|
])
|
||||||
|
|
||||||
var msg = Buffer.concat([
|
var msg = Buffer.concat([
|
||||||
hdr,
|
hdr,
|
||||||
this.universe,
|
this.universe.slice(1),
|
||||||
Buffer([DMXKING_ULTRA_DMX_PRO_END_OF_MSG])
|
Buffer([DMXKING_ULTRA_DMX_PRO_END_OF_MSG])
|
||||||
])
|
])
|
||||||
this.dev.write(msg)
|
this.dev.write(msg)
|
||||||
|
@ -71,7 +71,7 @@ DMXKingUltraDMXPro.prototype.update = function(u) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DMXKingUltraDMXPro.prototype.updateAll = function(v){
|
DMXKingUltraDMXPro.prototype.updateAll = function(v){
|
||||||
for(var i = 0; i < 512; i++) {
|
for(var i = 1; i <= 512; i++) {
|
||||||
this.universe[i] = v
|
this.universe[i] = v
|
||||||
}
|
}
|
||||||
this.send_universe()
|
this.send_universe()
|
||||||
|
|
|
@ -6,7 +6,7 @@ function EnttecOpenUsbDMX(device_id, options) {
|
||||||
var self = this
|
var self = this
|
||||||
options = options || {}
|
options = options || {}
|
||||||
|
|
||||||
this.universe = new Buffer(512)
|
this.universe = new Buffer(513)
|
||||||
this.universe.fill(0)
|
this.universe.fill(0)
|
||||||
|
|
||||||
self.interval = 46
|
self.interval = 46
|
||||||
|
@ -36,7 +36,7 @@ EnttecOpenUsbDMX.prototype.send_universe = function() {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
self.dev.set({brk: false}, function(err, r) {
|
self.dev.set({brk: false}, function(err, r) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
self.dev.write(Buffer.concat([Buffer([0]), self.universe]))
|
self.dev.write(Buffer.concat([Buffer([0]), self.universe.slice(1)]))
|
||||||
}, 1)
|
}, 1)
|
||||||
})
|
})
|
||||||
}, 1)
|
}, 1)
|
||||||
|
@ -63,7 +63,7 @@ EnttecOpenUsbDMX.prototype.update = function(u) {
|
||||||
}
|
}
|
||||||
|
|
||||||
EnttecOpenUsbDMX.prototype.updateAll = function(v) {
|
EnttecOpenUsbDMX.prototype.updateAll = function(v) {
|
||||||
for(var i = 0; i < 512; i++) {
|
for(var i = 1; i <= 512; i++) {
|
||||||
this.universe[i] = v
|
this.universe[i] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ var ENTTEC_PRO_DMX_STARTCODE = 0x00
|
||||||
function EnttecUSBDMXPRO(device_id, options) {
|
function EnttecUSBDMXPRO(device_id, options) {
|
||||||
var self = this
|
var self = this
|
||||||
options = options || {}
|
options = options || {}
|
||||||
this.universe = new Buffer(512)
|
this.universe = new Buffer(513)
|
||||||
this.universe.fill(0)
|
this.universe.fill(0)
|
||||||
|
|
||||||
this.dev = new SerialPort(device_id, {
|
this.dev = new SerialPort(device_id, {
|
||||||
|
@ -34,14 +34,14 @@ EnttecUSBDMXPRO.prototype.send_universe = function() {
|
||||||
var hdr = Buffer([
|
var hdr = Buffer([
|
||||||
ENTTEC_PRO_START_OF_MSG,
|
ENTTEC_PRO_START_OF_MSG,
|
||||||
ENTTEC_PRO_SEND_DMX_RQ,
|
ENTTEC_PRO_SEND_DMX_RQ,
|
||||||
(this.universe.length + 1) & 0xff,
|
(this.universe.length) & 0xff,
|
||||||
((this.universe.length + 1) >> 8) & 0xff,
|
((this.universe.length) >> 8) & 0xff,
|
||||||
ENTTEC_PRO_DMX_STARTCODE
|
ENTTEC_PRO_DMX_STARTCODE
|
||||||
])
|
])
|
||||||
|
|
||||||
var msg = Buffer.concat([
|
var msg = Buffer.concat([
|
||||||
hdr,
|
hdr,
|
||||||
this.universe,
|
this.universe.slice(1),
|
||||||
Buffer([ENTTEC_PRO_END_OF_MSG])
|
Buffer([ENTTEC_PRO_END_OF_MSG])
|
||||||
])
|
])
|
||||||
this.dev.write(msg)
|
this.dev.write(msg)
|
||||||
|
@ -62,7 +62,7 @@ EnttecUSBDMXPRO.prototype.update = function(u) {
|
||||||
}
|
}
|
||||||
|
|
||||||
EnttecUSBDMXPRO.prototype.updateAll = function(v){
|
EnttecUSBDMXPRO.prototype.updateAll = function(v){
|
||||||
for(var i = 0; i < 512; i++) {
|
for(var i = 1; i <= 512; i++) {
|
||||||
this.universe[i] = v
|
this.universe[i] = v
|
||||||
}
|
}
|
||||||
this.send_universe()
|
this.send_universe()
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
function Null(device_id, options) {
|
function Null(device_id, options) {
|
||||||
var self = this
|
var self = this
|
||||||
options = options || {}
|
options = options || {}
|
||||||
this.universe = new Buffer(512)
|
this.universe = new Buffer(513)
|
||||||
this.universe.fill(0)
|
this.universe.fill(0)
|
||||||
self.start()
|
self.start()
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,11 @@ Null.prototype.update = function(u) {
|
||||||
for(var c in u) {
|
for(var c in u) {
|
||||||
this.universe[c] = u[c]
|
this.universe[c] = u[c]
|
||||||
}
|
}
|
||||||
console.log(this.universe)
|
console.log(this.universe.slice(1))
|
||||||
}
|
}
|
||||||
|
|
||||||
Null.prototype.updateAll = function(v){
|
Null.prototype.updateAll = function(v){
|
||||||
for(var i = 0; i < 512; i++) {
|
for(var i = 1; i <= 512; i++) {
|
||||||
this.universe[i] = v
|
this.universe[i] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue