dmx-flok/dmx.js

33 lines
792 B
JavaScript
Raw Normal View History

"use strict"
2012-09-01 12:17:39 +00:00
var util = require('util')
var EventEmitter = require('events').EventEmitter
2012-09-01 12:17:39 +00:00
function DMX() {
this.universes = {}
this.drivers = {}
this.registerDriver('null', require('./drivers/null'))
this.registerDriver('enttec-usb-dmx-pro', require('./drivers/enttec-usb-dmx-pro'))
}
2012-09-08 12:43:04 +00:00
util.inherits(DMX, EventEmitter)
2012-09-08 12:43:04 +00:00
DMX.devices = require('./devices')
DMX.Animation = require('./anim')
DMX.prototype.registerDriver = function(name, module) {
this.drivers[name] = module
2012-09-08 12:43:04 +00:00
}
DMX.prototype.addUniverse = function(name, driver, device_id) {
this.universes[name] = new this.drivers[driver](device_id)
2012-09-08 12:43:04 +00:00
}
DMX.prototype.update = function(universe, channels) {
this.universes[universe].update(channels)
this.emit('update', universe, channels)
}
2012-09-08 12:43:04 +00:00
module.exports = DMX