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
#3
Code:
12345678910111213141516171819202122232425262728293031323334353637383940414243
RGB = event.getvalue() -- Norm of RGB values R = bit.rshift(bit.band(RGB, 0xFF0000), 16) G = bit.rshift(bit.band(RGB, 0x00FF00), 8) B = bit.band(RGB, 0x0000FF) Red =    R / 255 Green = G / 255 Blue = B / 255 -- Gamma correction if Red > 0.04045 then   Red = ((Red + 0.055) / (1 + 0.055))^2.4 else   Red = Red / 12.92 end if Green > 0.04045 then   Green = ((Green + 0.055) / (1 + 0.055))^2.4 else   Green = Green / 12.92 end if Blue > 0.04045 then   Blue = ((Blue + 0.055) / (1 + 0.055))^2.4 else   Blue = Red / 12.92 end -- Coversion RGB > XY X = Red * 0.649926 + Green * 0.103455 + Blue * 0.197109 Y = Red * 0.234327 + Green * 0.743075 + Blue * 0.022598 Z = Green * 0.053077 + Blue * 1.035763 x = X / (X+Y+Z) y = Y / (X+Y+Z) -- Coversion XY > CCT n = (x - 0.3320) / (0.1858 - y) cct = math.floor((-449 * ((x - 0.332) / (y - 0.1858))^3) + (3525 * ((x - 0.332) / (y - 0.1858))^2) - (6823.3 * ((x - 0.332) / (y - 0.1858))) + (5520.33)) log(cct)
Reply


Messages In This Thread
RE: Phlips Hue - RGB Color Feedback - Zigbee - by Joep - 25.03.2024, 13:03

Forum Jump: