CF2 - NeoPixelRing - Full HD Color Rainbow

Discussions and questions about the Crazyflie Nano Quadcopter
Post Reply
chonchonchon
Beginner
Posts: 18
Joined: Sat Sep 20, 2014 1:47 am

CF2 - NeoPixelRing - Full HD Color Rainbow

Post by chonchonchon »

Hi guys !

- FULLCOLOR RING Rotating circle with RAINBOW effect (like photo).
- UNICOLOR ring with Rainbow change effect (like PHILIPS LAMP)

Include a full RGB to HSV transformation function.
image1.JPG
image2.JPG
If someone is interrested about code source, please told me what i have to upload (FILE > cflie.bin? , neopixelring.c? , full project folder? or copy past of source code ?)

Thanks for your help

... I really love this new toy, it's awesome ! ...so funny !!!
dbrgn
Member
Posts: 51
Joined: Tue Dec 16, 2014 9:42 pm

Re: CF2 - NeoPixelRing - Full HD Color Rainbow

Post by dbrgn »

Nice effect. Could you post your effect function (the one with signature static void yourEffect(uint8_t buffer[][3], bool reset))?
chonchonchon
Beginner
Posts: 18
Joined: Sat Sep 20, 2014 1:47 am

Re: CF2 - NeoPixelRing - Full HD Color Rainbow

Post by chonchonchon »

1. Declare 4 following variables at beggining of neopixelring.c

static int red;
static int green;
static int blue;
static uint8_t RGB_direction=1, RGB_step=1;

2. Don't forget to add the "RainbowRing" and "ColorLamp" in the effect list at the end of the file.

3. Copy the 3 following functions
- setLedColorHSV function
- RainbowRing function
- ColorLamp function

4. Select the effect using the Parameter tab in cfClient !

''! ENJOY !''

Chon
--------------------------------------------------------

static void setLedColorHSV(int h, double s, double v)
{
double r=0;
double g=0;
double b=0;

int i=(int)h/60.0;

double f = h/60.0 - i;
double pv = v * (1 - s);
double qv = v * (1 - s * f);
double tv = v * (1 - s * (1 - f));

switch (i)
{
case 0: // red dominant
r = v;
g = tv;
b = pv;
break;

case 1: // green
r = qv;
g = v;
b = pv;
break;

case 2: //
r = pv;
g = v;
b = tv;
break;

case 3: // azur
r = pv;
g = qv;
b = v;
break;

case 4: //
r = tv;
g = pv;
b = v;
break;


case 5: // red
r = v;
g = pv;
b = qv;
break;

}

red = LIMIT(255*r);
green = LIMIT(255*g);
blue = LIMIT(255*b);

}



static void RainbowRing(uint8_t buffer[][3], bool reset)
{
uint8_t temp[3];
int i;

if (reset)
{

for (i=0; i<NBR_LEDS ; i++) {

int final = 32 *i;
setLedColorHSV(final,1,1);
buffer[0] = red;
buffer[1] = green;
buffer[2] = blue;
}
}

COPY_COLOR(temp, buffer[(NBR_LEDS-1)]);
for (i=(NBR_LEDS-1); i>=0; i--) {
COPY_COLOR(buffer, buffer[i-1]);
}
COPY_COLOR(buffer[0], temp);


}



static void ColorLamp(uint8_t buffer[][3], bool reset)
{
int i;

if (RGB_direction == 1 ) {
RGB_step = RGB_step + 1;
if (RGB_step >= 255 ){ RGB_direction = 0;}
}

else

{
RGB_step = RGB_step - 1;
if (RGB_step <= 0 ){ RGB_direction = 1;}
}


for (i=0; i<NBR_LEDS ; i++) {


setLedColorHSV(RGB_step,1,1);
buffer[0] = red;
buffer[1] = green;
buffer[2] = blue;
}

}
marcus
Bitcraze
Posts: 659
Joined: Mon Jan 28, 2013 7:02 pm
Location: Sweden
Contact:

Re: CF2 - NeoPixelRing - Full HD Color Rainbow

Post by marcus »

Really nice effect! It would be great if you wanted to create a pull-request for the code. Otherwise I could merge it in manually if that would be ok, since it's definitely something we would love to have in the firmware.
Call_me_a_Cab
Member
Posts: 51
Joined: Wed Dec 17, 2014 12:56 pm

Re: CF2 - NeoPixelRing - Full HD Color Rainbow

Post by Call_me_a_Cab »

These effects are awesome!!!

I had to change the first 3 declares and the occorences of them in the effects to make it compile though....

I just added "2" after red green and blue
Post Reply