commit 332b9b8f70e06f4e4839123a69790ce83de7919d Author: Sebastian Wiedenroth Date: Sat Sep 1 14:17:39 2012 +0200 initial commit diff --git a/devices.js b/devices.js new file mode 100644 index 0000000..cdf5e53 --- /dev/null +++ b/devices.js @@ -0,0 +1,34 @@ +exports.devices = { + 'eurolite-led-bar': { + channels: ['ctrl', 'dimmer', 'strobe', 'red0', 'green0', 'blue0', 'red1', 'green1', 'blue1', 'red2', 'green2', 'blue2'], + ranges: { + 'ctrl': { + 'type': 'option', + 'options': [ + {'value': 0, 'label': 'Black Out'}, + {'value': 1, 'label': 'Dimmer 1'}, + {'value': 16, 'label': 'Dimmer 2'}, + {'value': 32, 'label': 'Red'}, + {'value': 48, 'label': 'Green'}, + {'value': 64, 'label': 'Blue'}, + {'value': 80, 'label': 'Purple'}, + {'value': 96, 'label': 'Yellow'}, + {'value': 112, 'label': 'Cyan'}, + {'value': 128, 'label': 'White'}, + {'value': 144, 'label': 'Color change'}, + {'value': 160, 'label': 'Color flow'}, + {'value': 176, 'label': 'Color dream'}, + {'value': 192, 'label': 'Multi flow'}, + {'value': 208, 'label': 'Dream flow'}, + {'value': 224, 'label': 'Two color flow'}, + {'value': 240, 'label': 'Sound activity'} + ] + }, + 'dimmer': { + 'type': 'slider', + 'min': 0, + 'max': 255 + } + } + } +} \ No newline at end of file diff --git a/dmx.js b/dmx.js new file mode 100644 index 0000000..6b57b7b --- /dev/null +++ b/dmx.js @@ -0,0 +1,7 @@ + +var drv = require('./drivers/enttec-usb-dmx-pro.js'); +universe = new drv.init(0); +universe.update({0: 1, 1:0xff, 6: 20, 7: 0xff}, 20) + + + diff --git a/drivers/enttec-usb-dmx-pro.js b/drivers/enttec-usb-dmx-pro.js new file mode 100644 index 0000000..61469a5 --- /dev/null +++ b/drivers/enttec-usb-dmx-pro.js @@ -0,0 +1,50 @@ +var Ftdi = require('./node-ftdi/index'); + + +var ENTTEC_PRO_DMX_STARTCODE = 0x00 + , ENTTEC_PRO_START_OF_MSG = 0x7e + , ENTTEC_PRO_END_OF_MSG = 0xe7 + , ENTTEC_PRO_SEND_DMX_RQ = 0x06 + , ENTTEC_PRO_RECV_DMX_PKT = 0x05 + ; + + +exports.init = function(dev_id) { + var send_universe = function(dev, universe) { + var hdr = Buffer([ + ENTTEC_PRO_START_OF_MSG, + ENTTEC_PRO_SEND_DMX_RQ, + (universe.length + 1) & 0xff, + ((universe.length + 1) >> 8) & 0xff, + ENTTEC_PRO_DMX_STARTCODE + ]) + + var msg = Buffer.concat([ + hdr, + universe, + Buffer([ENTTEC_PRO_END_OF_MSG]) + ]) + console.log(msg) + dev.write(msg) + } + + var universe = new Buffer(512) + universe.fill(0) + + var dev = new Ftdi({'index': dev_id}); + dev.open(); + dev.setBaudrate(250000); + dev.setLineProperty(Ftdi.BITS_8, Ftdi.STOP_BIT_2, Ftdi.NONE); + + this.update = function(u) { + for(var k in u) { + universe[k] = u[k] + } + } + + setInterval(function() { + send_universe(dev, universe); + }, 1000); + + return this; +} diff --git a/setup.js b/setup.js new file mode 100644 index 0000000..8354fa1 --- /dev/null +++ b/setup.js @@ -0,0 +1,20 @@ +exports.setup = { + universes: { + 'office': { + 'output': { + 'driver': 'enttec-usb-dmx-pro', + 'device': 0 + }, + 'devices': [ + { + 'type': 'eurolite-led-bar', + 'address': 1 + }, + { + 'type': 'eurolite-led-bar', + 'address': 13 + } + ] + } + } +}