Adafruit Neopixel Library [PORTED]


#61

Hi @shocku992 most of the flickering problems have cleared up from what I know… what strip do you have, and how many pins are on your exact pixels… not the ones in the adafruit pictures. How many pixels are you running? Do you have a 3.3V to 5V level converter that you could try? (the Shield Shield has these on-board) or adafruit/sparkfun sell some nice ones that are I2C safe (good for stepping up from 3.3V to 5V)


#62

It’s a WS2812B, they are 3 pins each. I’m running 60 pixels. I don’t have a level converter, but I hooked up the power and ground to the 5v on my Arduino Uno that is sitting beside it. It doesn’t seem to make a difference. Maybe I’ll hook the data up to it as well and see if it has any flickering problems.


#63

WS2812B should be 4 pins per LED right? GND, VCC, DIN, DOUT

WS2812B has been tested a few times with no complaints of flickering… but the timing is slightly different than what I have here, however it’s within the tolerance of the WS2812 which is why up til now it’s worked. Did you buy yours from adafruit? I need to get some neopixel strip for another project, so I’ll try to buy whatever you have so I can code and test WS2812B’s. I could also tweak the timing and have you try that probably sooner than I can get a strip myself. Will probably be a few days though.


#64

Whoops, I may have been misinformed. The ones I got our 3 pins. GND, VCC, Data. I thought these were the same ones as the neopixels.

Here are the ones I bought:
Ebay

And here are the ones on Adafruit:
Neopixels

BDub, has anyone ever told you how awesome you are!? Thank you so much


#65

I think you’ve told me a few times now :blush: thanks!

So I think you have a case of the fleabays… the auction title says WS2812B, but the picture shows a 6 pin LED which suggests WS2812. However in the description they say WS2811 chipset! So which one is it? Looking at their software recommendation (FastSPI Library) I would say it’s ether WS2801 or WS2811. BUT they recommend setting the chipset to TM1804! WTF!? grrrr.

I just so happen to have a library for the WS2801 here: https://gist.github.com/technobly/8339548

If it’s WS2811 we’ll have to create the right timing for 800kHz mode and add it to the WS2812/B NeoPixel library.

But if it’s really TM1804 then you need the RadioShack Strip timing… I think:
https://gist.github.com/technobly/8469105

EDIT: I guess the RS Strip is TM1803, and TM1804 has these specs for timing:
These strips incorporate TM1804 chips by Titan Micro (one for each RGB LED) and 24-bit color data is shifted into them using very quick pulses (~1300ns=Digital_1 and ~700ns=Digital_0) which I think is opposite in pulse width from the RS Strip library I have…

Another thing that annoys me, is that nobody comments in the code what the effing timing is for bit high and bit low… seriously?? you do all that work writing assembly code and multiple support for various strips and you don’t include the timing info??? :rage1:

Try them all! :smile:


#66

I don’t know if this makes a difference, but I just tried the LED’s on my regular Arduino Uno and they worked great at they standard 800KHz. No flicker or anything.

I tried all the libraries last night with little success.The Neopixel library seemed to work the best. I just had the flicker.


#67

Yes that helps! At least I’ll have something to measure and check the timing of. Thanks! I’ll let you know when I have something you can try.


#68

Is it possible to split the Neopixel library into .h and .ccp file?
Looks like the web ide supports multiple .h files now?


#69

Yes, very possible :slight_smile: I have a lot of libraries to convert this way, and have to replace the CCFL bulb on a laptop first! Sometime today I’ll work on it :wink:


#70

Has anyone already seen this library? http://fastled.io
Maybe it’s also worth looking into it.


#71

just took a look at the Fast Led library and it seems very powerul and I think would be a great addition. There is already one issue opened 5 days ago on their github to port it to Spark so will see if any response comes.


#72

First of all thx @technobly, you seem to have created the lib I am looking for.

