How to use the hsv2rgb conversion?
I am currently using leds[cursor] = 0xff0000 to define the color of the leds-strip. But when I want to scroll through the hue rainbow I would like to make use of the hsv2rgb conversion.
How do I get the desired output like 0xff0000 while using hsv2rgb?
I now use a long to save the rgb inside:
long defColor;
byte defRed = 255;
byte defGreen = 0;
byte defBlue = 0;
defColor = ((long)defRed << 16L) | ((long)defGreen << 8L) | (long)defBlue;
leds[cursor] = defColor;
marmil
(Marc Miller)
February 10, 2018, 3:07pm
2
Here’s an example:
//***************************************************************
// Demo of converting HSV to RGB_rainbow values.
// And then converting RGB back to HSV to show how close it is.
//
// Values are printed to serial monitor.
//
// The first two pixels will show that the HSV to RGB converted
// colors always match. Observing the third pixel will show
// how the conversion from RGB back to HSV is often pretty
// close, but can be a bit off sometimes. Converting RGB to HSV
// works best with fully saturated colors.
//
// Marc Miller, Nov 2017
//***************************************************************
#include "FastLED.h"
#define DATA_PIN 11
#define CLOCK_PIN 13
#define LED_TYPE LPD8806
#define COLOR_ORDER GBR
This file has been truncated. show original
Read more here:
https://github.com/FastLED/FastLED/blob/master/hsv2rgb.h#L52
@marmil Thanks, managed to get it work:
hue++;
CHSV hsv(hue,255,255);
CRGB rgb;
hsv2rgb_rainbow(hsv, rgb);
curColor = ((long)rgb.r << 16L) | ((long)rgb.g << 8L) | (long)rgb.b;