-
Notifications
You must be signed in to change notification settings - Fork 2
/
ctrl.js
47 lines (36 loc) · 1.01 KB
/
ctrl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var e131 = require('./main.js');
var Controller = function(ip, universe, channels) {
this.client = e131.createClient(ip, 5568, universe);
this.client.UNIVERSE = universe;
this.channels = channels;
this.dmxData = new Array(channels);
}
Controller.prototype.setChannel = function(channel, value) {
this.dmxData[channel - 1] = value;
};
Controller.prototype.send = function() {
this.client.send(this.dmxData);
};
module.exports.Controller = Controller;
var Pixel = function(controller, startChannel) {
this.map = {
red: 0,
green: 1,
blue: 2
};
this.controller = controller;
for (key in this.map) {
this[key] = startChannel + this.map[key];
}
};
Pixel.prototype.setVals = function(values) {
for (key in this.map) {
this.controller.setChannel(this[key], values[key]);
}
};
Pixel.prototype.setAll = function(value) {
for (key in this.map) {
this.controller.setChannel(this[key], value);
}
};
module.exports.Pixel = Pixel;