I still have a few questions - it would be great of someone could answer these:

  • can I drive around 20 of these Neopixel Rings with this library? I would assume I have to match the RGB leds of each ring myself, but I should be able to address the RGBs easily with the library, right?

  • how exactly is the library being used as part of Spark Build. Do I just copy the content to a new file in the project or how does one include the lib (in Arduino I would go to “Add library…”

Thx!
Sven


#73

If you string all of the rings together in Daisy Chain fashion (output of first to input of the next) it should work. Right now I don’t know what the limit is for WS2812 leds. I’ve tested the library with 500 leds defined and it worked great. I didn’t have 500 attached… but the ones I did have were lit up perfectly. The neopixels themselves regenerate the timing for the next pixel in the line so I’m assuming it would work for 1000 leds.

Let us know how it works out for ya Sven! :wink:


#74

Hi, just gave it a try. Not running right now, but I assume it’s a noob issue. I’ve clicked the + in the ide to createa a .h and .cpp file, then I copied the contents from the github file accordingly.

In the main spark .cpp file I have this content now:


#include “Adafruit_NeoPixel.h”

Adafruit_NeoPixel strip = Adafruit_NeoPixel(64, D0);

void setup() {
strip.begin();
strip.show(); // Initialize all pixels to ‘off’
}

void loop() {
colorWipe(strip.Color(255, 0, 0), 50); // Red
}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}


Unfortunately there seems to be a compile issue:

Adafruit_NeoPixel.cpp:142:10: error: ‘Adafruit_NeoPixel’ has not been declared
Adafruit_NeoPixel.cpp:147:10: error: ‘Adafruit_NeoPixel’ has not been declared
Adafruit_NeoPixel.cpp:147:55: error: non-member function ‘uint32_t getPixelColor(uint16_t)’ cannot have cv-qualifier
Adafruit_NeoPixel.cpp: In function ‘uint32_t getPixelColor(uint16_t)’:
Adafruit_NeoPixel.cpp:149:10: error: ‘numLEDs’ was not declared in this scope
Adafruit_NeoPixel.cpp:151:23: error: ‘pixels’ was not declared in this scope
Adafruit_NeoPixel.cpp: At global scope:
Adafruit_NeoPixel.cpp:159:10: error: ‘Adafruit_NeoPixel’ has not been declared
Adafruit_NeoPixel.cpp:159:45: error: non-member function ‘uint8_t* getPixels()’ cannot have cv-qualifier
Adafruit_NeoPixel.cpp: In function ‘uint8_t* getPixels()’:
Adafruit_NeoPixel.cpp:160:10: error: ‘pixels’ was not declared in this scope
Adafruit_NeoPixel.cpp: At global scope:
Adafruit_NeoPixel.cpp:163:10: error: ‘Adafruit_NeoPixel’ has not been declared
Adafruit_NeoPixel.cpp:163:45: error: non-member function ‘uint16_t numPixels()’ cannot have cv-qualifier
Adafruit_NeoPixel.cpp: In function ‘uint16_t numPixels()’:
Adafruit_NeoPixel.cpp:164:10: error: ‘numLEDs’ was not declared in this scope
Adafruit_NeoPixel.cpp: At global scope:
Adafruit_NeoPixel.cpp:179:6: error: ‘Adafruit_NeoPixel’ has not been declared
Adafruit_NeoPixel.cpp: In function ‘void setBrightness(uint8_t)’:
Adafruit_NeoPixel.cpp:187:23: error: ‘brightness’ was not declared in this scope
Adafruit_NeoPixel.cpp:190:30: error: ‘pixels’ was not declared in this scope
Adafruit_NeoPixel.cpp:196:25: error: ‘numBytes’ was not declared in this scope
Adafruit_NeoPixel.cpp: At global scope:
Adafruit_NeoPixel.cpp:211:1: error: ‘Adafruit_NeoPixel’ does not name a type
Adafruit_NeoPixel.cpp: In function ‘void setup()’:
Adafruit_NeoPixel.cpp:214:3: error: ‘strip’ was not declared in this scope
Adafruit_NeoPixel.cpp: In function ‘void colorAll(uint32_t, uint8_t)’:
Adafruit_NeoPixel.cpp:242:14: error: ‘strip’ was not declared in this scope
Adafruit_NeoPixel.cpp:245:3: error: ‘strip’ was not declared in this scope
Adafruit_NeoPixel.cpp: In function ‘void colorWipe(uint32_t, uint8_t)’:
Adafruit_NeoPixel.cpp:251:23: error: ‘strip’ was not declared in this scope
Adafruit_NeoPixel.cpp: In function ‘void rainbow(uint8_t)’:
Adafruit_NeoPixel.cpp:262:16: error: ‘strip’ was not declared in this scope
Adafruit_NeoPixel.cpp:265:5: error: ‘strip’ was not declared in this scope
Adafruit_NeoPixel.cpp: In function ‘void rainbowCycle(uint8_t)’:
Adafruit_NeoPixel.cpp:275:17: error: ‘strip’ was not declared in this scope
Adafruit_NeoPixel.cpp:278:5: error: ‘strip’ was not declared in this scope
Adafruit_NeoPixel.cpp: In function ‘uint32_t Wheel(byte)’:
Adafruit_NeoPixel.cpp:287:11: error: ‘strip’ was not declared in this scope
Adafruit_NeoPixel.cpp:290:11: error: ‘strip’ was not declared in this scope
Adafruit_NeoPixel.cpp:293:11: error: ‘strip’ was not declared in this scope
Adafruit_NeoPixel.cpp:295:1: warning: control reaches end of non-void function [-Wreturn-type]
Adafruit_NeoPixel.cpp: In function ‘uint16_t numPixels()’:
Adafruit_NeoPixel.cpp:165:1: warning: control reaches end of non-void function [-Wreturn-type]
Adafruit_NeoPixel.cpp: In function ‘uint8_t* getPixels()’:
Adafruit_NeoPixel.cpp:161:1: warning: control reaches end of non-void function [-Wreturn-type]
make: *** [Adafruit_NeoPixel.o] Error 1

