From 25adc11f1716f6091184d5114e31e4443a653e19 Mon Sep 17 00:00:00 2001 From: Sebastian Wiedenroth Date: Sat, 19 Nov 2016 22:10:57 +0100 Subject: [PATCH] make bbdmx driver more backwards compatible, adjust style and add it to the readme --- drivers/bbdmx.js | 66 ++++++++++++++++++++++++------------------------ readme.md | 3 ++- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/drivers/bbdmx.js b/drivers/bbdmx.js index baf60e4..3a01870 100644 --- a/drivers/bbdmx.js +++ b/drivers/bbdmx.js @@ -1,57 +1,57 @@ -'use strict'; +'use strict' -const dgram = require('dgram'); +var dgram = require('dgram') function BBDMX(device_id, options) { - const self = this; - self.options = options || {}; - self.universe = new Buffer(512); - self.universe.fill(0); - self.host = device_id || '127.0.0.1'; - self.port = self.options.port || 9930; - self.dev = dgram.createSocket('udp4'); - self.sleepTime = 24; - self.start(); + var self = this + self.options = options || {} + self.universe = new Buffer(512) + self.universe.fill(0) + self.host = device_id || '127.0.0.1' + self.port = self.options.port || 9930 + self.dev = dgram.createSocket('udp4') + self.sleepTime = 24 + self.start() } BBDMX.prototype.send_universe = function() { - let messageBuffer = new Buffer(this.universe.length.toString()); + var channel + var messageBuffer = new Buffer(this.universe.length.toString()) - for (let i = 0; i < this.universe.length; i++) { - const channel = new Buffer(' ' + this.universe[i]); - const length = channel.length + messageBuffer.length; - messageBuffer = Buffer.concat([messageBuffer, channel], length); + for (var i = 0; i < this.universe.length; i++) { + channel = new Buffer(' ' + this.universe[i]) + messageBuffer = Buffer.concat([messageBuffer, channel]) } - this.dev.send(messageBuffer, 0, messageBuffer.length, this.port, this.host); -}; + this.dev.send(messageBuffer, 0, messageBuffer.length, this.port, this.host) +} BBDMX.prototype.start = function() { - this.timeout = setInterval(this.send_universe.bind(this), this.sleepTime); -}; + this.timeout = setInterval(this.send_universe.bind(this), this.sleepTime) +} BBDMX.prototype.stop = function() { - clearInterval(this.timeout); -}; + clearInterval(this.timeout) +} BBDMX.prototype.close = function(cb) { - this.stop(); - cb(null); + this.stop() + cb(null) }; BBDMX.prototype.update = function(u) { - for (let c in u) { - this.universe[c] = u[c]; + for (var c in u) { + this.universe[c] = u[c] } -}; +} BBDMX.prototype.updateAll = function(v) { - for (let i = 0; i < 512; i++) { - this.universe[i] = v; + for (var i = 0; i < 512; i++) { + this.universe[i] = v } -}; +} BBDMX.prototype.get = function(c) { - return this.universe[c]; -}; + return this.universe[c] +} -module.exports = BBDMX; +module.exports = BBDMX diff --git a/readme.md b/readme.md index f144c25..d4ebf30 100644 --- a/readme.md +++ b/readme.md @@ -65,10 +65,11 @@ Register a new DMX Driver module by its name. These drivers are currently registered by default: - null: a development driver that prints the universe to stdout +- artnet: driver for EnttecODE +- bbdmx: driver for [BeagleBone-DMX](https://github.com/boxysean/beaglebone-DMX) - dmx4all: driver for DMX4ALL devices like the "NanoDMX USB Interface" - 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 device is NOT recommended, there are known hardware limitations and this driver is not very stable. (If possible better obtain a device with the "pro" chip) -- artnet: driver for EnttecODE #### dmx.addUniverse(name, driver, device_id)