def blink_led(self, light, on, color): if on: value = 0.0 else: value = 1.0 r,g,b = ledcolors.hsv2rgb(color['h'], color['s'], value) self.setRGB(light, r, g, b) return not on
def fade_step(self, light, increment, value, color): if increment == True: value = value + 0.01 if value >= 1.0: increment = False else: value = value - 0.01 if value <= 0: increment = True r,g,b = ledcolors.hsv2rgb(color['h'], color['s'], value) self.setRGB(light, r, g, b) return increment, value
def run(self): if self.message["task"] == "SET": r, g, b = ledcolors.hsv2rgb(self.message["h"], self.message["s"], self.message["v"]) self.led.setRGB(self.message["light"], r, g, b) self.kill() elif self.message["task"] == "FADE": self.fade_led(self.message["light"], self.led, self.message) elif self.message["task"] == "FADE_ALL": self.fade_all_colors(self.message["light"], self.led, self.message) elif self.message["task"] == "BLINK": self.blink_led(self.message["light"], self.led, self.message) elif self.message["task"] == "BLINK_ALL": self.blink_all_colors(self.message["light"], self.led, self.message) else: # if the task was not handle or identified we should kill the worker self.kill()
def blink_all_colors(self, light, on, color): r,g,b = ledcolors.hsv2rgb(color, 1.0, 1.0) self.setRGB(light, r, g, b) return not on, ((color + 50) % 360)
def fade_all_colors_step(self, light, value, color): value = value + 1; r,g,b = ledcolors.hsv2rgb(value % 360, 1.0, 1.0) self.setRGB(light, r, g, b) return value + 1