forked from node-dmx/dmx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.js
83 lines (71 loc) · 2.14 KB
/
demo.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const DMX = require('./index');
const dmx = new DMX();
const 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')
// const universe = dmx.addUniverse('demo', 'socketio', null, {port: 17809, debug: true});
const universe = dmx.addUniverse('demo', 'null');
universe.update({1: 1, 2: 0});
universe.update({16: 1, 17: 255});
universe.update({1: 255, 3: 120, 4: 230, 5: 30, 6: 110, 7: 255, 8: 10, 9: 255, 10: 255, 11: 0});
function greenWater(universe, channels, duration) {
const colors = [
[160, 230, 20],
[255, 255, 0],
[110, 255, 10],
];
for (const c in channels) {
const r = Math.floor((Math.random() * colors.length));
const u = {};
for (let i = 0; i < 3; i++) {
u[channels[c] + i] = colors[r][i];
}
new A().add(u, duration).run(universe);
}
setTimeout(function () {greenWater(universe, channels, duration);}, duration * 2);
}
function warp(universe, channel, min, max, duration) {
const a = {}, b = {};
a[channel] = min;
b[channel] = max;
new A().add(a, duration).add(b, duration).run(universe, function () {
warp(universe, channel, min, max, duration);
});
}
warp(universe, 1, 200, 220, 360);
warp(universe, 1 + 15, 200, 255, 240);
greenWater(universe, [3, 6, 9], 4000);
greenWater(universe, [3 + 15, 6 + 15, 9 + 15], 4000);
// function done() { console.log('DONE'); }
//
// const x = new A()
// .add({1: 255, 6: 110, 7: 255, 8: 10}, 1200)
// .delay(1000)
// .add({1: 0}, 600)
// .add({1: 255}, 600)
// .add({5: 255, 6: 128}, 1000)
// .add({1: 0}, 100)
// .add({1: 255}, 100)
// .add({1: 0}, 200)
// .add({1: 255}, 200)
// .add({1: 0}, 100)
// .add({1: 255}, 100)
// .add({1: 0})
// .delay(50)
// .add({1: 255})
// .delay(50)
// .add({1: 0})
// .delay(50)
// .add({1: 255})
// .delay(50)
// .add({1: 0})
// .delay(50)
// .add({1: 255})
// .delay(50)
// .add({2: 255}, 6000)
// .delay(200)
// .add({2: 0});
// const y = new A()
// .add({9: 255}, 10000);
// x.run(universe, done);
// y.run(universe, done);