def spectrum(ser, channel, speed, direction): command = create_command(ser, channel, ["0000FF"], "spectrum", direction, 0, 0, speed) outputs = previous.get_colors(channel, command) write(ser, outputs)
def write_audio(ser, channel, colors, tolerance, value, strips): try: if value >= tolerance: # Prevent index out of range value = tolerance elif value < 0.0: value = 0.0 normal = (value/tolerance)*int(strips[channel-1]*10) normal_color = (value/tolerance)*len(colors) size = int(strips[channel-1]*10/len(colors)) value = normal_color*size-int(normal_color*size) # Get value fraction dis = colors[:int(normal_color)] display = [] for color in dis: for i in range(int(size)): display.append(color) for i in range(int(value*size)): display.append(colors[int(normal_color)]) rgb = colors[int(normal_color)] rgb = (int(rgb[:2], 16)/255.0, int(rgb[2:4], 16)/255.0, int(rgb[4:], 16)/255.0) h, s, v = colorsys.rgb_to_hsv(*rgb) v = value*v # Change value of final color r,g,b = colorsys.hsv_to_rgb(h, s, v) r = int(r*255) g = int(g*255) b = int(b*255) hexcolor = '%02x%02x%02x' % (r,g,b) # Back to html notation display.append(hexcolor.upper()) except KeyboardInterrupt: raise except: return command = create_custom(ser, channel, display, "audio", 0, 0, 0, 0, strips) outputs = previous.get_colors(channel, command) write(ser, outputs)
def wings(ser, gui, channel, color, speed): if gui != 0: color = picker.pick("Color") command = create_command(ser, channel, [color], "wings", 0, 0, 0, speed) outputs = previous.get_colors(channel, command) write(ser, outputs)
def fixed(ser, gui, channel, color): if gui != 0: color = picker.pick("Color") command = create_command(ser, channel, [color], "fixed", 0, 0, 0, 2) outputs = previous.get_colors(channel, command) write(ser, outputs)
def candlelight(ser, gui, channel, color): if gui != 0: color = picker.pick("Color") command = create_command(ser, channel, [color], "candlelight", 0, 0, 0, 0) outputs = previous.get_colors(channel, command) write(ser, outputs)
def pulse(ser, gui, channel, color, speed): if 1 <= gui <= 8: color = [] for i in range(gui): color.append(picker.pick("Color "+str(i+1) + " of "+str(gui))) command = create_command(ser, channel, color, "pulse", 0, 0, 0, speed) outputs = previous.get_colors(channel, command) write(ser, outputs)
def cover_marquee(ser, gui, channel, color, speed, direction): if 1 <= gui <= 8: color = [] for i in range(gui): color.append(picker.pick("Color "+str(i+1) + " of "+str(gui))) command = create_command(ser, channel, color, "cover_marquee", direction, 0, 0, speed) outputs = previous.get_colors(channel, command) write(ser, outputs)
def marquee(ser, gui, channel, color, speed, size, direction): if gui != 0: gui = 1 for i in range(1): color = picker.pick("Color "+str(i+1) + " of "+str(gui)) command = create_command(ser, channel, [color], "marquee", direction, 0, size, speed) outputs = previous.get_colors(channel, command) write(ser, outputs)
def animated(ser, channel, colors, speed): if not inspect.isclass(ser): ser = serial.Serial(ser, 256000) strips = [strips_info(ser, 1), strips_info(ser, 2)] init(ser) while True: for round in colors: command = create_custom(ser, channel, round, "audio", 0, 0, 0, 0, strips) outputs = previous.get_colors(channel, command) write(ser, outputs) sleep(speed / 1000.0)
def fixed(ser, gui, channel, color): if gui != 0: color = picker.pick("Color") print("Creating command...") command = create_command(ser, channel, [color], "fixed", 0, 0, 0, 2) print("Doing this weird previous thing") outputs = previous.get_colors(channel, command) print("Write final command.") write(ser, outputs) print("Done")
def custom(ser, gui, channel, colors, mode, speed): strips = [strips_info(ser, 1), strips_info(ser, 2)] if mode not in ['fixed', 'breathing', 'wave']: raise InvalidCommand("No such mode for custom") if 1 <= gui <= 40: colors = [] for i in range(gui): colors.append(picker.pick("Color "+str(i+1) + " of "+str(gui))) command = create_custom(ser, channel, colors, mode, 0, 0, 0, speed, strips) outputs = previous.get_colors(channel, command) write(ser, outputs)
def alternating(ser, gui, channel, color, speed, size, moving, direction): if gui != 0: color = [] gui = 2 for i in range(2): color.append(picker.pick("Color "+str(i+1) + " of "+str(gui))) if moving: option = 1 else: option = 0 command = create_command(ser, channel, color, "alternating", direction, option, size, speed) outputs = previous.get_colors(channel, command) write(ser, outputs)