Hi All,
I have been wondering, is it possible to convert an CRGB to CHSV? I know that FastLED can do the other way, but I’d like to be able to take an RGB value and then colour cycle it (as you can with a HSV by adding/subtracting from the hue value)
marmil
(Marc Miller)
December 11, 2017, 9:10pm
2
Here’s two tests that show this:
//***************************************************************
// Example of using rgb2hsv_approximate to convert from rgb to hsv.
// rgb2hsv works best with fully saturated colors.
// More info about rgb2hsv_approximate here:
// https://github.com/FastLED/FastLED/blob/master/hsv2rgb.h#L52
//
// Marc Miller, Aug 2017
//***************************************************************
#include "FastLED.h"
#define LED_TYPE LPD8806
#define DATA_PIN 11
#define CLOCK_PIN 13
#define NUM_LEDS 32
CRGB leds[NUM_LEDS];
CRGB rgb;
CHSV hsv;
//------------------------------------------------------------------
This file has been truncated. show original
//***************************************************************
// 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