Ejemplo n.º 1
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)
Ejemplo n.º 2
0
import light
import color

print "<h1>RGB Light Control</h1>"

if request: 
    if 'red' in request: 
        red=int(request['red'][0])
        green=int(request['green'][0])
        blue=int(request['blue'][0])
        if request['light'][0].lower() == 'a': 
            color.setA(light.ser, red, green, blue)
        elif request['light'][0].lower() == 'b': 
            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: