示例#1
0
def my_index():
    # start app
    global thread
    if thread is None:
        socketio.start_background_task(target=background_read)
    token = grid_handling.get_grid()
    return flask.render_template("index.html", token=token)
示例#2
0
def toggle_mod_inactive():
    # arguments: id of module (id: int)
    # function: make all squares inactive
    id = int(flask.request.args.get("id"))
    #grid changes and resultant grid
    grid_handling.toggle_module_active(id, False)
    token = grid_handling.get_grid()
    return flask.render_template("index.html", token=token)
示例#3
0
def toggle_active():
    # arguments: id of grid square (id: int)
    # function: will change active status of square
    id = flask.request.args.get("id")
    #grid changes and resultant grid
    active = grid_handling.toggle_active(id)
    token = grid_handling.get_grid()
    #arduino write
    t.write_pixels([0, 1, 2, 3, 4])
    return flask.render_template("index.html", token=token)
示例#4
0
def toggle_mod_color():
    # arguments: id of module (id: int), color to set module to (color: hex)
    # function: change color of all squares in module
    #           light up RGB LED on arduino with request color
    id = int(flask.request.args.get("id"))
    color = flask.request.args.get("color")
    #RGB conversion
    rgb = tuple(int(color[i:i + 2], 16) for i in (0, 2, 4))
    #grid changes and resultant grid
    grid_handling.toggle_module_color(id, rgb)
    token = grid_handling.get_grid()
    return flask.render_template("index.html", token=token)