0

我正在尝试将我的 arduino FastLED 项目的功能分开,并且我想将它们自己放入一个类中。现在这些“模式”,正如我所说的,使用了 FastLED 库的一些功能。

我目前得到的错误是我使用了 FastLED 库的对象的函数CRGB::white,但我得到了错误white is not a member of 'CRGB'。这让我很困惑,因为我能够在主 arduino 文件中使用这种语法,而且我还能够在类中使用库的函数,其语法与主文件中的语法相同。

模式类:

#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.
}

我的猜测是使用不同的语法,但我似乎无法在网上的任何地方找到它......

4

0 回答 0