All Is there a way to define a segment of LEDS as  RGB,

All
Is there a way to define a segment of LEDS as RGB, I just finished by build and found out one of my strings it RGB and all the rest GRB… :frowning:

Thanks
Greg

Have a look at the multiple strips setup. You should be able to set the color order for each as needed.

I think I already know the answer here, but are they on separate pins? Or is it all on one long string from a single pin?
You DO have options but they’re different for each case.

its in one big long string… I could break it apart but it would be a pain

on a single pin

OK. So the choice is basically are to solve this in hardware, or to solve it in software. Since hardware is ruled out, looks like software is the answer.

Basically, you’re going to need a “fix up” function that swaps the R and G channels for a certain range of pixels before (and possibly after) you call FastLED.show(). Something like this:

void swapRG( uint16_t startpixel, uint16_t pixelcount) {
uint16_t n = startpixel;
for( uint16_t j = 0; j < pixelcount; j++ ) {
uint8_t v = leds[n].r;
leds[n].r = leds[n].g;
leds[n].g = v;
n++;
}
}

Now before you call show(), call swapRG(…) with the starting pixel number of the swapped strip, and the length of it. Then after show(), call it again:

swapRG( 120, 60); // start & length
FastLED.show();
swapRG( 120, 60); // swap back

Depending on your animation, you might be able to leave out the second swap.

Warning: all this code is untested and may contain typos or other errors, but the idea will work.

Let us know how it goes!

Ah ha, that is a useful fix to have in the tool box. Thank you Mark.

Hi Mark
I’m getting test9.ino: In function ‘void swapRG(uint16_t, uint16_t)’:
test9:55: error: ‘leds’ was not declared in this scope
I new to programing in Arduino so I dont know if I have this in the correct spot. Here is the code that I’m playing with

#include <FastLED.h>

// Pin to which the input of the matrix is connected
#define String1_DATA_PIN 6

//—LED SETUP STUFF
const int ledsPerStrip = 200;

//—LED FX VARS
int max_bright = 255; //-SET MAX BRIGHTNESS TO 1/4
CRGB String1_leds[ledsPerStrip];

//—CHSV Color Setup
CHSV RoyalBlue( 157, 255, 255);
CHSV Overcast_Sky( 150, 130, 255);
CHSV SunRise_SunSet( 21, 155, 255);
CHSV Hign_Noon( 43, 2, 255);
CHSV Clear_Blue_Sky( 149, 75, 98);
CHSV CCandle( 21, 200, 255);
CHSV White( 0, 0, 255);
CHSV Red( 0, 255, 255);
CHSV Black( 0, 0, 0);
CHSV K2000( 30, 237, 255);
CHSV purple( 192, 255, 100);

CRGB interpolate(CRGB from, CRGB to, byte nSteps) {
CRGB ret;
ret.r = map(nSteps, 0, 255, from.r, to.r);
ret.g = map(nSteps, 0, 255, from.g, to.g);
ret.b = map(nSteps, 0, 255, from.b, to.b);
swapRG( 150, 50);
return ret;
}

void swapRG( uint16_t startpixel, uint16_t pixelcount) {
uint16_t n = startpixel;
for( uint16_t j = 0; j < pixelcount; j++ )
{
uint8_t v = leds[n].r;
leds[n].r = leds[n].g;
leds[n].g = v;
n++;
}
}

//------------------SETUP------------------
void setup()
{
Serial.begin(9600); // open the serial port at 9600 bps:
LEDS.addLeds<WS2811, String1_DATA_PIN ,GRB>(String1_leds, ledsPerStrip);
LEDS.setBrightness(max_bright); // SET BRIGHTNESS TO 1/4 POWER
LEDS.clear();
LEDS.show();
delay(2000);
}

//----------------Loop----------------
void loop() {
for(byte i = 0 ; i < 254; i++ ) {
// LEDS.showColor(interpolate(K2000, purple, i));
LEDS.showColor(interpolate(White, purple, i));
delay(100);
}
delay(1000);
for(byte i = 0 ; i < 254; i++ ) {
LEDS.showColor(interpolate(purple, Black, i));
delay(100);
}

LEDS.clear();
LEDS.show();
delay(5000);

for(byte i = 0 ; i < 254; i++ ) {
LEDS.showColor(interpolate(Black, purple, i));
delay(100);
}

delay(5000);
for(byte i = 0 ; i < 254; i++ ) {
// LEDS.showColor(interpolate(purple, K2000, i));
LEDS.showColor(interpolate(purple, White, i));
delay(100);
}
delay(5000);
}

In your LED FX VARS section you defined CRGB String1_leds, but the swapRG function is looking for something named leds. Update the swapRG function and i think it should work. (I’m not at a computer so can’t test.)

Replace leds with you String1_leds and try that?

I replaced String1_leds with leds… no change so I tried to do a Serial.print(leds[n].r); but it comes back as 0 am I not able to print the value?

You’re using “String1_leds” instead of “leds” in your code. Try that.

What is the n++ increment doing? Shouldn’t the pixel in question be
leds[n+j] ?

This seems to be working for me albeit with very little testing.

void swapRG( uint16_t startpixel, uint16_t pixelcount) {
uint16_t n = startpixel;
for( uint16_t j = 0; j < pixelcount; j++ ) {
uint8_t v = leds[n+j].r;
leds[n+j].r = leds[n+j].g;
leds[n+j].g = v;
//n++; why increment both n and j??
}