-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (26 loc) · 852 Bytes
/
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
import { WSconnection } from './modules/webSocket';
import { loginSession, websocketAnswer } from './modules/maRemote';
import { initNeopixels, setAllPixels } from './modules/neopixel';
import { initEncoder, readEncoder, readEncoderSwitch } from './modules/encoder';
initEncoder();
setInterval(() => {
const test = readEncoder();
if (test) console.log(test);
const test2 = readEncoderSwitch();
if (test2 !== null) console.log(test2);
}, 1);
// init neopixel
initNeopixels();
// setAllPixels();
// open websocket
WSconnection.onopen = () => {
// setAllPixels(0);
loginSession();
};
// websocket emitter
WSconnection.onmessage = (msg) => websocketAnswer(msg);
WSconnection.onerror = (error) => console.log(`WebSocket error: ${error}`);
WSconnection.onclose = () => {
console.error('Disconnected! Exiting...');
process.exit(1);
};