Compare commits
1 commit
6110039314
...
54f1b959f0
Author | SHA1 | Date | |
---|---|---|---|
54f1b959f0 |
2 changed files with 12 additions and 5 deletions
|
@ -2,5 +2,6 @@
|
||||||
"leds": 450,
|
"leds": 450,
|
||||||
"brightness": 200,
|
"brightness": 200,
|
||||||
"gpio": 18,
|
"gpio": 18,
|
||||||
"type": "grb"
|
"type": "grb",
|
||||||
|
"fade_ticks": 25
|
||||||
}
|
}
|
14
lights.js
14
lights.js
|
@ -3,7 +3,7 @@ import * as fs from 'fs'
|
||||||
|
|
||||||
const cfg = JSON.parse(fs.readFileSync('./config.json'));
|
const cfg = JSON.parse(fs.readFileSync('./config.json'));
|
||||||
|
|
||||||
const fade_ticks = cfg.fade_ticks || 10;
|
const fade_ticks = cfg.fade_ticks || 20;
|
||||||
var pixels = new Uint32Array(cfg.leds);
|
var pixels = new Uint32Array(cfg.leds);
|
||||||
var pixel_cache = new Uint32Array(cfg.leds);
|
var pixel_cache = new Uint32Array(cfg.leds);
|
||||||
var next_pattern = new Uint32Array(cfg.leds);
|
var next_pattern = new Uint32Array(cfg.leds);
|
||||||
|
@ -32,6 +32,7 @@ export function set_pattern(pat) {
|
||||||
|
|
||||||
function tick_pattern() {
|
function tick_pattern() {
|
||||||
// do the parsing stuff here
|
// do the parsing stuff here
|
||||||
|
console.log("TICKING PATTERN")
|
||||||
|
|
||||||
for (let i = 0; i < cfg.leds; i++) {
|
for (let i = 0; i < cfg.leds; i++) {
|
||||||
var r = Math.floor(Math.random() * 100)
|
var r = Math.floor(Math.random() * 100)
|
||||||
|
@ -67,9 +68,14 @@ function fade(index) {
|
||||||
var interval_g = diff_g / fade_ticks;
|
var interval_g = diff_g / fade_ticks;
|
||||||
var interval_b = diff_b / fade_ticks;
|
var interval_b = diff_b / fade_ticks;
|
||||||
|
|
||||||
if (Math.abs(final.r - current.r) < interval_r &&
|
console.log(`original: ${original.r} ${original.g} ${original.b}` +
|
||||||
Math.abs(final.g - current.g) < interval_g &&
|
`current: ${current.r} ${current.g} ${current.b}` +
|
||||||
Math.abs(final.b - current.b) < interval_b
|
`final: ${final.r} ${final.g} ${final.b}` +
|
||||||
|
`interval: ${interval_r} ${interval_g} ${interval_b}`)
|
||||||
|
|
||||||
|
if (final.r - current.r < interval_r &&
|
||||||
|
final.g - current.g < interval_g &&
|
||||||
|
final.b - current.b < interval_b
|
||||||
) {
|
) {
|
||||||
pixels[index] = next_pattern[index];
|
pixels[index] = next_pattern[index];
|
||||||
pixel_cache[index] = next_pattern[index];
|
pixel_cache[index] = next_pattern[index];
|
||||||
|
|
Loading…
Reference in a new issue