FastLED with WS2812B LEDs on Photon

Hi,

i’m trying to compile a slightly modified version of the Noise.ino example in the FastLED library for the Photon board. I’ve the same code up and running on a Teensy 3.1 board, in the Particle Web IDE compilation fails on this line:

FastLED.addLeds<WS2812B,23,RGB>(leds,NUM_LEDS);

When removing it, all compiles fine, when re-inserting it, it fails complaining about not finding a matching template function/call. Is the FastLED version (3.1.4) available in the Web IDE not fully compatible with the stock FastLED library or not fully ported to Particle IDE?

kind regards,

Christoph

Could you post the error message (and the next few too)?

Hi ScruffR,

thank you for your quick response, here are the error messages:

In file included from lacktable.cpp:2:0:
FastLED/FastLED.h:12:2: warning: #warning FastLED version 3001000 (Not really a warning, just telling you here.) [-Wcpp]
 #warning FastLED version 3001000  (Not really a warning, just telling you here.)
  ^
lacktable.cpp: In function 'void setup()':

lacktable.cpp:45:11: error: parse error in template argument list
 
           ^		
		lacktable.cpp:45:48: error: no matching function for call to 'NSFastLED::CFastLED::addLeds(NSFastLED::CRGB [276], int)'
 
                                                ^
	
		lacktable.cpp:45:48: note: candidates are:
In file included from lacktable.cpp:2:0:
FastLED/FastLED.h:165:129: note: template<NSFastLED::ESPIChipsets CHIPSET, unsigned char DATA_PIN, unsigned char CLOCK_PIN, NSFastLED::EOrder RGB_ORDER, unsigned char SPI_DATA_RATE> NSFastLED::CLEDController& NSFastLED::CFastLED::addLeds(NSFastLED::CRGB*, int, int)
  template<ESPIChipsets CHIPSET,  uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER, uint8_t SPI_DATA_RATE > CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
                                                                                                                                 ^
FastLED/FastLED.h:165:129: note:   template argument deduction/substitution failed:

lacktable.cpp:45:48: error: template argument 3 is invalid
 
                                                ^
		In file included from lacktable.cpp:2:0:
FastLED/FastLED.h:177:95: note: template<NSFastLED::ESPIChipsets CHIPSET, unsigned char DATA_PIN, unsigned char CLOCK_PIN> static NSFastLED::CLEDController& NSFastLED::CFastLED::addLeds(NSFastLED::CRGB*, int, int)
  template<ESPIChipsets CHIPSET,  uint8_t DATA_PIN, uint8_t CLOCK_PIN > static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
                                                                                               ^
FastLED/FastLED.h:177:95: note:   template argument deduction/substitution failed:
lacktable.cpp:45:48: error: template argument 3 is invalid
 
                                                ^
In file included from lacktable.cpp:2:0:
FastLED/FastLED.h:189:113: note: template<NSFastLED::ESPIChipsets CHIPSET, unsigned char DATA_PIN, unsigned char CLOCK_PIN, NSFastLED::EOrder RGB_ORDER> static NSFastLED::CLEDController& NSFastLED::CFastLED::addLeds(NSFastLED::CRGB*, int, int)
  template<ESPIChipsets CHIPSET,  uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER > static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
                                                                                                                 ^
FastLED/FastLED.h:189:113: note:   template argument deduction/substitution failed:
lacktable.cpp:45:48: error: template argument 3 is invalid
 
                                                ^
In file included from lacktable.cpp:2:0:
FastLED/FastLED.h:202:56: note: template<NSFastLED::ESPIChipsets CHIPSET> static NSFastLED::CLEDController& NSFastLED::CFastLED::addLeds(NSFastLED::CRGB*, int, int)
  template<ESPIChipsets CHIPSET> static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
                                                        ^
FastLED/FastLED.h:202:56: note:   template argument deduction/substitution failed:
			
lacktable.cpp:45:48: error: wrong number of template arguments (3, should be 1)

kind regards,

Christoph

OK, it is a bit odd and I’m not sure why, but as it seems the default zero for the third parameter is not allowed in this constellation of templates.
I know it works fine for “normal” functions, but my C++ is a bit rusty when it comes to templates.

