Skip to content

Commit

Permalink
Change DMX addressing to start at channel 1
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wiedi committed Jul 30, 2017
1 parent e133a52 commit 00d960e
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 49 deletions.
4 changes: 2 additions & 2 deletions demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', 'null')

universe.update({0: 1, 1: 0})
universe.update({15: 1, 16: 255})
universe.update({1: 1, 2: 0})
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})

function done() {console.log('DONE')}
Expand Down
38 changes: 19 additions & 19 deletions dmx-web-example.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@
{
"label": "White",
"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",
"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",
"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",
"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",
"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 }
}
}
],
Expand All @@ -49,15 +49,15 @@
"devices": [
{
"type": "eurolite-led-bar",
"address": 0
"address": 1
},
{
"type": "eurolite-led-bar",
"address": 15
"address": 16
},
{
"type": "showtec-multidim2",
"address": 31
"address": 32
},
{
"type": "stairville-led-par-56",
Expand All @@ -73,23 +73,23 @@
},
{
"type": "oppsk-cob-uv-par",
"address": 99
"address": 100
},
{
"type": "lixda-par12-led",
"address": 109
"address": 110
},
{
"type": "lixda-par12-led",
"address": 119
"address": 120
},
{
"type": "lixda-par12-led",
"address": 129
"address": 130
},
{
"type": "lixda-par12-led",
"address": 139
"address": 140
}
]
},
Expand All @@ -104,15 +104,15 @@
"devices": [
{
"type": "eurolite-led-bar",
"address": 0
"address": 1
},
{
"type": "eurolite-led-bar",
"address": 15
"address": 16
},
{
"type": "showtec-multidim2",
"address": 31
"address": 32
},
{
"type": "stairville-led-par-56",
Expand All @@ -139,15 +139,15 @@
"devices": [
{
"type": "eurolite-led-bar",
"address": 0
"address": 1
},
{
"type": "eurolite-led-bar",
"address": 15
"address": 16
},
{
"type": "showtec-multidim2",
"address": 31
"address": 32
},
{
"type": "stairville-led-par-56",
Expand Down
6 changes: 3 additions & 3 deletions drivers/artnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function EnttecODE(device_id, options) {
self.universe_id = new Buffer([0x00, 0x00])
self.length = new Buffer([0x02, 0x00])

self.universe = new Buffer(512)
self.universe = new Buffer(513)
self.universe.fill(0)

self.sleepTime = 24
Expand All @@ -31,7 +31,7 @@ EnttecODE.prototype.send_universe = function() {
this.physical,
this.universe_id,
this.length,
this.universe
this.universe.slice(1)
])

this.dev.send(pkg, 0, pkg.length, this.port, this.host)
Expand All @@ -57,7 +57,7 @@ EnttecODE.prototype.update = function(u) {
}

EnttecODE.prototype.updateAll = function(v) {
for (var i = 0; i < 512; i++) {
for (var i = 1; i <= 512; i++) {
this.universe[i] = v
}
}
Expand Down
10 changes: 6 additions & 4 deletions drivers/bbdmx.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

var dgram = require('dgram')

var UNIVERSE_LEN = 512

function BBDMX(device_id, options) {
var self = this
self.options = options || {}
self.universe = new Buffer(512)
self.universe = new Buffer(UNIVERSE_LEN + 1)
self.universe.fill(0)
self.host = device_id || '127.0.0.1'
self.port = self.options.port || 9930
Expand All @@ -16,9 +18,9 @@ function BBDMX(device_id, options) {

BBDMX.prototype.send_universe = function() {
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])
messageBuffer = Buffer.concat([messageBuffer, channel])
}
Expand All @@ -45,7 +47,7 @@ BBDMX.prototype.update = function(u) {
}

BBDMX.prototype.updateAll = function(v) {
for (var i = 0; i < 512; i++) {
for (var i = 1; i <= UNIVERSE_LEN; i++) {
this.universe[i] = v
}
}
Expand Down
12 changes: 7 additions & 5 deletions drivers/dmx4all.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

var SerialPort = require("serialport")

var UNIVERSE_LEN = 512

function DMX4ALL(device_id, options) {
var self = this
options = options || {}
this.universe = new Buffer(512)
this.universe = new Buffer(UNIVERSE_LEN + 1)
this.universe.fill(0)

this.dev = new SerialPort(device_id, {
Expand All @@ -28,11 +30,11 @@ DMX4ALL.prototype.send_universe = function() {
return
}

var msg = Buffer(this.universe.length * 3)
for(var i = 0; i < this.universe.length; i++) {
var msg = Buffer(UNIVERSE_LEN * 3)
for(var i = 0; i < UNIVERSE_LEN; i++) {
msg[i * 3 + 0] = (i < 256) ? 0xE2 : 0xE3
msg[i * 3 + 1] = i
msg[i * 3 + 2] = this.universe[i]
msg[i * 3 + 2] = this.universe[i + 1]
}
this.dev.write(msg)
}
Expand All @@ -52,7 +54,7 @@ DMX4ALL.prototype.update = function(u) {
}

DMX4ALL.prototype.updateAll = function(v){
for(var i = 0; i < 512; i++) {
for(var i = 1; i <= 512; i++) {
this.universe[i] = v
}
this.send_universe()
Expand Down
10 changes: 5 additions & 5 deletions drivers/dmxking-ultra-dmx-pro.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var DMXKING_ULTRA_DMX_PRO_DMX_STARTCODE = 0x00
function DMXKingUltraDMXPro(device_id, options) {
var self = this
this.options = options || {}
this.universe = new Buffer(512)
this.universe = new Buffer(513)
this.universe.fill(0)

this.sendDMXReq = DMXKING_ULTRA_DMX_PRO_SEND_DMX_RQ
Expand Down Expand Up @@ -43,14 +43,14 @@ DMXKingUltraDMXPro.prototype.send_universe = function() {
var hdr = Buffer([
DMXKING_ULTRA_DMX_PRO_START_OF_MSG,
this.sendDMXReq,
(this.universe.length + 1) & 0xff,
((this.universe.length + 1) >> 8) & 0xff,
(this.universe.length) & 0xff,
((this.universe.length) >> 8) & 0xff,
DMXKING_ULTRA_DMX_PRO_DMX_STARTCODE
])

var msg = Buffer.concat([
hdr,
this.universe,
this.universe.slice(1),
Buffer([DMXKING_ULTRA_DMX_PRO_END_OF_MSG])
])
this.dev.write(msg)
Expand All @@ -71,7 +71,7 @@ DMXKingUltraDMXPro.prototype.update = function(u) {
}

DMXKingUltraDMXPro.prototype.updateAll = function(v){
for(var i = 0; i < 512; i++) {
for(var i = 1; i <= 512; i++) {
this.universe[i] = v
}
this.send_universe()
Expand Down
6 changes: 3 additions & 3 deletions drivers/enttec-open-usb-dmx.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function EnttecOpenUsbDMX(device_id, options) {
var self = this
options = options || {}

this.universe = new Buffer(512)
this.universe = new Buffer(513)
this.universe.fill(0)

self.interval = 46
Expand Down Expand Up @@ -36,7 +36,7 @@ EnttecOpenUsbDMX.prototype.send_universe = function() {
setTimeout(function() {
self.dev.set({brk: false}, function(err, r) {
setTimeout(function() {
self.dev.write(Buffer.concat([Buffer([0]), self.universe]))
self.dev.write(Buffer.concat([Buffer([0]), self.universe.slice(1)]))
}, 1)
})
}, 1)
Expand All @@ -63,7 +63,7 @@ EnttecOpenUsbDMX.prototype.update = function(u) {
}

EnttecOpenUsbDMX.prototype.updateAll = function(v) {
for(var i = 0; i < 512; i++) {
for(var i = 1; i <= 512; i++) {
this.universe[i] = v
}
}
Expand Down
10 changes: 5 additions & 5 deletions drivers/enttec-usb-dmx-pro.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var ENTTEC_PRO_DMX_STARTCODE = 0x00
function EnttecUSBDMXPRO(device_id, options) {
var self = this
options = options || {}
this.universe = new Buffer(512)
this.universe = new Buffer(513)
this.universe.fill(0)

this.dev = new SerialPort(device_id, {
Expand All @@ -34,14 +34,14 @@ EnttecUSBDMXPRO.prototype.send_universe = function() {
var hdr = Buffer([
ENTTEC_PRO_START_OF_MSG,
ENTTEC_PRO_SEND_DMX_RQ,
(this.universe.length + 1) & 0xff,
((this.universe.length + 1) >> 8) & 0xff,
(this.universe.length) & 0xff,
((this.universe.length) >> 8) & 0xff,
ENTTEC_PRO_DMX_STARTCODE
])

var msg = Buffer.concat([
hdr,
this.universe,
this.universe.slice(1),
Buffer([ENTTEC_PRO_END_OF_MSG])
])
this.dev.write(msg)
Expand All @@ -62,7 +62,7 @@ EnttecUSBDMXPRO.prototype.update = function(u) {
}

EnttecUSBDMXPRO.prototype.updateAll = function(v){
for(var i = 0; i < 512; i++) {
for(var i = 1; i <= 512; i++) {
this.universe[i] = v
}
this.send_universe()
Expand Down
6 changes: 3 additions & 3 deletions drivers/null.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
function Null(device_id, options) {
var self = this
options = options || {}
this.universe = new Buffer(512)
this.universe = new Buffer(513)
this.universe.fill(0)
self.start()
}
Expand All @@ -27,11 +27,11 @@ Null.prototype.update = function(u) {
for(var c in u) {
this.universe[c] = u[c]
}
console.log(this.universe)
console.log(this.universe.slice(1))
}

Null.prototype.updateAll = function(v){
for(var i = 0; i < 512; i++) {
for(var i = 1; i <= 512; i++) {
this.universe[i] = v
}
}
Expand Down

0 comments on commit 00d960e

Please sign in to comment.