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,
|
||||
"brightness": 200,
|
||||
"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 fade_ticks = cfg.fade_ticks || 10;
|
||||
const fade_ticks = cfg.fade_ticks || 20;
|
||||
var pixels = new Uint32Array(cfg.leds);
|
||||
var pixel_cache = new Uint32Array(cfg.leds);
|
||||
var next_pattern = new Uint32Array(cfg.leds);
|
||||
|
@ -32,6 +32,7 @@ export function set_pattern(pat) {
|
|||
|
||||
function tick_pattern() {
|
||||
// do the parsing stuff here
|
||||
console.log("TICKING PATTERN")
|
||||
|
||||
for (let i = 0; i < cfg.leds; i++) {
|
||||
var r = Math.floor(Math.random() * 100)
|
||||
|
@ -67,9 +68,14 @@ function fade(index) {
|
|||
var interval_g = diff_g / fade_ticks;
|
||||
var interval_b = diff_b / fade_ticks;
|
||||
|
||||
if (Math.abs(final.r - current.r) < interval_r &&
|
||||
Math.abs(final.g - current.g) < interval_g &&
|
||||
Math.abs(final.b - current.b) < interval_b
|
||||
console.log(`original: ${original.r} ${original.g} ${original.b}` +
|
||||
`current: ${current.r} ${current.g} ${current.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];
|
||||
pixel_cache[index] = next_pattern[index];
|
||||
|
|
Loading…
Reference in a new issue