-
Notifications
You must be signed in to change notification settings - Fork 3
/
lightKnot.js
executable file
·75 lines (58 loc) · 1.49 KB
/
lightKnot.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
#!/usr/local/bin/node
/*
*
* todo
* - prio buffers allways have transparency
* - completely disconnect wall drawing from bufferupdates (async)
* - throttle all connections to max wall speed
*
*
*
*
*
*
*
*
*
*/
var fs = require('fs');
var myFile = process.argv[1];
fs.watch(myFile, function (event, filename) {
console.log('file event : terminate ' + event);
process.exit(0);
});
process.on('uncaughtException', function (err) {
console.log('uncaught exception: '+ err)
console.log(err.stack);
});
var wall = require('./wall.js');
var wallConn = require('./wallConnection.js');
{
var serialDevice1 = '/dev/cu.usbserial-A8008I0K';
//var serialDevice1 = '/dev/cu.usbserial-A100DDXG';
//var serialDevice = '/dev/cu.usbserial-A8008I0K';
var hardwareAvailable = true;
try{
var stats = fs.lstatSync(serialDevice1);
console.log("running with hardware");
// fs.watch(serialDevice1, function (event, filename) {
// console.log('file event2 : terminate ' + event);
// process.exit(0);
// });
} catch(e) {
hardwareAvailable = false;
console.log("running without hardware");
setInterval(function(){
fs.lstat(serialDevice1,function(err,stats){
if(stats && stats.dev)
{
console.log('restart a');
process.exit(0);
}
});
},5000);
}
var connectionCeil = new wallConn.newConn(hardwareAvailable,serialDevice1,500000);
var pentawallHD = wall.newWall('PentawallHD',connectionCeil);
// var ceilingLED = wall.newWall('CeilingLED',connectionCeil);
}