def __init__(self, color): self.color = color self.strip = LPD8806.strand(leds=num_leds) self.sleep_time = 0.1 self.choice = 'SingleTail' self.valid_choices = ['Fader', 'FadeTail', 'SingleTail'] threading.Thread.__init__(self)
def ledOn(): l = LPD8806.strand() l.set(0,100,0,0) l.set(1,0,100,0) l.set(2,0,0,100) l.set(3,100,100,0) l.set(4,0,100,100) l.set(5,100,0,100) l.set(6,100,100,100) l.fill(255,0,0,7,32) l.update()
def GreenLED(firstPixel, secondPixel): """ This fades the leds from red to green in 25 step increments """ led = LPD8806.strand() count1 = 250 count2 = 0 while count1 != 0: """ Fade red off """ led.set(firstPixel, count1, 0, 0) led.set(secondPixel, count1, 0, 0) led.update() count1 -= 25 while count2 != 250: """ Fade green on """ led.set(firstPixel, 0, count2, 0) led.set(secondPixel, 0, count2, 0) led.update() count2 += 25 return
from imgproc import * import LPD8806 print "Starting MIMIC..." my_cam = Camera(320,240) led = LPD8806.strand() while 0 < 1: my_img = my_cam.grabImage() red, green, blue = my_img[160, 120] my_img[160, 120] = 0, 0, 0 led.fill(red, green, blue)
def ledOff(): led = LPD8806.strand() led.fill(0,0,0) led.update() return
#!/usr/bin/python from time import sleep import LPD8806 led = LPD8806.strand() while True: for i in range(5): led.fill(255, 0, 0) led.update() sleep(0.3) led.fill(0, 255, 0) led.update() sleep(0.3) led.fill(0, 0, 255) led.update() sleep(0.3) for i in range(300): led.wheel() led.update()
# Import other modules import time import sys import math import json import atexit sys.path.append('.') # Import the LPD8806 module. import LPD8806 LED_COUNT = int(sys.argv[1]) SPI_PORT = int(sys.argv[2]) SPI_DEVICE = int(sys.argv[3]) strip = LPD8806.strand(LED_COUNT, '/dev/spidev' + str(SPI_PORT) + '.' + str(SPI_DEVICE)) def listen(): global strip try: while True: for line in iter(sys.stdin.readline, ''): colors = json.loads(line) for j in range(LED_COUNT): strip.set(j, int(colors[j][0]), int(colors[j][2]), int(colors[j][1])) strip.update() time.sleep(0.002) except KeyboardInterrupt: pass