At which point will the HSV colors in the fill_gradient function (in colorutils.cpp) be

At which point will the HSV colors in the fill_gradient function (in colorutils.cpp) be converted to RGB?

From this line I conclude that you can store as CHSV in the CRGBPalette256: leds[i] = CHSV( hue88 >> 8, sat88 >> 8, val88 >> 8);

However in the ColorFromPalette functions I only see CRGB data being grabbed from the Palette. Where does the conversion happen?

I found this line in pixeltypes.h, does the magic happen over here?
// allow assignment from HSV color
inline CRGB& operator= (const CHSV& rhs) attribute((always_inline))

The the conversion happen when storing the palette or when reading?

Storing.
The current palettes are currently CRGB-based, hence the name. We are, however, leaving room for CHSVPalette16 and CHSVPalette256, which we’ll probably add in the not-too-far future.

We have grand ideas for an all-HSV world-- and also day jobs.

And just let me add that it makes me very happy to see somebody really digging in and playing with the palettes, and also the underlying code!

That inline function where I pointed to (I’m kind of a C noob) takes care of the conversion? Because I’m thinking to use the hsv2rgb_spectrum instead of the rainbow.

Yep. You got it. The constructor/assignment operator for CRGB that takes CHSV as an argument.

I’m curious what the appear of spectrum is?

I already wrote my own palette creation code, but that was entirely based on floats to create gradients. I’m suffering a lot that it got obsolete now after the release of your palette code :wink:

Filling the 256 value array with my gradient function (and HSV2RGB function) takes about 60ms, with yours 2.3ms :slight_smile: I’ve noticed that the rainbow is even faster around 1.9ms.

I’m trying to implement an RYB wheel (which seems kind of similar to rainbow, with more yellow), so I need the spectrum function.

Sound great!
(And yeah… floats… are not fast on AVR…)

Can I override the function in some way. Of course I can modify my local copy, but it might be better to create a separate file with my modifications.

I’d like to override the construction of CRGB to make use of hsv2rgb_spectrum.

I’ve sort of wanted a global way to do this for a whole. Let me think a bit.

Code: https://gist.github.com/kasperkamperman/8c71695ae1e7953970fa

[removed question about lerp, clear now]

Do you have any other tips to make it as fast as possible?

I see that you use normal arrays for sin tables. Is this a lot faster than PROG_MEM?

I’ve tried to optimize the code from my previous post. This code is meant to convert use the RYB circle when the conversion step to RGB is made.

code: https://gist.github.com/kasperkamperman/0fdc698346d9c147c191

I’m a noob in using pointers (still black magic for me), but with the numerous examples (Thanks!) that I could copy-paste from I could at least make it work. I also noticed it matters in speed (using a pointer, instead of a return for example).

I’m curious if it can be optimized. Filling the 256 array with two solid colors (half, half), took about 5.2ms with this function, while it takes about 0.8ms with the normal conversion.

I made a little test Sketch, just to measure the execution speed of the function alone:

I tried to replace the /8 for >> 3 and found that it actually slowed down :slight_smile: (which I didn’t expect of course).