register artnet driver by default and adjust style a bit
This commit is contained in:
parent
7c95c4eaec
commit
9a34f3de30
3 changed files with 39 additions and 40 deletions
1
dmx.js
1
dmx.js
|
@ -12,6 +12,7 @@ function DMX(options) {
|
|||
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'))
|
||||
this.registerDriver('artnet', require('./drivers/artnet'))
|
||||
}
|
||||
|
||||
util.inherits(DMX, EventEmitter)
|
||||
|
|
|
@ -1,41 +1,36 @@
|
|||
"use strict"
|
||||
|
||||
const dgram = require('dgram');
|
||||
var dgram = require('dgram')
|
||||
|
||||
const ARTNET = {
|
||||
PORT : 6454,
|
||||
HOST : "127.0.0.1"
|
||||
}
|
||||
|
||||
function EnttecODE(device_id, cb) {
|
||||
function EnttecODE(device_id, options) {
|
||||
var self = this
|
||||
|
||||
self.header = new Buffer([65, 114, 116, 45, 78, 101, 116, 0, 0, 80, 0, 14]);
|
||||
self.sequence = self.physical = new Buffer([0]);
|
||||
self.length = new Buffer([0x02,0x00]);
|
||||
self.header = new Buffer([65, 114, 116, 45, 78, 101, 116, 0, 0, 80, 0, 14])
|
||||
self.sequence = self.physical = new Buffer([0])
|
||||
self.length = new Buffer([0x02,0x00])
|
||||
|
||||
cb = cb || function() {}
|
||||
this.universe = new Buffer(512)
|
||||
this.universe.fill(0)
|
||||
|
||||
self.sleepTime = 24
|
||||
self.timeout
|
||||
|
||||
self.dev = dgram.createSocket('udp4');
|
||||
self.start();
|
||||
|
||||
// self.dev.bind(6454, function() {
|
||||
|
||||
// });
|
||||
options = options || {}
|
||||
self.host = device_id || '127.0.0.1'
|
||||
self.port = options.port || 6454
|
||||
self.dev = dgram.createSocket('udp4')
|
||||
self.start()
|
||||
}
|
||||
|
||||
EnttecODE.prototype.send_universe = function() {
|
||||
var pkg = Buffer.concat([
|
||||
this.header,
|
||||
this.sequence,
|
||||
this.physical,
|
||||
this.length,
|
||||
this.universe
|
||||
])
|
||||
|
||||
var pkg = Buffer.concat([this.header, this.sequence, this.physical,this.length,this.universe]);
|
||||
|
||||
this.dev.send(pkg, 0, pkg.length, ARTNET.PORT, ARTNET.HOST, function() {
|
||||
// Package Sent
|
||||
});
|
||||
this.dev.send(pkg, 0, pkg.length, self.port, self.host)
|
||||
}
|
||||
|
||||
EnttecODE.prototype.start = function() {
|
||||
|
@ -48,7 +43,7 @@ EnttecODE.prototype.stop = function() {
|
|||
|
||||
EnttecODE.prototype.close = function(cb) {
|
||||
this.stop()
|
||||
this.dev.close(cb)
|
||||
cb(null)
|
||||
}
|
||||
|
||||
EnttecODE.prototype.update = function(u) {
|
||||
|
|
|
@ -62,10 +62,12 @@ Create a new DMX instance. This class is used to tie multiple universes together
|
|||
|
||||
|
||||
Register a new DMX Driver module by its name.
|
||||
Two Drivers are currently registered by default:
|
||||
These drivers are currently registered by default:
|
||||
|
||||
- null: a development driver that prints the universe to stdout
|
||||
- enttec-usb-dmx-pro: a driver for devices using a Enttec USB DMX Pro chip like the "DMXKing ultraDMX Micro". This driver requires the ftdi module (<https://github.com/KABA-CCEAC/node-ftdi>)
|
||||
- enttec-usb-dmx-pro: a driver for devices using a Enttec USB DMX Pro chip like the "DMXKing ultraDMX Micro".
|
||||
- enttec-open-usb-dmx: driver for "Enttec Open DMX USB". This driver has not received enough testing and the hardware has known limitations. (If possible better obtain a device with the "pro" chip)
|
||||
- artnet: driver for EnttecODE
|
||||
|
||||
#### dmx.addUniverse(name, driver, device_id)
|
||||
|
||||
|
@ -74,6 +76,7 @@ Two Drivers are currently registered by default:
|
|||
- <code>device_id</code> - Number or Object
|
||||
|
||||
Add a new DMX Universe with a name, driver and an optional device_id used by the driver to identify the device.
|
||||
For enttec-usb-dmx-pro and enttec-open-usb-dmx device_id is the path the the serial device. For artnet it is the target ip.
|
||||
|
||||
#### dmx.update(universe, channels)
|
||||
|
||||
|
|
Loading…
Reference in a new issue