Hi, I´d like to use a gradient palette that is manipulated in real time within the code. Any hint how to achieve this? Something like
DEFINE_GRADIENT_PALETTE( palette1 ) {
0, 3, 3, 3,
128, 3, 3, controlparameter,
255, 3, 3, 3 };
Thank you, Stefan.
@Mark_Kriegsman ?
I’m sure you already know this, but the closest I’ve seen (and what I use) is:
void SetupSimilar4Palette() {
thishue=random8(); // Pick a random hue.
targetPalette = CRGBPalette16(CHSV(thishue+random8(32), 255, random8(128,255)),
CHSV(thishue+random8(32), 255, random8(192,255)),
CHSV(thishue+random8(32), 192, random8(192,255)),
CHSV(thishue+random8(32), 255, random8(128,255)));
} // SetupSimilar4Palette()
and in loop(), I’ll blend them with:
EVERY_N_MILLISECONDS(100) {
uint8_t maxChanges = 24;
nblendPaletteTowardPalette(currentPalette, targetPalette, maxChanges); // AWESOME palette blending capability.
}
Thanks, @Andrew_Tuline . Yes, with CRGBPalette16 it works fine, but with 4 colors on defined positions I don´t get the colordistribution I want. I need one center color fading to “black” at both ends of the palette.
marmil
(Marc Miller)
June 21, 2017, 8:19pm
4
Cool, @marmil , that´s a good solution! Thank you.
I have used this-
CRGBPalette16 getPalette(CRGB color) {
static byte gradientByte[12] = {
0, 0, 0, 0, //black
192, 0, 255, 0, //green
255, 255, 255, 255 //white
};
gradientByte[5] = color.r;
gradientByte[6] = color.g;
gradientByte[7] = color.b;
CRGBPalette16 returnPalette;
returnPalette.loadDynamicGradientPalette(gradientByte);
return returnPalette;
}