def set_color(self, color: utils.RGBColor, start: int = 0, end: int = 0, fast: bool = False): ''' Sets the LEDs' color in the zone between start and end :param color: the color to set the LEDs to :param start: the first LED to change :param end: the first unchanged LED :param fast: If you care more about quickly setting colors than having correct internal state data, then set :code:`fast` to :code:`True` ''' if end == 0: end = len(self.leds) self.comms.send_header(self.device_id, utils.PacketType.RGBCONTROLLER_UPDATEZONELEDS, struct.calcsize(f"IiH{3*(end)}b{(end)}x")) buff = struct.pack("iH", self.id, end) + b''.join( (color.pack() for color in self._colors[:start] )) + (color.pack()) * (end - start) buff = struct.pack("I", len(buff)) + buff self.comms.send_data(buff) if not fast: self.update()
def set_color(self, color: utils.RGBColor, fast: bool = False): ''' Sets the color of the LED :param color: the color to set the LED to :param fast: If you care more about quickly setting colors than having correct internal state data, then set :code:`fast` to :code:`True` ''' self.comms.send_header(self.device_id, utils.PacketType.RGBCONTROLLER_UPDATESINGLELED, struct.calcsize("i3bx")) buff = struct.pack("i", self.id) + color.pack() self.comms.send_data(buff) if not fast: self.update()
def set_color(self, color: utils.RGBColor, fast: bool = False): ''' Sets the zone's color :param color: the color to set the LEDs to :param fast: If you care more about quickly setting colors than having correct internal state data, then set :code:`fast` to :code:`True` ''' self.comms.send_header( self.device_id, utils.PacketType.RGBCONTROLLER_UPDATEZONELEDS, struct.calcsize(f"iIH{3*(len(self.leds))}b{len(self.leds)}x")) buff = struct.pack("iH", self.id, len( self.leds)) + (color.pack()) * len(self.leds) buff = struct.pack("I", len(buff)) + buff self.comms.send_data(buff) if not fast: self.update()