-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
23 lines (18 loc) · 759 Bytes
/
index.js
File metadata and controls
23 lines (18 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// eslint-disable-next-line import/no-unresolved
import ledHandler from 'rpi-ws281x';
import allConfig from './config.json';
const config = allConfig.controller.neopixel;
const pixels = new Uint32Array(config.options.leds);
function rgbColor(red, green, blue, orgIntensity) {
// default value for intensity
const intensity = orgIntensity || 1;
// eslint-disable-next-line no-bitwise
return ((red * intensity) << 16) | ((green * intensity) << 8) | (blue * intensity);
}
function initNeopixels() {
// initalize config:
ledHandler.configure(config.options);
// set pixel val:
pixels.forEach((plx, i) => pixels[i] = rgbColor(config.dot2Color.red, config.dot2Color.green, config.dot2Color.blue, config.intensity.buttonOn));
}
initNeopixels();