def set_light(self, r, g, b): """Set LED. :param r: Red (0-255) :param g: Green (0-255) :param b: Blue (0-255) """ plasma.set_light(0, r, g, b) plasma.show()
def update_led_temperature(self,temp,min_temp,max_temp,brightness): temp = float(temp) temp -= max_temp temp /= float(min_temp - max_temp) temp = max(0, min(1, temp)) temp = 1.0 - temp temp *= 120.0 temp /= 360.0 r, g, b = [int(c * 255.0) for c in colorsys.hsv_to_rgb(temp, 1.0, brightness / 255.0)] plasma.set_light(0, r, g, b) plasma.show()
import plasma import plasmafx from plasmafx import plugins import time FPS = 60 NUM_LIGHTS = 10 plasma.set_light_count(10) sequence = plasmafx.Sequence(NUM_LIGHTS) for x in range(NUM_LIGHTS): sequence.set_plugin( x, plugins.FXCycle(speed=2, spread=5, offset=(360.0 / NUM_LIGHTS) * x)) sequence.set_plugin(0, plugins.Pulse([(0, 0, 0), (255, 0, 255)])) sequence.set_plugin( 1, plugins.Pulse([(255, 0, 0), (0, 0, 255), (0, 0, 0)], speed=0.5)) while True: values = sequence.get_leds() for index, rgb in enumerate(values): # print("Setting pixel: {} to {}:{}:{}".format(index, *rgb)) plasma.set_pixel(index, *rgb) plasma.show() time.sleep(1.0 / FPS)