self.send_dmx(Packet(palette)) class Packet: def __init__(self, colors): self.data = bytearray() for color in colors: r, g, b = color self.data.append(int(g * 255)) self.data.append(int(r * 255)) self.data.append(int(b * 255)) def rotate(l,n): return l[n:] + l[:n] if __name__ == "__main__": widget = Widget('/dev/ttyUSB0') import color import time #Ex 1: Spread a rainbow across all the strands numStrands=4 palette = color.rainbow_palette(numStrands, 1.0, 1.0) widget.send_dmx(Packet(palette)) #Ex 2: Fade the first strand through the color spectrum in steps of 52 #palette = color.rainbow_palette(52, 1.0, 1.0) #i = 0 #while True: #i = (i+1) % 52 #widget.send_dmx(Packet([palette[i],palette[i],palette[i],palette[i]])) # time.sleep(.05)
class Packet: def __init__(self, colors): self.data = bytearray() for color in colors: r, g, b = color self.data.append(int(g * 255)) self.data.append(int(r * 255)) self.data.append(int(b * 255)) def rotate(l, n): return l[n:] + l[:n] if __name__ == "__main__": widget = Widget('/dev/ttyUSB0') import color import time #Ex 1: Spread a rainbow across all the strands numStrands = 4 palette = color.rainbow_palette(numStrands, 1.0, 1.0) widget.send_dmx(Packet(palette)) #Ex 2: Fade the first strand through the color spectrum in steps of 52 #palette = color.rainbow_palette(52, 1.0, 1.0) #i = 0 #while True: #i = (i+1) % 52 #widget.send_dmx(Packet([palette[i],palette[i],palette[i],palette[i]])) # time.sleep(.05)
#!/usr/bin/python import sys, threading, time, argparse import dmx, color NUM_STRANDS = 24 # Number of LED Strands FREQUENCY = 1 # Number of times per second to update timeout = 1.0 / FREQUENCY bright_rainbow = color.rainbow_palette(NUM_STRANDS, 1, 1) pastel_rainbow = color.rainbow_palette(NUM_STRANDS, 0.33, 1) palettes = [bright_rainbow, pastel_rainbow] # todo: more stuff class Program: def __init__(self, **kwargs): self.widget = dmx.Widget(port) self.timeout = 1 / freq def run(self): self.tick() time.sleep(60) def tick(self): colors = pastel_rainbow # todo: we do our crazy sequence math here packet = dmx.Packet(colors) self.widget.send_dmx(packet) threading.Timer(timeout, self.tick).start()