enttec openDMX attempt 1
This commit is contained in:
parent
a09449101f
commit
d96e5478d9
3 changed files with 64 additions and 2 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -10,5 +10,6 @@ lib-cov
|
|||
pids
|
||||
logs
|
||||
results
|
||||
.DS_Store
|
||||
|
||||
node_modules
|
||||
|
|
5
dmx.js
5
dmx.js
|
@ -7,8 +7,9 @@ function DMX() {
|
|||
this.universes = {}
|
||||
this.drivers = {}
|
||||
|
||||
this.registerDriver('null', require('./drivers/null'))
|
||||
this.registerDriver('enttec-usb-dmx-pro', require('./drivers/enttec-usb-dmx-pro'))
|
||||
this.registerDriver('null', require('./drivers/null'))
|
||||
this.registerDriver('enttec-usb-dmx-pro', require('./drivers/enttec-usb-dmx-pro'))
|
||||
this.registerDriver('enttec-open-usb-dmx', require('./drivers/enttec-open-usb-dmx'))
|
||||
}
|
||||
|
||||
util.inherits(DMX, EventEmitter)
|
||||
|
|
60
drivers/enttec-open-usb-dmx.js
Normal file
60
drivers/enttec-open-usb-dmx.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
"use strict"
|
||||
|
||||
var FTDI = require('ftdi')
|
||||
|
||||
var ENTTEC_PRO_DMX_STARTCODE = 0x00
|
||||
, ENTTEC_PRO_START_OF_MSG = 0x7e
|
||||
, ENTTEC_PRO_END_OF_MSG = 0xe7
|
||||
, ENTTEC_PRO_SEND_DMX_RQ = 0x06
|
||||
;
|
||||
|
||||
function EnttecUSBDMXPRO(device_id, cb) {
|
||||
var self = this
|
||||
cb = cb || function() {}
|
||||
this.universe = new Buffer(512)
|
||||
this.universe.fill(0)
|
||||
|
||||
this.dev = new FTDI.FtdiDevice(device_id)
|
||||
this.dev.open({
|
||||
'baudrate': 115200,
|
||||
'databits': 8,
|
||||
'stopbits': 2,
|
||||
'parity': 'none'
|
||||
}, function(err) {
|
||||
cb(err, device_id)
|
||||
if(!err) {
|
||||
self.send_universe()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
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) >> 0) & 0xff,
|
||||
((this.universe.length + 1) >> 8) & 0xff,
|
||||
ENTTEC_PRO_DMX_STARTCODE
|
||||
])
|
||||
|
||||
var msg = Buffer.concat([
|
||||
hdr,
|
||||
this.universe,
|
||||
Buffer([ENTTEC_PRO_END_OF_MSG])
|
||||
])
|
||||
this.dev.write(msg)
|
||||
}
|
||||
|
||||
EnttecUSBDMXPRO.prototype.update = function(u) {
|
||||
for(var c in u) {
|
||||
this.universe[c] = u[c]
|
||||
}
|
||||
this.send_universe()
|
||||
}
|
||||
|
||||
EnttecUSBDMXPRO.prototype.get = function(c) {
|
||||
return this.universe[c]
|
||||
}
|
||||
|
||||
module.exports = EnttecUSBDMXPRO
|
Loading…
Reference in a new issue