import time import io import xled import random discovered_device = xled.discover.discover() print('discovered_device') control = xled.ControlInterface(discovered_device.ip_address, discovered_device.hw_address) print('got control') control.set_mode('movie') leds = [] for x in range(105): leds.insert(0, False) nr_orange = 30 i = nr_orange while i > 0: r = random.randint(0,104) if (not leds[r]): leds[r] = True i = i-1 red_color = bytes([255,10,0]) orange_color = bytes([230,50,0]) while True: with io.BytesIO() as m: for s in range(5): r_off = random.randint(1,nr_orange) r_on = random.randint(1,105-nr_orange) for x in range(105): if (leds[x]): if (r_off == 1): leds[x] = False r_off = r_off - 1 else: if (r_on == 1): leds[x] = True r_on = r_on - 1 for x in range(105): m.write(orange_color if leds[x] else red_color) m.seek(0) print('set led movie full') control.set_led_movie_full(m) print('set led movie config') control.set_led_movie_config(1, 1, 105) time.sleep(1)