def takeCommand(command): if "turn" in command: return led_modes.mode_static() mode = findMode(command) colours = findColours(command) if mode == led_modes.mode_breathe: md = led_modes.mode_breathe(colours,0.04) return md if mode == led_modes.mode_strobe: return led_modes.mode_strobe(colours,0.04)
def mode_query_interpreter(queries): mode = None colours = None try: mode = find_mode(search_q(queries, 'mode')) colours = [] colours_q = search_q(queries, "hexcolour", return_list=True) for colour in colours_q: colours.append(rbgLib.hex_to_colour(colour)) print colours except Exception: print Exception if mode == led_modes.mode_breathe: md = led_modes.mode_breathe( colours, search_q( queries, "period", fallback=0.01)) rgbLEDx.bind_mode(md) elif mode == led_modes.mode_alert: md = led_modes.mode_alert(colours[0]) rgbLEDx.interruptMode(md, pause=True, resume_thread=True) elif mode == led_modes.mode_strobe: md = led_modes.mode_strobe( colours, search_q( queries, "period", fallback=0.02)) rgbLEDx.bind_mode(md) #elif mode == led_modes.None: # TODO I'm working on a 'mode' that kills all modes and turns the LEDs elif mode == led_modes.mode_static: md = led_modes.mode_static( colours[0]) rgbLEDx.bind_mode(md) #elif mode == led_modes.None: # TODO I'm working on a 'mode' that kills all modes and turns the LEDs elif mode == led_modes.mode_rainbow: md =led_modes.mode_rainbow( search_q( queries, "period", fallback=0.01)) rgbLEDx.bind_mode(md) elif mode == led_modes.mode_fadeto: md =led_modes.mode_fadeto( colours[0], search_q( queries, "period", fallback=0.01)) rgbLEDx.bind_mode(md) else: rgbLEDx.set_colour(rbgLib.orange)