leds/index.js

17 lines
337 B
JavaScript
Raw Normal View History

import * as server from './server.js';
2021-05-26 01:55:56 +00:00
import * as lights from './lights.js';
2021-05-26 22:28:52 +00:00
const cfg = JSON.parse(fs.readFileSync('./config.json'));
2021-05-26 00:32:56 +00:00
server.recv(
2021-05-26 01:55:56 +00:00
(res) => {
2021-05-26 03:18:02 +00:00
lights.set_pattern(JSON.parse(res));
2021-05-26 01:55:56 +00:00
},
(res) => {
console.log(`error callback: ${res}`);
}
);
2021-05-26 03:30:42 +00:00
2021-05-26 22:28:52 +00:00
setInterval(() => {
2021-05-26 03:30:42 +00:00
lights.tick();
2021-05-26 22:28:52 +00:00
}, cfg.sleep_time || 500);