So -I guess I am fighting with the IDE. It does not seem to include the library. Any ideas?


#75

all right, it works. I was confused by the fact that all files are in one. But one really can copy them all into one big editor screen.

So the rainbow is on by default. Only tiny issue is that some LEDs seem to be flickering. I am not sure why, but the rainbow is not 100% smooth for example. Is that a timing issue?

I have 64 RGB LEDs on that RGB123 board - and I intend to connect 16x12=192 in total. I am a bit worried if it starts running into issues at 30-40 LEDs already. Have you tried this with larger RGB boards?


#76

hansamann, I just split the file in three on the Web IDE and it compiled just fine. The catch is that your need to add #include "Adafruit_Neopixel.h" at the top of the Adafruit_Neopixel.cpp file. This was not in the “single” file because it was not needed.

:smiley:


#77

Strange, it does not work for me.

I click the + to add a .h.and .cpp file, then correctly add the parts to each file and finally make sure the #include is in. This works even automatically:

// This #include statement was automatically added by the Spark IDE.
#include “Adafruit_Neopixel.h”

Nope, I get tons of compile issues. Any idea?


#78

@hansamann I’m guessing you have the WS2812B pixels which have 4 pins on them instead of the WS2812 which has 6 pins. The 12B is slightly different in timing, but should work. I have an action item to review the timing of the Adafruit library, which is looks like the RGB123 boards use. I just haven’t had time to set it all up again. Been so busy. Also need to break out the files as separate .cpp and .h, but for now just use it as one big file and it should work great (minus the flickering issue).

If anyone wants to beat me to the punch and tell me adafruit’s specific timing, please do… but post here and @BDub me before you start so we don’t do the same work! :smile:


#79

Did you make sure you have the include in BOTH .cpp files?


#80

@mippen @hansamann the library files have been separated now. Compiles fine for me, please test for me if you would. I will work on glitch issue when I get time :smile:

https://github.com/technobly/SparkCore-NeoPixel