Exemplo n.º 1
0
def blink_color(lifx: Group,
                colors: Optional[ColorTheme] = None,
                blink_time_secs=.5,
                how_long_secs=8):
    """change colors on lights every `blink_time_secs`"""
    num_cycles = math.ceil(how_long_secs / blink_time_secs)
    theme = colors_to_theme(colors) or (Colors.COPILOT_BLUE,
                                        Colors.COPILOT_DARK_BLUE)
    with lifx.reset_to_orig():
        for _, color in zip(range(num_cycles), cycle(theme)):
            lifx.set_color(color)
            sleep(blink_time_secs)
Exemplo n.º 2
0
def rainbow(lifx: Group,
            colors: Optional[ColorTheme] = Themes.rainbow,
            duration_secs=0.5,
            smooth=False,
            num_repeats=1):
    """similar to blink_color"""
    theme = colors_to_theme(colors)
    transition_time_ms = duration_secs * 1000 if smooth else 0
    rapid = duration_secs < 1
    with lifx.reset_to_orig():
        for _ in range(num_repeats):
            for color in theme:
                lifx.set_color(color, transition_time_ms, rapid)
                sleep(duration_secs)
Exemplo n.º 3
0
def fireworks(lifx: Group):
    """make lights look like fireworks"""
    start_color = Colors.SNES_LIGHT_PURPLE
    with lifx.reset_to_orig():
        lifx.set_color(start_color)
        sleep(1)
        for pers in (500, 250, 125, 60, 30):
            num_cycles = 1000 // pers
            _set_waveforms(lifx,
                           Waveform.pulse,
                           start_color,
                           Colors.SNES_DARK_PURPLE,
                           period_msec=pers,
                           num_cycles=num_cycles,
                           reduce_sleep_msecs=100)
Exemplo n.º 4
0
def _set_waveforms(lifx: Group,
                   waveform: Waveform,
                   start_color: Color,
                   end_color: Color,
                   *,
                   period_msec=4000,
                   num_cycles=4,
                   skew_ratio=.5,
                   reduce_sleep_msecs=0):
    lifx.turn_on()
    lifx.set_color(start_color)
    lifx.set_waveform(waveform,
                      end_color,
                      period_msec,
                      num_cycles,
                      skew_ratio=skew_ratio)
    sleep((period_msec * num_cycles - reduce_sleep_msecs) / 1000)