Пример #1
2
            color.setB(light.ser, red, green, blue)
        elif request['light'][0].lower() == 'ab': 
            color.setA(light.ser, red, green, blue)
            color.setB(light.ser, red, green, blue)
            
    elif 'color' in request: 
        color=request['color'][0]
        if request['light'][0].lower() == 'a': 
            light.colors[color].setA() 
        elif request['light'][0].lower() == 'b': 
            light.colors[color].setB() 
        elif request['light'][0].lower() == 'ab': 
            light.colors[color].setA() 
            light.colors[color].setB() 
    elif 'brightness' in request: 
        color.setW(light.ser, int(request['brightness'][0]))
    
    elif 'off' in request: 
        color.setA(light.ser, 0, 0, 0)
        color.setB(light.ser, 0, 0, 0)
        color.setW(light.ser, 0) 
    elif 'on' in request: 
        color.setA(light.ser, 255, 15, 0)
        color.setB(light.ser, 255, 15, 0)
        color.setW(light.ser, 255)



print '<h1><a href="index.py?off">All Lights off</a></h1>' 

print '<h2>Enter your own RGB color or pick from the list. </h2>'
Пример #2
0
def fade(ser, fTime, light, start, end): 
    colors = 3
    for i in range(65): 
        current = list() 
        if light.lower() == 'w': 
            colors = 1
        for c in range(colors): 
            if end[c] > start[c]: 
                current.append(int((end[c]-start[c])/256.0 * i ** exp + start[c]))
            else: 
                current.append(int(start[c] - (start[c]-end[c])/255.0 * i ** exp))
                
        if light.lower() == "a":
            color.setA(ser, current[0], current[1], current[2])
        elif light.lower() == "b":
            color.setB(ser, current[0], current[1], current[2])
        elif light.lower() == "w": 
            color.setW(ser, current[0])
            
        time.sleep(fTime/64.0)