octoWS inside a class won't work

Status
Not open for further replies.

Stav

New member
Hey guys!
I'm trying to generalize an API for some led projects using octoWS2811 library and I'm having some problems.
I want to put the octoWS object inside a class so it will be easier to handle, but when I upload and run the code it does not seem to work.

the class definition (BasicLed.h) :

Code:
#include <Arduino.h>
#include "OctoWS2811.h"
#include "FastLED.h"
#include "Defines.h"


static DMAMEM int displayMemory[LEDSPERSTRIP*6];
static int drawingMemory[LEDSPERSTRIP*6];
static const int config = WS2811_GRB | WS2811_800kHz;


class BasicLed{
private:
CRGB fastled[NUMOFPIX];
// octo veriables
OctoWS2811 octo = OctoWS2811(LEDSPERSTRIP, displayMemory, drawingMemory, config);

public: 
BasicLed();
void set_color (u16 index ,u32 color);
void fast2octo();
void show();
static u32 rgb2word(u8 r, u8 g, u8 b);
void clear();

};

first of all for the display & drawing memory, if I dont define them as static I get a duplicate veriable error. I would really like to understand why, I dont declare them anywhere else in the code nor accept them as function inputs.
2nd when I use the BasicLed class and try to light some leds nothing seems to work.

Main.cpp code:

Code:
#include "BasicLed.h"


BasicLed led;

void setup() {
    led.set_color(0,RMASK);
    led.show();
}


void loop() {

}

ocotows.begin() is used in the constructor of the BasicLed class.

Thanks for the help guys!
 
Hi Stav,
I think it would make sense if you added BasicLed.cpp as well.
Do you get a compiler issue that the object are not declared? Or are you just not getting any output on the leds?
 
I have BasicLed.cpp ,the header file is just for declarations and had no compiler error.
I just managed to solve the problem
I moved octo.begin() from the constructor to a function so i will call it inside setup{} instead of calling it when i create the global object.

Now I have a new problem with an inherited class of BasicLed that wont output anything on the leds...
 
Status
Not open for further replies.
Back
Top