def set_scene(address, scene): if scene == 'bright': device = gatt.connect(address) s = state.from_rgb(255, 255, 255, 100) state_map[address] = s s.write(device) elif scene == 'night': device = gatt.connect(address) s = state.from_rgb(48, 24, 96, 25) state_map[address] = s s.write(device)
def GET(self, address): i = web.input() r = utils.try_get_input(i, 'red', 0) g = utils.try_get_input(i, 'green', 0) b = utils.try_get_input(i, 'blue', 0) duration = utils.try_get_input(i, 'duration', 0.25) action.thread.queue.put(action.ActionFlash(state.from_rgb(r, g, b, 100), duration))
def GET(self, address): i = web.input() r = utils.try_get_input(i, 'red', 0) g = utils.try_get_input(i, 'green', 0) b = utils.try_get_input(i, 'blue', 0) duration = utils.try_get_input(i, 'duration', 0.25) action.thread.queue.put( action.ActionFlash(state.from_rgb(r, g, b, 100), duration))
import gatt import state import time import random device = gatt.connect('20:C3:8F:F3:09:98') s = state.from_rgb(0, 0, 0, 5) while True: s.set_rgb(random.randrange(25, 100), random.randrange(25, 100), random.randrange(25, 100)) s.write(device)