Hi there, I'm trying to implement a display that houses 4 nested led strips

Hi there,

I’m trying to implement a display that houses 4 nested led strips and use an arduino to create a few animation effects. I’m using an Uno r3 with Arduino 1.6 connecting into a DMX receiver.

The issue I’m having is in trying to call different functions and passing through pointers to FastLED color structs.

Here is the most basic of cases. Within an animation, I aim to blend two colors in a slow progression. The loop calls the colorBlend function to update LED strip’s color once that is done, it send the instructions out to the strip through DMX. Here’s the code:

Code: [Select]

#include <FastLED.h>
#include <DmxMaster.h>

#define numStrips 4
int step = 128;
int led1Strip = 0;
int channelArray[numStrips][3];

CRGB strip1Color; //empty container that gets updated each time with new blend color

CHSV baseColor = CHSV(45, 98, 95);
CHSV newColor = CHSV(208, 98, 55);

void setup() {
pinMode(dmxPin, OUTPUT);
DmxMaster.usePin(3);
DmxMaster.maxChannel(12);
}

void loop() {
// this function call is housed in a loop that steps through the blend, but only the call is important
colorBlend(&strip1Color, &baseColor, &newColor, step);
sendDMX(led1Strip, &strip1Color);

}

void colorBlend(struct CRGB *arrToChange[], struct CHSV *color1[], struct CHSV *color2[], int perc) {
arrToChange = blend(color1, color2, perc); //the blend funciton from FastLED
}

void sendDMX(int theStrip, struct CRGB *theColor) {
for(int z=0; z<3; z++) { //loop to send instructions to each of 3 channels, one for R, G, & B
DmxMaster.write(channelArray[theStrip][z], theColor[z]);
}
}

From this I get a number of errors stemming from passing the pointers:

cannot convert ‘CRGB*’ to ‘CRGB*’ for argument ‘1’ to ‘void colorBlend(CRGB*, CHSV*, CHSV*, int)’

invalid user-defined conversion from ‘CHSV**’ to ‘const CRGB&’ [-fpermissive]

candidate is: CRGB::CRGB(uint32_t)
no known conversion for argument 1 from ‘CHSV**’ to ‘uint32_t {aka long unsigned int}’

Any help would be greatly appreciated. I’m still unsure about how to use pointers properly. My intent is to pass the pointers to the ‘strip1Color’ struct (I believe it is a struct) which gets updated with a blended color between two other colors structs (baseColor & newColor), the pointers to which have also been passed with a value with the point to blend between the two colors (step: between 0-255).

strip1Color’s type is CRGB - aka, it is a single CRGB object. However, the first parameter to colorBlend is a pointer to an array of CRGB objects (also, the types are CRGB and CHSV, not struct CRGB and struct CHSV). Also, blend takes references to CRGB objects - and you are attempting to pass it pointers to CRGB and CHSV objects.

void colorBlend( CRGB & colorToChange, const CHSV & color1, const CHSV & color2, uint8_t step) {
colorToChange = blend(color1, color2, step);
}

and then call it like this:

colorBlend(strip1Color, baseColor, newColor, step);

In fact, i’m not entirely sure why you have the colorBlend function - you should just replace your call to colorBlend with:

strip1Color = blend(baseColor, newColor, step);

Much appreciated, I’ll give it a try tonight.

In reading the various FastLED files, I assumed CRGB and CHSV were structs as I found references to “struct CRGB” in a number of files in declarations and function calls. So thank you for the clarity. And I can never get pointers and references straight.

The reason I had a colorBlend function isolated was building it as a ready function for other animations and having a function that could do other things too, blend() being one of them . But you’re probably right, it doesn’t save anything to just have the straight blend() call whenever I need it

Ah - yeah, they’re structs at the moment (though that will change shortly - I was looking at a tree that I have here that has some major re-working going on - though, generally, structs and classes are the same thing these days (with an exception in default visibility - public for structs, private for classes) - but using struct in user code may cause problems when I replace them with classes) - but the struct is extraneous for the most part.

it works! many thanks.