def __init__(self, pin_fancontrol=18, pin_button=17): """FAN Shim. :param pin_fancontrol: BCM pin for fan on/off :param pin_button: BCM pin for button """ self._pin_fancontrol = pin_fancontrol self._pin_button = pin_button self._button_press_handler = None self._button_release_handler = None self._button_hold_handler = None self._button_hold_time = 2.0 self._t_poll = None atexit.register(self._cleanup) GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(self._pin_fancontrol, GPIO.OUT) GPIO.setup(self._pin_button, GPIO.IN, pull_up_down=GPIO.PUD_UP) plasma.set_clear_on_exit(True) plasma.set_light_count(1) plasma.set_light(0, 0, 0, 0) self.start_polling()
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)