Basic Control
This commit is contained in:
parent
381882eda9
commit
1c4d5d5b01
@ -31,7 +31,7 @@ class Lights_Modules():
|
||||
|
||||
for gc in range(groupCount):
|
||||
try:
|
||||
#print(gc)
|
||||
print("group n:" + str(gc))
|
||||
group = b.get_group(gc ,'name')
|
||||
print(group)
|
||||
#group_list.append(group)
|
||||
@ -39,8 +39,41 @@ class Lights_Modules():
|
||||
except:
|
||||
print(" --adding failed")
|
||||
|
||||
#b.set_group(18, "bri", 254) #This is max Brightness
|
||||
#b.set_group(18, "on", True) #This is will turn ON
|
||||
xy_result = self.rgb_to_xy(0,0,1) #This will take an rgb value and make it xy
|
||||
b.set_group(18, "xy", xy_result) #This will make the lights in the group turn blue
|
||||
|
||||
print("\n finished doing the thing")
|
||||
print("\n finished doing the things")
|
||||
|
||||
|
||||
|
||||
def rgb_to_xy(self, red, green, blue):
|
||||
""" conversion of RGB colors to CIE1931 XY colors
|
||||
Formulas implemented from: https://gist.github.com/popcorn245/30afa0f98eea1c2fd34d
|
||||
Args:
|
||||
red (float): a number between 0.0 and 1.0 representing red in the RGB space
|
||||
green (float): a number between 0.0 and 1.0 representing green in the RGB space
|
||||
blue (float): a number between 0.0 and 1.0 representing blue in the RGB space
|
||||
Returns:
|
||||
xy (list): x and y
|
||||
"""
|
||||
# gamma correction
|
||||
red = pow((red + 0.055) / (1.0 + 0.055), 2.4) if red > 0.04045 else (red / 12.92)
|
||||
green = pow((green + 0.055) / (1.0 + 0.055), 2.4) if green > 0.04045 else (green / 12.92)
|
||||
blue = pow((blue + 0.055) / (1.0 + 0.055), 2.4) if blue > 0.04045 else (blue / 12.92)
|
||||
|
||||
# convert rgb to xyz
|
||||
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
|
||||
|
||||
# convert xyz to xy
|
||||
x = x / (x + y + z)
|
||||
y = y / (x + y + z)
|
||||
|
||||
# TODO check color gamut if known
|
||||
return [x, y]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Loading…
Reference in New Issue
Block a user