i am trying to write a class for an arduino projekt, i am using the information in http://paulmurraycbr.github.io/ArduinoTheOOWay.html as a guide.
I want to set up a lighstrip for further use and constantly keep getting the errormessage: error: use of 'this' in a constant expression.
My code looks like this:
#include <FastLED.h>
#define LED_STRIP_PIN 2
#define LED_STRIP_NUM_LEDS 10
//const unsigned char LED_STRIP_PIN = 2;
//const int LED_STRIP_NUM_LEDS = 10;
CRGB leds[LED_STRIP_NUM_LEDS];
class LedStrip {
unsigned char pin;
public:
LedStrip(unsigned char attachTo) :
pin(attachTo)
{
};
void setup() {
FastLED.addLeds<NEOPIXEL, pin>(leds, 10);
};
};
//LedStrip ledstrip(LED_STRIP_PIN, LED_STRIP_NUM_LEDS);
LedStrip ledstrip(LED_STRIP_PIN);
void setup() {
}
void loop() {
}
I have tried reading up on what might cause this error, but frankly i do not understand any of it. As far as i have understood it seems like i cannot use a const there (which i am not, i think) since it might be modified during code execution.
the complete error looks like thissketch_feb03b.ino: In member function 'void LedStrip::setup()':
sketch_feb03b:20:33: error: use of 'this' in a constant expression
FastLED.addLeds<NEOPIXEL, pin>(leds, 10);
^~~