Added support for defining devices in config file (#64)
This commit is contained in:
parent
338b80fb06
commit
cfe02e8ffe
4 changed files with 10 additions and 7 deletions
4
demo.js
4
demo.js
|
@ -1,9 +1,9 @@
|
||||||
"use strict"
|
"use strict"
|
||||||
|
|
||||||
var DMX = require('./dmx')
|
var DMX = require('./dmx')
|
||||||
var A = DMX.Animation
|
|
||||||
|
|
||||||
var dmx = new DMX()
|
var dmx = new DMX();
|
||||||
|
var A = dmx.animation;
|
||||||
|
|
||||||
// var universe = dmx.addUniverse('demo', 'enttec-usb-dmx-pro', '/dev/cu.usbserial-6AVNHXS8')
|
// var universe = dmx.addUniverse('demo', 'enttec-usb-dmx-pro', '/dev/cu.usbserial-6AVNHXS8')
|
||||||
// var universe = dmx.addUniverse('demo', 'enttec-open-usb-dmx', '/dev/cu.usbserial-6AVNHXS8')
|
// var universe = dmx.addUniverse('demo', 'enttec-open-usb-dmx', '/dev/cu.usbserial-6AVNHXS8')
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
"use strict"
|
"use strict"
|
||||||
|
|
||||||
var DMX = require('./dmx');
|
var DMX = require('./dmx');
|
||||||
var A = DMX.Animation;
|
|
||||||
|
|
||||||
var dmx = new DMX();
|
var dmx = new DMX();
|
||||||
|
var A = dmx.animation;
|
||||||
|
|
||||||
// var universe = dmx.addUniverse('demo', 'enttec-open-usb-dmx', '/dev/cu.usbserial-6AVNHXS8')
|
// var universe = dmx.addUniverse('demo', 'enttec-open-usb-dmx', '/dev/cu.usbserial-6AVNHXS8')
|
||||||
var universe = dmx.addUniverse('demo', 'null')
|
var universe = dmx.addUniverse('demo', 'null')
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ function DMXWeb() {
|
||||||
var server = http.createServer(app)
|
var server = http.createServer(app)
|
||||||
var io = socketio.listen(server)
|
var io = socketio.listen(server)
|
||||||
|
|
||||||
var dmx = new DMX()
|
var dmx = new DMX(config)
|
||||||
|
|
||||||
for(var universe in config.universes) {
|
for(var universe in config.universes) {
|
||||||
dmx.addUniverse(
|
dmx.addUniverse(
|
||||||
|
@ -56,7 +56,7 @@ function DMXWeb() {
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get('/config', function(req, res) {
|
app.get('/config', function(req, res) {
|
||||||
var response = {"devices": DMX.devices, "universes": {}}
|
var response = {"devices": dmx.devices, "universes": {}}
|
||||||
Object.keys(config.universes).forEach(function(key) {
|
Object.keys(config.universes).forEach(function(key) {
|
||||||
response.universes[key] = config.universes[key].devices
|
response.universes[key] = config.universes[key].devices
|
||||||
})
|
})
|
||||||
|
@ -108,7 +108,7 @@ function DMXWeb() {
|
||||||
})
|
})
|
||||||
|
|
||||||
io.sockets.on('connection', function(socket) {
|
io.sockets.on('connection', function(socket) {
|
||||||
socket.emit('init', {'devices': DMX.devices, 'setup': config})
|
socket.emit('init', {'devices': dmx.devices, 'setup': config})
|
||||||
|
|
||||||
socket.on('request_refresh', function() {
|
socket.on('request_refresh', function() {
|
||||||
for(var universe in config.universes) {
|
for(var universe in config.universes) {
|
||||||
|
|
4
dmx.js
4
dmx.js
|
@ -5,9 +5,11 @@ var EventEmitter = require('events').EventEmitter
|
||||||
|
|
||||||
function DMX(options) {
|
function DMX(options) {
|
||||||
var options = options || {}
|
var options = options || {}
|
||||||
|
var devices = options.devices || {}
|
||||||
this.universes = {}
|
this.universes = {}
|
||||||
this.drivers = {}
|
this.drivers = {}
|
||||||
this.devices = options.devices || require('./devices')
|
this.devices = Object.assign({}, require('./devices'), devices);
|
||||||
|
this.animation = require('./anim')
|
||||||
|
|
||||||
this.registerDriver('null', require('./drivers/null'))
|
this.registerDriver('null', require('./drivers/null'))
|
||||||
this.registerDriver('dmx4all', require('./drivers/dmx4all'))
|
this.registerDriver('dmx4all', require('./drivers/dmx4all'))
|
||||||
|
|
Loading…
Reference in a new issue