def __init__(self, ledStrandModel, auxscreens=[]): for section in ledStrandModel: self.pixelMap += self.createMapFor(section) self.pixelMapPacked = np.array(self.pixelMap).astype( np.int8).tostring() print min(np.array(self.pixelMap).T[0]), " - ", max( np.array(self.pixelMap).T[0]) print min(np.array(self.pixelMap).T[1]), " - ", max( np.array(self.pixelMap).T[1]) self.opcServers.append(opc.FastOPC()) if None != auxscreens: for aux in auxscreens: self.opcServers.append(opc.FastOPC(aux))
def basic(brightnessFactor): print('brightness factor is ' + str(brightnessFactor)) global lNeck, lBody, lStrap client = fastopc.FastOPC('localhost:7890') pixels = lib.BassPixels(lNeck, lBody, lStrap, 0) theoNeck = np.zeros([lNeck, 3]) theoBody = np.zeros([lBody, 3]) theoStrap = np.zeros([lStrap, 3]) stream = micStream.Stream(fps=30, nBuffers=4) powerSmooth = lib.ExpFilter(val=0.05, alpha_rise=0.05, alpha_decay=0.05) nColorWheel = 600 colorWheel = lib.getColorWheel(nColorWheel) frameCount = 0 while True: success = stream.readAndCalc() if success: frameNumEff = np.mod(frameCount, nColorWheel) power = np.sum(stream.freqSpectrum[20//7:250//7]) powerSmooth.update(power) displayPower = int(122*power/powerSmooth.value) width = int(5 + np.sqrt(float(displayPower))) theoBody = displayPower * colorWheel[np.mod(frameNumEff+200, nColorWheel)] theoNeck[0:width] = 255 * colorWheel[np.mod(frameNumEff, nColorWheel)] pixels.updateBody(theoBody, 0.7, 0.1) pixels.updateNeck(theoNeck, 0.7, 0.1) client.putPixels(0, brightnessFactor*pixels.getArrayForDisplay()) frameCount+=1
def rain2(brightnessFactor): # always here global nStrips, lStrip client = fastopc.FastOPC('localhost:7890') # setup nColorWheel = nStrips colorWheel = lib.getColorWheelRedBlue(nColorWheel) pixels = lib.Pixels(nStrips, lStrip, 0) theoAll = np.zeros([lStrip * nStrips, 3]) frameCount = 0 stripNum = 0 dir = 1 updateEvery = 50 sleepTime = 0.03 / updateEvery chance = 0.5 alpha = float(2.0 / updateEvery) # loop while True: if np.mod(frameCount, updateEvery) == 0: for i in range(nStrips): theoAll[i * lStrip, :] = 0 theoAll = np.roll(theoAll, -1, axis=0) if np.random.rand() < chance: if stripNum == 0: dir = 1 elif stripNum == nStrips - 1: dir = -1 theoAll[(stripNum * lStrip) + lStrip - 1] = 255 * colorWheel[stripNum] stripNum += dir pixels.update(theoAll, alpha, alpha / 10.0) client.putPixels(0, brightnessFactor * pixels.getArrayForDisplay()) frameCount += 1 time.sleep(sleepTime)
def bassScrollTop(brightnessFactor): # always here global nStrips, lStrip client = fastopc.FastOPC('localhost:7890') # setup pixels = lib.Pixels(nStrips, lStrip, 0) theoStrip = np.zeros([lStrip, 3]) stream = micStream.Stream(fps=30, nBuffers=4) powerSmooth = lib.ExpFilter(val=1.0, alpha_rise=0.01, alpha_decay=0.01) nColorWheel = 300 colorWheel = lib.getColorWheel(nColorWheel) frameCount = 0 powerMinFreqIndex = int(0 / stream.dFreq) powerMaxFreqIndex = int(120 / stream.dFreq) # loop while True: success = stream.readAndCalc() if success: frameNumEff = np.mod(frameCount, nColorWheel) power = np.sum( stream.freqSpectrum[powerMinFreqIndex:powerMaxFreqIndex]) powerSmooth.update(power) displayPower = int(122 * np.power(power / powerSmooth.value, 1.5)) theoStrip = np.roll(theoStrip, -1, axis=0) theoStrip[-2] = displayPower * colorWheel[frameNumEff] theoStrip[-1] = 1000 * colorWheel[frameNumEff] pixels.update(theoStrip, 0.7, 0.5) client.putPixels(0, brightnessFactor * pixels.getArrayForDisplay()) frameCount += 1
def kickDrum(brightnessFactor): # always here global nStrips, lStrip client = fastopc.FastOPC('localhost:7890') # setup pixels = lib.Pixels(nStrips, lStrip, 0) theoStrip = np.zeros([lStrip // 2, 3]) stream = micStream.Stream(fps=60, nBuffers=4) powerSmooth = lib.ExpFilter(val=0.05, alpha_rise=0.1, alpha_decay=0.1) nColorWheel = 300 colorWheel = lib.getColorWheel(nColorWheel) frameCount = 0 # loop while True: success = stream.readAndCalc() if success: frameNumEff = np.mod(frameCount, nColorWheel) #power = np.sum(stream.freqSpectrum[20//7:250//7]) power = np.sum(stream.freqSpectrum[:20]) powerSmooth.update(power) if power > 1.e4: displayPower = int(122 * np.power(power / powerSmooth.value, 1.5)) theoStrip[:] = displayPower * colorWheel[frameNumEff] #theoStrip[0] = 1000*colorWheel[frameNumEff] pixels.update(theoStrip, 1.0, 0.4) client.putPixels( 0, brightnessFactor * pixels.getArrayForDisplay()) frameCount += 1 else: theoStrip[:] = np.zeros_like(theoStrip[:]) #theoStrip[0] = 1000*colorWheel[frameNumEff] pixels.update(theoStrip, 1.0, 0.4) client.putPixels( 0, brightnessFactor * pixels.getArrayForDisplay())
def bassWiden(brightnessFactor): # always here global nStrips, lStrip client = fastopc.FastOPC('localhost:7890') # setup pixels = lib.Pixels(nStrips, lStrip, 20) theoStrip = np.zeros([lStrip // 2, 3]) stream = micStream.Stream(fps=30, nBuffers=4) powerMinFreqIndex1 = int(0 / stream.dFreq) powerMaxFreqIndex1 = int(200 / stream.dFreq) powerSmooth = lib.ExpFilter(val=1.0, alpha_rise=0.01, alpha_decay=0.01) nColorWheel = 600 colorWheel = lib.getColorWheel(nColorWheel) frameCount = 0 # loop while True: success = stream.readAndCalc() if success: frameNumEff = np.mod(frameCount, nColorWheel) power = np.sum( stream.freqSpectrum[powerMinFreqIndex1:powerMaxFreqIndex1]) powerSmooth.update(power) displayPower = max(int(122 * power / powerSmooth.value), 50) width = int(2 + 0.5 * np.sqrt(float(displayPower))) theoStrip[width:] = displayPower * colorWheel[np.mod( frameNumEff + 200, nColorWheel)] theoStrip[0:width] = 255 * colorWheel[np.mod( frameNumEff, nColorWheel)] #pixels.update(theoStrip, 0.7, 0.2) pixels.update(theoStrip, 1.0, 1.0) client.putPixels(0, brightnessFactor * pixels.getArrayForDisplay()) frameCount += 1
def bouncers(brightnessFactor): # always here global nStrips, lStrip client = fastopc.FastOPC('localhost:7890') # setup nBouncers = 16 pixels = lib.Pixels(nStrips, lStrip, 0) theoStrip = np.zeros([nStrips * lStrip, 3]) bouncerList = [] for i in range(nBouncers): bouncerList.append( lib.Bouncer(np.random.randint(1, high=8), np.random.rand() * 0.3 + 0.05, np.random.rand(3), lStrip)) # loop while True: for i in range(0, nBouncers): bouncerList[i].update() for i in range(0, nBouncers // 2): stripNum = i base = stripNum * lStrip theoStrip[base:base + lStrip] = bouncerList[i].getFullOutArray() + bouncerList[ i + nBouncers // 2].getFullOutArray() pixels.update(theoStrip, 0.5, 0.5) client.putPixels(0, brightnessFactor * pixels.getArrayForDisplay()) time.sleep(0.01)
def __init__(self, layout="layout/amcp-leds.json", server=None, targetFPS=30, maxLightning=10, showFPS=False): self.model = Model(layout) self.opc = fastopc.FastOPC(server) self.targetFPS = targetFPS self.showFPS = showFPS self.time = time.time() # Current translation vector self.translation = [0, 0, 0, 0] # Parameters, intended to be modified by the server code self.params = LightParameters() # Array with state of DMX devices. (TODO) self.dmx = numpy.zeros((1, 3), numpy.uint8) # Array of live lightning bolt objects self.lightning = [] self.maxLightning = maxLightning self._fpsFrames = 0 self._fpsTime = 0 self._fpsLogPeriod = 0.5 # How often to log frame rate
def joystick(brightnessFactor): # always here global nStrips, lStrip client = fastopc.FastOPC('localhost:7890') # setup pixels = lib.Pixels(nStrips, lStrip, 0) theoAll = np.zeros([lStrip * nStrips, 3]) inputNames = mido.get_input_names() inport = mido.open_input(inputNames[0]) board = lib.Board() # loop while True: for msg in inport.iter_pending(): board.update(msg) for n in range(nStrips): theoAll[n * lStrip, :] = 0 theoAll = np.roll(theoAll, -1, axis=0) currentStrip = np.floor( (board.pitchwheel + 8192) // (8192 * 2 // nStrips)) for n in range(nStrips): if n == currentStrip: theoAll[(n * lStrip) + lStrip - 1] = [200, 100, 250] pixels.update(theoAll, 1.0, 0.4) client.putPixels(0, brightnessFactor * pixels.getArrayForDisplay()) time.sleep(2.e-2)
def scroll(brightnessFactor): global lNeck, lBody, lStrap client = fastopc.FastOPC('localhost:7890') pixels = lib.BassPixels(lNeck, lBody, lStrap, 0) theoNeck = np.zeros([lNeck, 3]) theoBody = np.zeros([lBody, 3]) theoStrap = np.zeros([lStrap, 3]) stream = micStream.Stream(fps=30, nBuffers=4) powerSmooth = lib.ExpFilter(val=0.05, alpha_rise=0.05, alpha_decay=0.05) nColorWheel = 600 colorWheel = lib.getColorWheel(nColorWheel) frameCount = 0 while True: success = stream.readAndCalc() if success: frameNumEff = np.mod(frameCount, nColorWheel) power = np.sum(stream.freqSpectrum[20//7:250//7]) powerSmooth.update(power) displayPower = int(122*np.power(power/powerSmooth.value, 1.5)) theoNeck = np.roll(theoNeck, 1, axis=0) theoNeck[0] = displayPower * colorWheel[frameNumEff] theoBody = displayPower * colorWheel[np.mod(frameNumEff+200, nColorWheel)] pixels.updateBody(theoBody, 0.5, 0.5) pixels.updateNeck(theoNeck, 0.5, 0.5) client.putPixels(0, brightnessFactor*pixels.getArrayForDisplay()) frameCount+=1
def chase_beatDetection(brightnessFactor): # always here global nStrips, lStrip client = fastopc.FastOPC('localhost:7890') # setup stream = micStream.Stream(fps=30, nBuffers=4) powerSmooth1 = lib.ExpFilter(val=1.0, alpha_rise=0.05, alpha_decay=0.05) powerMinFreqIndex1 = int(0 / stream.dFreq) powerMaxFreqIndex1 = int(120 / stream.dFreq) beatObj1 = music.Beat(thresh=1.5, waitFrames=5) powerSmooth2 = lib.ExpFilter(val=1.0, alpha_rise=0.1, alpha_decay=0.1) powerMinFreqIndex2 = int(9000 / stream.dFreq) powerMaxFreqIndex2 = int(10000 / stream.dFreq) beatObj2 = music.Beat(thresh=2.5, waitFrames=2) dir = 1 pixels = lib.Pixels(nStrips, lStrip, 20) theoStrip = np.zeros([lStrip * nStrips, 3]) color = 2 for n in range(0, lStrip * nStrips, lStrip // 2 + 2): theoStrip[n, color] = 255 # loop while True: success = stream.readAndCalc() if success: power1 = np.sum( stream.freqSpectrum[powerMinFreqIndex1:powerMaxFreqIndex1]) powerSmooth1.update(power1) #powerTot = np.sum(stream.freqSpectrum) powerSmooth1.update(power1) powerNorm1 = power1 / powerSmooth1.value beatObj1.update(powerNorm1) power2 = np.sum( stream.freqSpectrum[powerMinFreqIndex2:powerMaxFreqIndex2]) powerSmooth2.update(power2) powerNorm2 = power2 / powerSmooth2.value beatObj2.update(powerNorm2) if beatObj1.getBeatStatus() == True: dir *= -1 theoStrip = np.roll(theoStrip, 1, axis=1) lib.clDisplay(powerNorm1) theoStrip = np.roll(theoStrip, dir, axis=0) pixels.update(theoStrip, 1.0, 0.05) client.putPixels(0, brightnessFactor * pixels.getArrayForDisplay()) n += dir time.sleep(0.003)
def stars(brightnessFactor): # always here global nStrips, lStrip client = fastopc.FastOPC('localhost:7890') # setup waitTime = 0.1 #fade stars in over 10 frames at 0.1 s/frame is 1s per star nStars = 50 pixels = lib.Pixels(nStrips, lStrip, 0) theoStrips = np.zeros([nStars, nStrips * lStrip, 3]) zeroStrip = np.zeros_like(pixels.getArrayForDisplay()) client.putPixels(0, zeroStrip) colorOption = "all" # loop while True: # select new values positions = np.random.randint(0, high=nStrips * lStrip - 1, size=nStars) colors = np.random.randint(0, 255, size=[nStars, 3]) for n in range(nStars): maxColor = np.amax(colors[n]) if colorOption == "all": colors[n] = 255 * colors[n] / maxColor elif colorOption == "red": colors[n] = [255, 0, 0] elif colorOption == "blue": colors[n] = [0, 0, 255] elif colorOption == "green": colors[n] = [0, 255, 0] elif colorOption == "purple": colors[n] = [200, 0, 150] for n in range(nStars): theoStrips[n, positions[n]] = colors[n] # bring in new stars for i in range(0, nStars * 10): starNum = int(np.floor(i / 10)) pixels.update(theoStrips[starNum], 0.2, 0.0) client.putPixels(0, brightnessFactor * pixels.getArrayForDisplay()) time.sleep(waitTime) # clear old stars for i in range(0, int(10 / waitTime)): pixels.update(zeroStrip, 0.0, 0.02) client.putPixels(0, brightnessFactor * pixels.getArrayForDisplay()) time.sleep(waitTime) # fully zero out strip pixels.update(zeroStrip, 1.0, 1.0) theoStrips = np.zeros([nStars, nStrips * lStrip, 3])
def beatDetection(brightnessFactor): # always here client = fastopc.FastOPC('localhost:7890') pixels = lib.Pixels(nStrips, lStrip, 0) theo = np.zeros([lStrip, 3]) stream = micStream.Stream(fps=30, nBuffers=4) powerSmooth1 = lib.ExpFilter(val=1.0, alpha_rise=0.05, alpha_decay=0.05) powerMinFreqIndex1 = int(0 / stream.dFreq) powerMaxFreqIndex1 = int(250 / stream.dFreq) beatObj1 = music.Beat() powerSmooth2 = lib.ExpFilter(val=1.0, alpha_rise=0.1, alpha_decay=0.1) powerMinFreqIndex2 = int(9000 / stream.dFreq) powerMaxFreqIndex2 = int(10000 / stream.dFreq) beatObj2 = music.Beat(thresh=2.5, waitFrames=2) while True: success = stream.readAndCalc() if success: power1 = np.sum( stream.freqSpectrum[powerMinFreqIndex1:powerMaxFreqIndex1]) powerSmooth1.update(power1) powerNorm1 = power1 / powerSmooth1.value beatObj1.update(powerNorm1) power2 = np.sum( stream.freqSpectrum[powerMinFreqIndex2:powerMaxFreqIndex2]) powerSmooth2.update(power2) powerNorm2 = power2 / powerSmooth2.value beatObj2.update(powerNorm2) theo[0, :] = 0 theo = np.roll(theo, -1, axis=0) if beatObj1.getBeatStatus() == True: theo[-1, 0] = 255 print('BEAT ' * 21) if beatObj2.getBeatStatus() == True: theo[-1, 2] = 255 #print('BEAT '*21) lib.clDisplay(powerNorm2) pixels.update(theo, 1.0, 0.3) client.putPixels(0, brightnessFactor * pixels.getArrayForDisplay())
def drums_midi(brightnessFactor): # always here global nStrips, lStrip client = fastopc.FastOPC('localhost:7890') # setup pixels = lib.Pixels(nStrips, lStrip, 0) theoAll = np.zeros([lStrip * nStrips, 3]) inputNames = mido.get_input_names() inport = mido.open_input(inputNames[1]) board = lib.Board() speedCut = 100 frameNum = 0 nColorWheel = nStrips colorWheel = lib.getColorWheel(nColorWheel) stripColors = np.zeros([nStrips, 3]) n = 0 while n < nStrips: stripColors[n] = colorWheel[n] * 255 n += 1 midiNotes = [] while len(midiNotes) < nStrips: for msg in inport.iter_pending(): if msg.type == 'note_on': midiNotes.append(msg.note) print(midiNotes) justTurnedOn = np.zeros(nStrips) # loop while True: for msg in inport.iter_pending(): board.update(msg) #overallFactor = float(board.knobs[51]+1)/(128.0) #if np.mod(frameNum, speedCut) == 0: for n in range(nStrips): theoAll[n * lStrip, :] = 0 theoAll = np.roll(theoAll, -1, axis=0) for n in range(nStrips): if board.notes[midiNotes[n]] == 1: theoAll[(n * lStrip) + lStrip - 1] = stripColors[n] pixels.update(theoAll, 1.0, 0.4) client.putPixels(0, brightnessFactor * pixels.getArrayForDisplay()) time.sleep(2.e-2) frameNum += 1
def rain1_midi(brightnessFactor): # always here global nStrips, lStrip client = fastopc.FastOPC('localhost:7890') # setup pixels = lib.Pixels(nStrips, lStrip, 0) theoAll = np.zeros([lStrip * nStrips, 3]) inputNames = mido.get_input_names() inport = mido.open_input(inputNames[0]) board = lib.Board() speedCut = 100 frameNum = 0 midiNotes = [] while len(midiNotes) < nStrips: for msg in inport.iter_pending(): if msg.type == 'note_on': midiNotes.append(msg.note) print(midiNotes) # loop while True: for msg in inport.iter_pending(): board.update(msg) color = 2 * board.knobs[48:51] overallFactor = float(board.knobs[51] + 1) / (128.0) if np.mod(frameNum, speedCut) == 0: for n in range(nStrips): theoAll[n * lStrip, :] = 0 theoAll = np.roll(theoAll, -1, axis=0) for n in range(nStrips): midiNoteNum = midiNotes[n] if board.notes[midiNoteNum] == 1: theoAll[(n * lStrip) + lStrip - 1] = color * (board.velocities[midiNoteNum] / 128.0) #theoAll[(n*lStrip)+lStrip-1] = stripColors[n] pixels.update(theoAll, 1.0, 0.4) client.putPixels( 0, overallFactor * brightnessFactor * pixels.getArrayForDisplay()) time.sleep(2.e-4) frameNum += 1
def chase(brightnessFactor): # always here global nStrips, lStrip client = fastopc.FastOPC('localhost:7890') # setup n = 1 dir = 1 pixels = lib.Pixels(nStrips, lStrip, 20) theoStrip = np.zeros([lStrip * nStrips, 3]) color = 2 theoStrip[n, color] = 255 # loop while True: if n == (nStrips * lStrip - 1): dir *= -1 elif n == 0: dir *= -1 theoStrip = np.roll(theoStrip, 1, axis=1) theoStrip = np.roll(theoStrip, dir, axis=0) pixels.update(theoStrip, 1.0, 1.0) client.putPixels(0, brightnessFactor * pixels.getArrayForDisplay()) n += dir time.sleep(0.003)
def bouncers_ar(brightnessFactor): # always here global nStrips, lStrip client = fastopc.FastOPC('localhost:7890') # setup stream = micStream.Stream(fps=30, nBuffers=4) powerSmooth = lib.ExpFilter(val=0.05, alpha_rise=0.05, alpha_decay=0.05) powerMinFreqIndex = int(0 / stream.dFreq) powerMaxFreqIndex = int(250 / stream.dFreq) nBouncers = 16 pixels = lib.Pixels(nStrips, lStrip, 0) theoStrip = np.zeros([nStrips * lStrip, 3]) bouncerList = [] for i in range(nBouncers): bouncerList.append( lib.Bouncer(np.random.randint(1, high=8), np.random.rand() * 0.3 + 0.05, np.random.rand(3), lStrip)) # loop while True: success = stream.readAndCalc() if success: power = np.sum( stream.freqSpectrum[powerMinFreqIndex:powerMaxFreqIndex]) powerSmooth.update(power) displayPower = int(122 * np.power(power / powerSmooth.value, 1.5)) for i in range(0, nBouncers): bouncerList[i].update() for i in range(0, nBouncers // 2): stripNum = i base = stripNum * lStrip theoStrip[base:base + lStrip] = ( 0.5 + (float(displayPower) / 255.0)) * ( bouncerList[i].getFullOutArray() + bouncerList[i + nBouncers // 2].getFullOutArray()) pixels.update(theoStrip, 0.5, 0.5) client.putPixels(0, brightnessFactor * pixels.getArrayForDisplay())
def rain1(brightnessFactor): # always here global nStrips, lStrip client = fastopc.FastOPC('localhost:7890') # setup nColorWheel = 100 colorWheel = lib.getColorWheel(nColorWheel) pixels = lib.Pixels(nStrips, lStrip, 0) theoAll = np.zeros([lStrip * nStrips, 3]) frameCount = 0 # loop while True: for i in range(nStrips): theoAll[i * lStrip, :] = 0 frameNumEff = np.mod(frameCount, nColorWheel) theoAll = 0.99 * np.roll(theoAll, -1, axis=0) if np.random.rand() < 0.75: stripNum = np.random.randint(0, high=nStrips) theoAll[(stripNum * lStrip) + lStrip - 1] = 255 * colorWheel[frameNumEff] pixels.update(theoAll, 1.0, 0.4) client.putPixels(0, brightnessFactor * pixels.getArrayForDisplay()) time.sleep(0.05) frameCount += 1
Let's light this sucker up. """ import fastopc import time from generate_pulse import sinedata # ...because we're using the last LEDs on the FadeCandy. [facepalm] numLEDs = 512 LEDstart = 448 LEDstop = 512 # Fire up the OPC connection ADDRESS = "localhost:7890" # Create a client object client = fastopc.FastOPC(ADDRESS) # Initialise the pixel data structure pixels = [(0, 0, 0)] * numLEDs # Now let's populate some heartbeat data hearts = [] number_of_hearts = 12 for heart in range(number_of_hearts): # 60 to 180 bpm heartrate = 60 + 10 * heart fps = 60.0 hearts.append(sinedata(heartrate, fps)) # print "Heart: ", heart, "Frames: ", len(hearts[heart]) framecount = 0
#!/usr/bin/python from argparse import ArgumentParser from pieva import * import fastopc as opc import time from screen import * leds = opc.FastOPC() def testPattern(pattern): global testDotIndex pixels = [] for i in range(len(pattern)): if i == testDotIndex: pixels += testDot else: pixels += testBlank testDotIndex = testDotIndex + 1 if (testDotIndex >= len(pattern)): testDotIndex = 0 return pixels def blank(pattern): pixels = [] for led in pattern: pixels += testBlank return pixels
print longueur_upscaling = int(longueur_maison * (matrix_upscaling - 1) / 2) largeur_upscaling = int(largeur_maison * (matrix_upscaling - 1) / 2) print "Longueur upscaling : ", longueur_upscaling, " Largeur upscaling : ", largeur_upscaling largeur = largeur_maison + largeur_upscaling * 2 longueur = longueur_maison + longueur_upscaling * 2 print "Taille totale : ", largeur, ", ", longueur ############# Boucle de traitement ############# OPC_server = fastopc.FastOPC() VALEUR_DE_NORMALISATION_DE_LA_MATRICE = 255 SECURITY_LUMINOSITY = 0.7 steps = 0 while (True): upscaled_matrix = np.zeros((largeur, longueur), dtype=float) # On calcul l'azimut et l'élévation du soleil en fonction de la date et # du lieu. azimut_soleil, elevation = sunpos.sun_position(2017, 07, 10, hour=(steps / 60) % 24,
#!/usr/bin/env python import fastopc, time import numpy as np import functionLib as lib nStrips = 16 lStrip = 64 nLed = nStrips * lStrip client = fastopc.FastOPC('localhost:7890') on = np.zeros([nLed, 3]) for i in range(0, nStrips): base = lStrip * i on[base:base + i + 1] = [0, 0, 255] off = np.zeros_like(on) while True: client.putPixels(0, on) time.sleep(0.25) client.putPixels(0, off) time.sleep(0.25)
from __future__ import division import fastopc as opc import time, os, sys, traceback import numpy as np #from logipy import logi_led import colortools as ct import threading import jsonsocket, json from timeit import default_timer as timer from enum import Enum from websocket_server import WebsocketServer connection = opc.FastOPC() class Effect(Enum): NONE = 'none' BREATHE = "breathe" GRADIENT = "gradient" RAINBOW = "rainbow" RAINBOW_GRADIENT = "rainbow_gradient" CYANIZE = "cyanize" class Anim(Enum): NONE = 'none' BREATHE = 'breathe' ROLL = 'roll' class wsLED: