except KeyError: logger.exception(f"""No known animation for https://weather.gc.ca/weathericons/{forecast}.gif""") animations.append(UNKNOWN_CONDITION) # Break the animations down into per-panel instructions anim_data = [] for animation, cluster in zip(animations, PANEL_CLUSTERS): for index, panel in enumerate(cluster): panel_animation = [ frame[0] + [round(frame[1] * DURATION_IN_SECONDS * 10)] for frame in animation[len(anim_data) % len(animation)] ] anim_data.append([panel, len(panel_animation)] + list(panel_animation)) # Composite the instructions into an Aurora command aurora = Aurora(IP_ADDRESS, AUTH_TOKEN) effect = { "command": "add", "animName": "Forecast", "animType": "custom", "animData": " ".join(map(str, [len(anim_data)] + list(flatten(anim_data)))), "loop": True, } # Set the effect aurora.effect_set_raw(effect) # Error handling except Exception as e: logger.exception(e)
# after calibration for a in myfunc.get_nouha(mu, sigma): print(a['meditation']) print(a['attention']) animdata = '9 ' r = rgb(a['eeg'][8]) g = rgb(a['eeg'][9]) b = rgb(a['eeg'][10]) newcolor = r + ' ' + g + ' ' + b + ' ' + '0 0 ' print(newcolor) type(newcolor) color.insert(0, newcolor) color.pop() for i in range(len(color)): animdata += index[1][i] + color[i] effect_data = { "command": "add", "animName": "Flash", "animType": "custom", "animData": animdata, "loop": True } my_aurora.effect_set_raw(effect_data) clientsock.close()
"y": new_y, "color": unset_color }) effect = {"command": "display", "animType": "static", "loop": False} while True: im = PIL.ImageGrab.grab() im.thumbnail([5, 2]) px = im.load() panel_strings = [] for panel in panel_list: color = px[panel["x"], panel["y"]] if (color != panel["color"]): panel["color"] = color r, g, b = color hsv = colorsys.rgb_to_hsv(r / 255, g / 255, b / 255) h, s, v = hsv s = min(1, 1.5 * s) rgb = colorsys.hsv_to_rgb(h, s, v) r, g, b = rgb r = math.floor(r * 255) g = math.floor(g * 255) b = math.floor(b * 255) panel_strings.append("{} 1 {} {} {} 0 10 ".format( panel["panelId"], r, g, b)) if (len(panel_strings) > 0): effect["animData"] = str( len(panel_strings)) + " " + " ".join(panel_strings) #print(effect) backsplash.effect_set_raw(effect) #time.sleep(1)