As a workaround just add the third parameter (0) explicitly, the code will still work on Arduino this way.

BTW: How have you declared your pins in lacktable.cpp?
In the candidates notes the template resolution seems to complain about CLK_PIN not being of either unsigned char nor uint8_t.
Could you also show your code that produces that error?

Hi ScruffR,

i’ve pasted the complete code here:

http://pastebin.com/vARrsH66

i tried adding a zero to the parameters in line 45 with no luck…

kind regards,

Christoph

This line does look wrong

FastLED.addLeds<WS2812B,23,RGB>(leds,NUM_LEDS,0);

As the error notes state the template should be

FastLED.addLeds<WS2812B, DATA_PIN, CLOCK_PIN, RGB>(leds,NUM_LEDS); // or with ,0
// or 
FastLED.addLeds<WS2812B, DATA_PIN, CLOCK_PIN>(leds,NUM_LEDS); // or with ,0
// or just
FastLED.addLeds<WS2812B>(leds,NUM_LEDS); // or with ,0

And what does the 23 stand for? The Photon has no pin 23!

You are also using NUM_LEDS but have the #define statement commented out.

NUM_LEDS is #defined in line 9 as product of kMatrixWidth * kMatrixHeight - where did you see it commented out? Even when i change the data pin to 1 an try the three variants you proposed, i get the same error… i tried the following function calls:

FastLED.addLeds<WS2812B, 1,0, RGB>(leds,NUM_LEDS);
FastLED.addLeds<WS2812B, 1,0>(leds,NUM_LEDS);
FastLED.addLeds<WS2812B>(leds,NUM_LEDS);

kind regards,

Christoph

I see, I had mistaken the green line for a comment and didn’t look close enough :blush:
I’m so used to the Visual Studio color scheme.

Since I can’t see the templates the way you posted the code lines above, it’s a bit hard to tell what you did :wink:
All three lines look exactly the same - after correcting the formatting for you, the “tags” got displayed.

And you have removed the third parameter again.


Could you try this?

const uint8_t pinCLK = D0;
const uint8_t pinDATA = D1; // or const unsigned char

FastLED.addLeds<WS2812B, pinDATA, pinCLK, RGB>(leds, NUM_LEDS, 0);
FastLED.addLeds<WS2812B, pinDATA, pinCLK>(leds, NUM_LEDS, 0);

But the template without pins should at least have given you a different error. Could you have another check if it really was the exact same error with FastLED.addLeds<WS2812B>(leds, NUM_LEDS);? Also try adding the third param there.


OK, I’m trying these too but can’t get it to build either - I’ll report back when I found a way.

OK, forget what I said above :blush:

I had some tests with your code and the original XYMATRIX sample and I figured that your issue seems to come from your RGB template parameter.
If you substitute it with BGR the code builds.

But why the templates without color encoding scheme fail is still not clear to me.


@happenpappen: Yes of course! :flushed: I should have seen that earlier.

The problem with RGB is that in the Particle environment there already is an RGB object for the control of the on-board RGB-LED.
Unfortunately the ambiguity should rather trigger a redef or ambiguity error than a cryptic tamplate argument fail, but I guess this is comes from the template deduction happening before the actual compile.

But if you manually remove the ambiguity by writing it this way

  FastLED.addLeds<WS2812B, D1, EOrder::RGB>(leds, NUM_LEDS);

The whole thing should build.

And as for the puzzle why addLeds<WS2812B>() didn’t work, this must be due to the default use RGB if EOrder is not provided.

Thank you very much for your support! The last hint did the trick. You may see the result of your support here:

This is an Ikea Lack table with integrated a 12x23 WS2812B matrix which now displays the noise example of FastLED. The first version of this table was powered by a Teensy 3.1 without Wifi so to change to another program you had to connect it by USB. The Photon offers much more flexibility to change the program on thy fly.

Thank you again and enjoy your holidays!

kind regards,

Christoph

1 Like

Looks cool :sunglasses:

Freut mich, dass ich helfen konnte!
Jederzeit gerne wieder :+1:

The WS2812B is a great rgb for dev boards as it runs at 5v and in the case of the photon can run directly off of vin if you are supplying usb power or you can split an outside power supply to support both the strip and photon.

Hmm, yes? The point being?