Hi everybody, I have already spent hours looking for a solution for my problem.

Hi everybody,

I have already spent hours looking for a solution for my problem. Perhaps one of you has a solution to implement my requirement. I would like to read the light of one of my Philips Hue lamps and transferred to my WS2812b LED Strip. So I have to convert from HSB (hue up to 65535 !!!) to RGB or at least a conversion from Philips HSB to something I can continue to work with fastled.
The reading of the values hue, bri, sat, xy is already prepared, but now I come no further.

Does anyone have a solution for me?

HSB is just another acronym for HSV. Check out the docs here https://github.com/FastLED/FastLED/wiki/FastLED-HSV-Colors

yes i know, but it can’t handle the philips hue values up to 65535.

Sounds like they are using 16bit for hue. FastLED uses 8 so you just need to scale it down.

okay, i will look for a way to do that. thank you.

There may be more efficient ways but you can get going fast using Arduino map function https://www.arduino.cc/en/Reference/Map

There are even faster and more flexible versions already included in FastLED.
I.e. check the scale16by8 function in the documentation.

@Sven_Eric_Nielsen ​​ that function doesn’t do what he wants here I think. It computes i * (scale / 256) and returns a new 16bit value. What he wants here is to map 0-65535 to 0-255. So he wants (i / 65535) * 255. But obviously without the need for floating point.

@Ben_Delarre
You’re right. I mixed that up with the scale16 function.
However, he could do it exactly this way if he writes his own function.
But then it’s probably easier to use the map function directly.
And floating is in general not a topic I think because all these functions (even the Android map function) don’t use floats.

Right…I only mentioned floats because you can’t actually do hue / 65535 and expect to get a value other than 0 or 1 without floats.

Looks like a biased bit shift (I don’t know if it has a proper name) would be perfect here, and avoids floating point.

hue8 = ((hue16 + 127)>>8)&255

Where the +127 makes it round to the nearest value rather than rounding down, the bit shift (>>8) does the division, and masking by 255 (8 bits) takes advantage of overflow near max value to “round” to zero (as desired with hue values).

Hi Techy get this error:
no match for ‘operator>>’ (operand types are ‘StringSumHelper’ and ‘int’)

@Hille_Hillebrand ​ hue16 needs to be in a numerical format (int, short or long should all work because 16bit overflow is acceptable here), it looks like you have it in a string. If it’s a string but you know it will always be only digits you can convert with toInt().

Thank you very much, works perfect. :smiley: