-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
66 lines (58 loc) · 1.3 KB
/
index.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"use strict";
var ws = require('ws');
var wss;
global.nervousTimer = require('./nervous-timer');
global.XorShift = require('./xorshift');
global.Peatix = {};
// Monkey patch to ignore LocalStorage related codes.
global.ColorSyncClientAndroid = {
connect: function(to){
wss = new ws(to);
wss.on('message', function (msg) {
csc.__onMessage({data: msg});
});
wss.on('close', function() {
});
wss.on('open', function () {
setTimeout( function () {
csc.startClockSync();
},1000);
});
},
send: function(msg){
wss.send(msg);
},
setValue: function(){},
getValue: function(){},
deleteKey: function(){}
};
var CS = require('./colorsync-client.js');
var csc;
var server = process.argv[2];
var token = process.argv[3];
var universe = process.argv[4];
var channel = parseInt(process.argv[5]);
csc = new CS({
server: server,
token: token
});
var dmxlen = 1;
function r (){return Math.random();}
var dmxpro = require('dmxpro');
var dmx = dmxpro.alloc();
console.log(dmxpro);
dmxpro.init(dmx, {
colourspace: 'rgb',
fixtures: [{
id: 1,
map: {
red: channel,
green: channel + 1,
blue: channel + 2
}
}]
});
global.colorsync = function (col) {
console.log(col);
dmxpro.color(dmx, universe, col.r/255, col.g/255, col.b/255);
};