Skip to content
Snippets Groups Projects
Commit c7c0764b authored by supsup's avatar supsup
Browse files

Update random-color-pixel-strip.html

parent adb3063e
No related branches found
No related tags found
No related merge requests found
...@@ -57,7 +57,10 @@ ...@@ -57,7 +57,10 @@
} }
// Set Default Black Color. // Set Default Black Color.
var color = {r:0,b:0,g:0}; var defaultColor = {r:0,b:0,g:0};
// Set Queue Speed, default is 3 seconds.
var speed = 3000;
// Set all pixels to a given color // Set all pixels to a given color
function writeFrame(red, green, blue) { function writeFrame(red, green, blue) {
...@@ -91,7 +94,7 @@ ...@@ -91,7 +94,7 @@
for (var led = 0; led < leds; led++) { for (var led = 0; led < leds; led++) {
//protection against null from random color. //protection against null from random color.
myObj === null ? myObj = {r:0,b:0,g:0} : myObj; myObj === null ? myObj = defaultColor : myObj;
packet[dest++] = myObj.r; packet[dest++] = myObj.r;
packet[dest++] = myObj.g; packet[dest++] = myObj.g;
...@@ -107,14 +110,12 @@ ...@@ -107,14 +110,12 @@
// Animation loop // Animation loop
var animate = function() { var animate = function() {
// Get time delta
writeFrame( writeFrame(
color.r, defaultColor.r,
color.g, defaultColor.g,
color.b); defaultColor.b);
setTimeout(animate, 3000); setTimeout(animate, speed);
} }
// Connect to a Fadecandy server running on the same computer, on the default port // Connect to a Fadecandy server running on the same computer, on the default port
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment