예제 #1
0
def setColor():
    oldColor = light.getColor()
    data = json.JSONDecoder().decode(request.data)
    color = data['color']
    light.setColor(color)

    return json.JSONEncoder().encode(oldColor)
예제 #2
0
def getLight():
    return Response(
        json.dumps({
            "light": {
                "color": light.getColor(),
                "value": light.getValue()
            }
        }),
        mimetype = 'application/json'
    )
예제 #3
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>'
print '<table> <tr>' 
for set in ['a', 'b', 'w']: 

    # red = 0
    # green = 0
    # blue = 0

    colors = light.getColor(set) 

    if set in ('a', 'b'):
        red = colors[0]
        green = colors[1]
        blue = colors[2]
    else: 
        white = colors[0]

    if set == 'a': 
        print '<td><h3>Desk Light</h3>'
    elif set == 'b': 
        print '<td><h3>Window Light</h3>'
    elif set == 'w': 
        print '<td><h3>Work Light</h3>' 
예제 #4
0
def getColor():
    return Response(json.dumps(light.getColor()), mimetype = 'application/json')
예제 #5
0
def setValue(value):
    light.stopAnim()
    light.setValue(value)
    light.update()
    return repr(light.getColor())
예제 #6
0
def off():
    light.stopAnim()
    light.setValue(0)
    light.update()
    return repr(light.getColor())
예제 #7
0
def showDefaultColor():
    light.stopAnim()
    light.showDefaultColor()
    light.update()
    return repr(light.getColor())