-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo-artnet.js
58 lines (47 loc) · 1.02 KB
/
demo-artnet.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
const Serialed = require('./serialed.js')
ctrl = new Serialed.SerialedController()
RUN = true
NPIX = 150
ctrl.addNode('artnet://10.42.0.250', NPIX)
/* CHASER FPS
go to next pixel once previous has been drawn
in this exemple speed reflects FPS !
*/
var currentLedFPS = 0
function animChaser_FPS() {
ctrl.on('next', ()=>{
ctrl.clear()
currentLedFPS = (currentLedFPS+1)%NPIX
ctrl.led( currentLedFPS,100,100,100 )
})
}
/* CHASER FIXED
go to next col every 20ms
in this exemple speed is independant to FPS !
*/
var currentLedFIXED = 0
function animChaser_FIXED() {
setTimeout(()=>{
ctrl.clear()
currentLedFIXED = (currentLedFIXED+1)%NPIX
ctrl.led( currentLedFIXED,100,100,100 )
if (RUN) animChaser_FIXED()
}, 40)
}
/* FPS Monitoring
*/
function printFPS() {
setTimeout(()=>{
console.log('FPS', ctrl.fps())
if (RUN) printFPS()
}, 2000)
}
// START
printFPS()
animChaser_FPS()
//animChaser_FIXED()
// PROPERLY CLOSE
process.on('SIGINT', function() {
ctrl.close()
RUN = false
});