Skip to content

Commit

Permalink
lamp now changes with rainbow
Browse files Browse the repository at this point in the history
  • Loading branch information
DatNoHand committed Sep 18, 2018
1 parent 2d0997b commit 86dd87d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions server/public/js/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ function Start() {

setBg(msg.favorites)
break;
case 'color':
led_color = msg.color;
$('div.colorreference').css({'background-color': color});
Lamp(true);
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion server/rpi-led-library.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ exports.render = () => {
}
strip.render(exports.pixel_data);
exports.event.emit('render');

return true
}

Expand Down
8 changes: 6 additions & 2 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,21 @@ async function l_rainbow_factory(delay = 50) {
shouldLoop = true;

while (shouldLoop) {
await l_rainbow(shift++);
let color = await l_rainbow(shift++);
SendToEveryone({type: 'color', color: color});
await sleep(delay).catch((e) => {});
}

}

async function l_rainbow(shift = 0) {
let color;
for (let i = 0; i < LedLib.num_leds; i++) {
LedLib.setLed(i, wheel(parseInt((i+shift) * 256 / LedLib.num_leds) & 255).string());
color = wheel(parseInt((i+shift) * 256 / LedLib.num_leds) & 255).string();
LedLib.setLed(i, color);
}
LedLib.render();
return color;
}

function sleep(ms){
Expand Down

0 comments on commit 86dd87d

Please sign in to comment.