Added support for defining devices in config file (#64)

This commit is contained in:
Pierre Frisch 2018-12-18 10:40:53 -08:00 committed by Frédéric Bolvin
parent 338b80fb06
commit cfe02e8ffe
4 changed files with 10 additions and 7 deletions

View file

@ -1,9 +1,9 @@
"use strict"
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-open-usb-dmx', '/dev/cu.usbserial-6AVNHXS8')

View file

@ -1,9 +1,10 @@
"use strict"
var DMX = require('./dmx');
var A = DMX.Animation;
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', 'null')

View file

@ -23,7 +23,7 @@ function DMXWeb() {
var server = http.createServer(app)
var io = socketio.listen(server)
var dmx = new DMX()
var dmx = new DMX(config)
for(var universe in config.universes) {
dmx.addUniverse(
@ -56,7 +56,7 @@ function DMXWeb() {
})
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) {
response.universes[key] = config.universes[key].devices
})
@ -108,7 +108,7 @@ function DMXWeb() {
})
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() {
for(var universe in config.universes) {

4
dmx.js
View file

@ -5,9 +5,11 @@ var EventEmitter = require('events').EventEmitter
function DMX(options) {
var options = options || {}
var devices = options.devices || {}
this.universes = {}
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('dmx4all', require('./drivers/dmx4all'))