Exemplo n.º 1
0
def update(strip, data):
    global state
    global speed
    global dayColor

    now = datetime.now()
    seconds_since_midnight = (now - now.replace(
        hour=0, minute=0, second=0, microsecond=0)).total_seconds()
    seconds_since_midnight = seconds_since_midnight**2
    colorToSet = seconds_since_midnight / 7464960000.0
    colorToSet = int(colorToSet * 1000) / 1000.0

    if state < 255:
        for i in range(0, data['num_pixel']):
            if i > 22 and i < 115 or i > 192 and i < 300:
                strip.setPixelColor(
                    i, cm.hsv(0.14, 0, state / (255.0 + brightnessCap)))
            else:
                strip.setPixelColor(
                    i, cm.hsv(colorToSet, 1, state / (255.0 + brightnessCap)))
        state += speed
        if state > 255:
            state = 255
    else:
        if dayColor != colorToSet:
            print("changed color due daytime ", colorToSet)
            for i in range(0, data['num_pixel']):
                if i > 22 and i < 115 or i > 192 and i < 300:
                    strip.setPixelColor(
                        i, cm.hsv(0.14, 0, state / (255.0 + brightnessCap)))
                else:
                    strip.setPixelColor(
                        i,
                        cm.hsv(colorToSet, 1, state / (255.0 + brightnessCap)))
            dayColor = colorToSet
Exemplo n.º 2
0
def magicOverride(strip, data):
    global printerTemp
    global printerOn
    global tempColor

    if data['printerStart'] > 0:
        if printerTemp < 0:
            printerOn = not printerOn
      
            if printerOn:
                for i in range(852,883):
                    tempColor[i - 852] = strip.getPixelColor(i)
                    strip.setPixelColor(i,cm.hsv(data['printer-color'],1,1))
        
            else:
                for i in range(852,883):
                    strip.setPixelColor(i,tempColor[i - 852])
            
            printerTemp = 23

        else:
            printerTemp-=1
    
        data['printerStart']-=1
    else:
        if printerOn:
            printerOn=False
            for i in range(852,883):
                strip.setPixelColor(i,tempColor[i - 852])
Exemplo n.º 3
0
def show(strip, colors):
    for i in range(0, strip.numPixels()):
        if colors[i][2] < 0.05:
            colors[i] = [0, 0, 0]
            strip.setPixelColor(i, cm.rgb(0, 0, 0))
        else:
            strip.setPixelColor(
                i, cm.hsv(colors[i][0], colors[i][1], colors[i][2]))
Exemplo n.º 4
0
def magicOverride(strip, data):

    if currentState > 0.05 and currentState < 99.95:
        dist = area[1] - area[0]
        currentDist = int(dist * currentState)
        green = cm.hsv(0.3, 1, 1)
        white = cm.hsv(0.3, 0, 1)
        black = cm.hsv(0.3, 1, 0)
        for i in range(area[0], area[1] + 1):
            if i >= area[1] - currentDist:
                strip.setPixelColor(i, green)
            else:
                strip.setPixelColor(i, black)
        strip.setPixelColor(area[0] - 1, white)
        strip.setPixelColor(area[0] - 2, white)
        strip.setPixelColor(area[1] + 1, white)
        strip.setPixelColor(area[1] + 2, white)
Exemplo n.º 5
0
def update(strip, data):
    global startRainbow

    temp = startRainbow
    for i in range(strip.numPixels()):
        temp = temp + i * step
        temp = temp % 1.0
        clr = cm.hsv(temp, 1, 0.2)
        strip.setPixelColor(i, clr)
    startRainbow = startRainbow + speed
Exemplo n.º 6
0
def update(strip, data):
    global colorArray
    global point
    global distance
    global modifier

    if distance>101:
        point=(rdm.randint(0,data['num_pixel']-1)+200)%data['num_pixel']
        distance=0   
        if bool(rdm.randint(0,1)):
            modifier=0.002
        else:
            modifier=0.002

    for idx,clr in enumerate(colorArray):
        strip.setPixelColor(idx, cm.hsv(clr,1,1))

    if distance==0:
        
        colorArray[point]=(colorArray[point]+colorDistance*modifier)%1.0
        strip.setPixelColor(point, cm.hsv(clr,0,1))

    else:
        
        ##To the left
        tempPoint=(point+distance)%data['num_pixel']
        colorArray[tempPoint]=(colorArray[tempPoint]+colorDistance*modifier)%1.0
        strip.setPixelColor(tempPoint, cm.hsv(clr,0,1))

        #To the right
        tempPoint=(point-distance)%data['num_pixel']
        colorArray[tempPoint]=(colorArray[tempPoint]+colorDistance-distance*modifier)%1.0
        strip.setPixelColor(tempPoint, cm.hsv(clr,0,1))
        
    distance+=1
    
    
    
    
Exemplo n.º 7
0
def init(strip, data):
    global colorArray
    colorArray=[]
    last=0.0
    for i in range(0,data['num_pixel']):
        upOrDown=bool(rdm.randint(0,1))
        if upOrDown:
            last+=initColor
        else:
            last-=initColor
        last%=1.0
        colorArray.append(last)
        
        strip.setPixelColor(i, cm.hsv(last,1,1))
Exemplo n.º 8
0
def update(strip, data):
    global blobs
    global recording
    global threadstate
    global lock
    global blobState
    global blobColour

    if threadstate:
        #CS----------
        #lock.acquire()
        threadstate=False
        pulse=isBeat
        #lock.release()
        #-------------
        #print(pulse)
        if pulse :
            '''
            print(pulse)
            pos=random.random()*data['num_pixel']-300
            pos=int(pos)+150
            blobs.append([pos,0])
            
            blobState=1

            pos=random.random()*data['num_pixel']-300
            pos=int(pos)+150
            blobs.append([pos,0])
            
            blobState=1

            pos=random.random()*data['num_pixel']-300
            pos=int(pos)+150
            blobs.append([pos,0])
            '''
            blobState=1
            
            print("blob")

    

    if blobState>0:
        for i in range(data['num_pixel']-1,0,-1):    
            strip.setPixelColor(i,cm.hsv(blobColour,1,blobState))
        blobState=blobState/2
        if blobState<0.01:
            blobState=0
            blobColour=random.random()
    
    for i in range(0,len(blobs)):
        light=blobs[i][1]+1
        light=1-(light*7)/255
        #print(light)
        clr=random.random()
        #print(clr)
        left=blobs[i][0]+blobs[i][1]
        right=blobs[i][0]-blobs[i][1]
        #print(left)
        #print(right)
        strip.setPixelColor(left,cm.hsv(clr,1,light))
        strip.setPixelColor(right,cm.hsv(clr,1,light))

        strip.setPixelColor(left-1,cm.hsv(0,0,0))
        strip.setPixelColor(right+1,cm.hsv(0,0,0))

        blobs[i][1]=blobs[i][1]+1
        if blobs[i][1]>35:
            del blobs[i]
            strip.setPixelColor(left,cm.hsv(clr,1,0))
            strip.setPixelColor(right,cm.hsv(clr,1,0))
            break