Ejemplo n.º 1
0
def hsv_rainbow(strip: BaseStrip, delay: int):
    for i in range(1, 360):
        r, g, b = hsv2rgb(i / 360, 1, 1)
        strip.fill((r, g, b))
        strip.show()

        time.sleep(delay / 1000)
Ejemplo n.º 2
0
def rainbow_cycle(strip: BaseStrip, delay: int = 20):
    for j in range(256 * 5):
        for i in range(strip.led_count):
            color = wheel(int((i * 256 / strip.led_count) + j) & 255)
            strip[i] = color
        strip.show()
        time.sleep(delay / 1000)
Ejemplo n.º 3
0
def strobe(strip: BaseStrip, color: ColorTuple, count: int, delay: int = 100):
    for i in range(count):
        strip.fill(color)
        strip.show()
        time.sleep(delay / 1000)
        strip.fill((0, 0, 0))
        strip.show()
        time.sleep(delay / 1000)
Ejemplo n.º 4
0
def random_burst(strip: BaseStrip, delay: int):
    index = random.randint(0, strip.led_count - 1)
    hue = random.randint(0, 359)

    r, g, b = hsv2rgb(hue / 360, 1, 1)
    strip[index] = (r, g, b)
    strip.show()
    time.sleep(delay / 1000)
Ejemplo n.º 5
0
def improved_alternating(strip: BaseStrip,
                         colors: list[ColorTuple],
                         size: int,
                         offset: int = 0,
                         delay: int = 50):
    for i in range(strip.led_count):
        strip[i] = colors[(i + offset) % len(colors)]

    strip.show()
    time.sleep(delay / 1000)
Ejemplo n.º 6
0
def running_lights(strip: BaseStrip, color: ColorTuple, delay: int = 50):
    p = 0
    for j in range(strip.led_count * 2):
        p += 1
        for i in range(strip.led_count):
            strip[i] = tuple(
                map(lambda c: ((math.sin(i + p) * 127 + 128) / 255) * c,
                    color))

        strip.show()
        time.sleep(delay / 1000)
Ejemplo n.º 7
0
def alternating(strip: BaseStrip,
                color_one: ColorTuple,
                color_two: ColorTuple,
                size: int,
                delay: int = 100):
    for j in range(2):
        for i in range(strip.led_count):
            if i % size * 2 < size:
                strip[i] = color_one
            else:
                strip[i] = color_two

        color_one, color_two = color_two, color_one

        strip.show()
        time.sleep(delay / 1000)
Ejemplo n.º 8
0
def scanner(strip: BaseStrip,
            color: ColorTuple,
            size: int,
            speed_delay: int = 10,
            return_delay: int = 50):
    for i in itertools.chain(range(strip.led_count - size - 2),
                             reversed(range(strip.led_count - size - 2))):
        strip.fill((0, 0, 0))
        strip[i] = int(color[0] / 10), int(color[1] / 10), int(color[2] / 10)

        for j in range(1, size + 1):
            strip[i + j] = color

        strip[i + size + 1] = int(color[0] / 10), int(color[1] / 10), int(
            color[2] / 10)
        strip.show()
        time.sleep(speed_delay / 1000)
Ejemplo n.º 9
0
def meteor_rain(strip: BaseStrip,
                color: ColorTuple,
                size: int,
                decay: int,
                random_decay: bool = True,
                delay: int = 30):
    strip.fill((0, 0, 0))

    for i in range(strip.led_count * 2):
        for j in range(strip.led_count):
            if not random_decay or random.random() > 0.5:
                fade_to_black(strip, j, decay)

        for j in range(size):
            if strip.led_count > i - j >= 0:
                strip[i - j] = color

        strip.show()
        time.sleep(delay / 1000)
Ejemplo n.º 10
0
def color_wipe(strip: BaseStrip, color: ColorTuple, delay: int = 50):
    for i in range(strip.led_count):
        strip[i] = color
        strip.show()
        time.sleep(delay / 1000)
Ejemplo n.º 11
0
def police_lights(strip: BaseStrip, delay: int):
    for i in range(strip.led_count):
        strip[i] = (255, 0, 0)
        strip[strip.led_count - 1 - i] = (0, 0, 255)
        strip.show()
        time.sleep(delay / 1000)
Ejemplo n.º 12
0
def fade_in_n_out(strip: BaseStrip, color: ColorTuple, delay: int):
    for i in itertools.chain(range(256), reversed(range(256))):
        c = calculate_color_percent(color, i / 256)
        strip.fill(c)
        strip.show()
        time.sleep(delay / 1000)