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
#12
Try this updated 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 round(v)     if v <= 0 then       return 0     else       return math.round(v * level)     end   end   x = x / 0xFFFE   y = y / 0xFFFE   local z = 1.0 - x - y   local Y = level   local X = (Y / y) * x   local Z = (Y / y) * z   local r = X * 1.656492 - Y * 0.354851 - Z * 0.255038   local g = -X * 0.707196 + Y * 1.655397 + Z * 0.036152   local b = X * 0.051713 - Y * 0.121364 + Z * 1.01153   if r > b and r > g and r > 1 then     g = g / r     b = b / r     r = 1   elseif g > b and g > r and g > 1 then     r = r / g     b = b / g     g = 1   elseif b > r and b > g and b > 1 then     r = r / b     g = g / b     b = 1   end   r = round(revgamma(r))   g = round(revgamma(g))   b = round(revgamma(b))   return r * 0x10000 + g * 0x100 + b end
Reply


Messages In This Thread
RE: Phlips Hue - RGB Color Feedback - Zigbee - by admin - 17.10.2024, 13:49

Forum Jump: