Library for using addressable LEDs (such as NeoPixels/WS2812) with Firmata and JohnnyFive
dependabot[bot] on npm_and_yarn
chore: bump sinon from 13.0.2 t… (compare)
dependabot[bot] on npm_and_yarn
dependabot[bot] on master
chore: bump eslint from 8.14.0 … Merge pull request #305 from aj… (compare)
dependabot[bot] on npm_and_yarn
dependabot[bot] on npm_and_yarn
chore: bump eslint from 8.14.0 … (compare)
dependabot[bot] on npm_and_yarn
chore: bump eslint from 8.14.0 … (compare)
range
intermediary there because I think API wise there's a bunch of things we could do on a range for example shifting and cycling across a range of pixels as you sort of do on a Strip
already
I just spent the weekend installing LED bling into my kitchen. Maybe a little bit to the dismay of fiancé - but hey she knew that this was part of the deal when she met me :p! ANYWAY!
The setup is a strip of approximately 300 SK6812 RGBW LEDS, controlled by an Arduino MEGA (so i wouldn’t have to worry about memory constraints).
It already looks pretty good (native Adafruit RGBW test sketch)!
http://imgur.com/Ezx08bs
I’m a web dev by day, which means i have grand plans for controlling the setup remotely. Web control, native app, wifi switches - the works. And it turns out that there’s a bit of groundwork to do.
node-pixel needs me (or someone) to:
And while i’m at it, add back the interchange configuration option (ajfisher/node-pixel#93) - I have a MEGA, what even is small memory capacity? ;)
I’m a newbie (one day into it now) to the world of microcontrollers, interchange, backpacks, loading firmware. Send me your un-newbie-ifying reading recommendations please! In saying that, I won’t be doing anything quickly, and I will be asking for help.
So, hI! And be speaking to you guys soon!
nvm you probably can't fix that until you pad out the white channel. You could potentially hack that in the firmware to simply pad that byte with a zero for the moment.
In theory if you bump this to 4
it should pad out the last byte as well.
https://github.com/ajfisher/node-pixel/blob/master/firmware/src/libs/ws2812/ws2812.cpp#L15
No probs! I'm enjoying it! I'll try to implement it nicely tonight if I have time (instead of hacking it in) and send you a pull request. But i might resort to the hack on account of not really understanding a great deal of what I'm doing.
I was thinking of comparing the latest adafruit library and porting across node-pixel again to update it. I wouldn't mind the setBrightness() method. Although I'm sure it's not included already for a good reason.
@ajfisher Hi again! So I got my hands on a nano and followed the "I2C Backpack Installation" by installing the Arduino IDE, then uploading the backpack.ino (found in nedo-pixel/firmware/build/backpack). Then I ran the johnnyfive-i2c.js from the examples folder. Here is what I get:
1502418425559 Available /dev/ttyUSB0
1502418425611 Connected /dev/ttyUSB0
1502418435621 Device or Firmware Error A timeout occurred while connecting to the Board.
Please check that you've properly flashed the board with the correct firmware.
See: https://github.com/rwaldron/johnny-five/wiki/Getting-Started#trouble-shooting
If connecting to a Leonardo or Leonardo clone, press the 'Reset' button on the board, wait approximately 11 seconds for complete reset, then run your program again.
events.js:165
throw err;
^
Error: Uncaught, unspecified "error" event. ([object Object])
at Board.emit (events.js:163:17)
at Board.log (/home/pi/Workspace/neoPixelTest/node-pixel/node_modules/johnny-five/lib/board.js:635:8)
at Board.(anonymous function) [as error] (/home/pi/Workspace/neoPixelTest/node-pixel/node_modules/johnny-five/lib/board.js:646:14)
at Board.<anonymous> (/home/pi/Workspace/neoPixelTest/node-pixel/node_modules/johnny-five/lib/board.js:390:14)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5)
I found a similar post in the issue list which dealing with the Frimata on an Uno and not the backpack. Could you please help us?
strip.off()
command
var strip_off = function()
{
console.log("[J5]:Led Stop called");
var led_counter = 0;
if(rainbow_timer != null) {
stop_loop = "true";
clearInterval(rainbow_timer);
rainbow_timer.unref();
}
for (;led_counter < LED_COUNT; ++led_counter)
strip.pixel(led_counter).color("#000000");
//strip.off();
strip.show();
board.io.reset();
}
function dynamicRainbow( delay ){
console.log( 'dynamicRainbow' );
var showColor;
var cwi = 0; // colour wheel index (current position on colour wheel)
rainbow_timer = setInterval(function(){
console.log("Changing now!");
if (++cwi > 255) {
cwi = 0;
}
for(var i = 0; i < strip.length; i++) {
showColor = colorWheel( ( cwi+i ) & 255 );
strip.pixel( i ).color( showColor );
}
strip.show();
}, 1000/delay);
}
// Input a value 0 to 255 to get a color value.
// The colors are a transition r - g - b - back to r.
function colorWheel( WheelPos ){
var r,g,b;
WheelPos = 255 - WheelPos;
if ( WheelPos < 85 ) {
r = 255 - WheelPos * 3;
g = 0;
b = WheelPos * 3;
} else if (WheelPos < 170) {
WheelPos -= 85;
r = 0;
g = WheelPos * 3;
b = 255 - WheelPos * 3;
} else {
WheelPos -= 170;
r = WheelPos * 3;
g = 255 - WheelPos * 3;
b = 0;
}
// returns a string with the rgb value to be used as the parameter
return "rgb(" + r +"," + g + "," + b + ")";
}
var strip_off = function()
{
console.log("[J5]:Led Stop called");
var led_counter = 0;
if(rainbow_timer != null) {
stop_loop = "true";
clearInterval(rainbow_timer);
rainbow_timer.unref();
}
for (;led_counter < LED_COUNT; ++led_counter)
strip.pixel(led_counter).color("#000000");
//strip.off();
strip.show();
board.io.reset();
}
function dynamicRainbow( delay ){
console.log( 'dynamicRainbow' );
var showColor;
var cwi = 0; // colour wheel index (current position on colour wheel)
rainbow_timer = setInterval(function(){
console.log("Changing now!");
if (++cwi > 255) {
cwi = 0;
}
for(var i = 0; i < strip.length; i++) {
showColor = colorWheel( ( cwi+i ) & 255 );
strip.pixel( i ).color( showColor );
}
strip.show();
}, 1000/delay);
}
// Input a value 0 to 255 to get a color value.
// The colors are a transition r - g - b - back to r.
function colorWheel( WheelPos ){
var r,g,b;
WheelPos = 255 - WheelPos;
if ( WheelPos < 85 ) {
r = 255 - WheelPos * 3;
g = 0;
b = WheelPos * 3;
} else if (WheelPos < 170) {
WheelPos -= 85;
r = 0;
g = WheelPos * 3;
b = 255 - WheelPos * 3;
} else {
WheelPos -= 170;
r = WheelPos * 3;
g = 255 - WheelPos * 3;
b = 0;
}
// returns a string with the rgb value to be used as the parameter
return "rgb(" + r +"," + g + "," + b + ")";
}
board.on("ready", function() {
console.log("Board ready, lets add light");
strip = new pixel.Strip({
data: 6,
length: LED_COUNT,
color_order: pixel.COLOR_ORDER.GRB,
board: this,
controller: "FIRMATA",
});
strip.on("ready", function() {
console.log("Strip ready, let's go");
var colors = ["red", "green", "blue", "yellow", "cyan", "magenta", "white"];
//var current_colors = [0,1,2,3,4];
var current_pos = [0,1,2,3,4];
current_pos.forEach((pos) => {
strip.pixel(pos).color(colors[pos]);
});
strip.show();
/*current_pos.forEach((pos) => {
strip.pixel(pos).color("#000
000");
});
strip.show();
var blinker = setInterval(function() {
strip.shift(1, pixel.FORWARD, true);
strip.show();
}, 1000/fps);*/
});
this.repl.inject({
strip: strip
});
});
exports.strip=strip;
exports.board=board;
exports.strip_on=strip_on;
exports.strip_off=strip_off;
exports.dynamicRainbow=dynamicRainbow;
will a 144 led WS2812B strip be supported in firmata mode
Yes - you can have about 200 pixels