Skip to content

Commit 423f9d4

Browse files
authored
Merge pull request #1 from ashwinvandijk/master
Support for RGBWW saturation
2 parents 8b07e34 + 0f3e659 commit 423f9d4

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pyc

limitlessled/group/commands/v6.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class CommandSetV6(CommandSet):
1717
PASSWORD_BYTE2 = 0x00
1818
MAX_COLOR = 0xFF
1919
MAX_BRIGHTNESS = 0x64
20+
MAX_SATURATION = 0x64
2021
MAX_TEMPERATURE = 0x64
2122

2223
def __init__(self, bridge, group_number, remote_style,
@@ -48,6 +49,19 @@ def convert_brightness(self, brightness):
4849
"""
4950
return math.ceil(brightness * self.MAX_BRIGHTNESS)
5051

52+
def convert_saturation(self, saturation):
53+
"""
54+
Convert the saturation from decimal percent (0.0-1.0)
55+
to byte representation for use in commands.
56+
:param saturation: The saturation from in decimal percent (0.0-1.0).
57+
1.0 is the maximum saturation where no white leds will be on. 0.0 is no
58+
saturation.
59+
:return: The saturation in byte representation.
60+
"""
61+
62+
saturation_inverted = 1 - saturation;
63+
return math.ceil(saturation_inverted * self.MAX_SATURATION)
64+
5165
def convert_temperature(self, temperature):
5266
"""
5367
Convert the temperature from decimal percent (0.0-1.0)
@@ -310,3 +324,11 @@ def brightness(self, brightness):
310324
:return: The command.
311325
"""
312326
return self._build_command(0x03, self.convert_brightness(brightness))
327+
328+
def saturation(self, saturation):
329+
"""
330+
Build command for setting the saturation of the led.
331+
:param saturation: Value to set (0.0-1.0).
332+
:return: The command.
333+
"""
334+
return self._build_command(0x02, self.convert_saturation(saturation))

limitlessled/group/rgbw.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,27 @@ def brightness(self, brightness):
8080
cmd = self.command_set.brightness(brightness)
8181
self.send(cmd)
8282

83+
@property
84+
def saturation(self):
85+
""" Saturation property.
86+
87+
:returns: Saturation.
88+
"""
89+
return self._saturation
90+
91+
@brightness.setter
92+
def saturation(self, saturation):
93+
""" Set the group saturation.
94+
95+
:param saturation: Saturation in decimal percent (0.0-1.0).
96+
"""
97+
if saturation < 0 or saturation > 1:
98+
raise ValueError("Saturation must be a percentage "
99+
"represented as decimal 0-1.0")
100+
self._saturation = saturation
101+
cmd = self.command_set.saturation(saturation)
102+
self.send(cmd)
103+
83104
def transition(self, duration, color=None, brightness=None):
84105
""" Transition wrapper.
85106

0 commit comments

Comments
 (0)