This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Phlips Hue - RGB Color Feedback - Zigbee
#6
Use this conversion function:
Code:
function xytorgb(x, y, level)   local function revgamma(v)     if v <= 0.0031308 then       return v * 12.92     else       return (1 + 0.055) * math.pow(v, (1 / 2.4)) - 0.055     end   end   local function clampconvert(v, max)     v = math.max(0, v * 255 / max)     v = math.min(255, v)     return math.round(v)   end   local x = x / 0xFFFE   local y = y / 0xFFFE   local z = 1 - x - y   local Y = math.min(254, level) / 254   local X = (Y / y) * x   local Z = (Y / y) * z   local r = revgamma(3.2404542 * X - 1.5371385 * Y - 0.4985314 * Z)   local g = revgamma(-0.9692660 * X + 1.8760108 * Y + 0.0415560 * Z)   local b = revgamma(0.0556434 * X - 0.2040259 * Y + 1.0572252 * Z)   local max = math.max(r, g, b)   r = clampconvert(r, max)   g = clampconvert(g, max)   b = clampconvert(b, max)   return r * 0x10000 + g * 0x100 + b end x = 45913 y = 19614 level = 254 rgb = xytorgb(x, y, level) log(rgb)

You also need to pass the light level (0..254) for the conversion to work.
Reply


Messages In This Thread
RE: Phlips Hue - RGB Color Feedback - Zigbee - by admin - 24.09.2024, 06:42

Forum Jump: