0

I'm trying to separate my functions of my arduino FastLED project, and I want to put them into a class themselves. Now these "modes", as I call them, use some functions of the FastLED library.

The error I'm currently getting is that I use a function of an object of the FastLED library CRGB::white, but I'm getting the error white is not a member of 'CRGB'. It confuses me since I am able to use this syntax in the main arduino file, and I'm also able to use the functions of the library in the classes, with the same syntax as in the main file.

The mode class:

#include <FastLED.h>

class Mode {
public:
    Mode (CRGB *l)
    {
        leds = l;

        leds[random16(60)] += CRGB::white //Here the compiler gives an error about white not being a member of CRGB
    }
protected:
    CRGB *leds;
};

void setup()
{
    leds[random16(60)] += CRGB::white //While over here it won't give an error.
}

My guess is to use a different syntax, but I can't seem to find it anywhere online...

Joel Spolsky
  • 33,372
  • 17
  • 89
  • 105
  • Did you include 'FastLED/pixeltypes.h', or wherever else 'CRGB::white' is declared in your library, in your '.cpp' file? – Patrick Trentin Feb 04 '17 at 10:04
  • @PatrickTrentin I did not before, tried it, and it didn't fix the problem... – Max Winsemius Feb 04 '17 at 17:34
  • Then, please provide a minimal, reproducible example (see: http://stackoverflow.com/help/mcve ) , that is a complete project. If it is too big to post, and has too many files, upload it on *github* and then edit your question with a link. – Patrick Trentin Feb 04 '17 at 17:40
  • @PatrickTrentin Guess I missed that, sorry, changed now. – Max Winsemius Feb 04 '17 at 17:56
  • are you is it defined in that header? I am not familiar with that project, but it looks like it might be pixeltypes.h – peval27 Feb 04 '17 at 18:03
  • @peval27 It's already included in the FastLED.h file (https://github.com/FastLED/FastLED/blob/master/FastLED.h#L56) – Max Winsemius Feb 04 '17 at 18:33
  • 1
    If you look closely at the definitions inside 'pixeltypes.h' you find out that all enumerated types have an upper case first letter, so it should be 'CRGB::White'. I tested your code on the web arduino editor and, after several fixes, I was able to compile it (so it didn't pass the mcve test ;-), reproduce the error and fix it by changing the name to the proper value. For the records, the compiler complained about 'CFGB::white' in the 'setup() {}' as well. – Patrick Trentin Feb 04 '17 at 21:14
  • @PatrickTrentin I feel very stupid now... I checked back on the reference code and yeah... idk how that once changed... thanks xD – Max Winsemius Feb 04 '17 at 21:19
  • no reason to, it happens even to the best to miss obvious issues and solutions.. it isn't a matter of intelligence, just of perspective. That's why peer communication and team work are so important – Patrick Trentin Feb 04 '17 at 21:26

0 Answers0