Exemplo n.º 1
0
def snowRoutine(scale, pcnt, hsv):
    for x in range(settings.led_width):
        for y in range(settings.led_height - 1):
            led_init.setColorXY(x, y, led_init.getColorXY(x, y + 1))

    for x in range(settings.led_width):
        if led_init.getColorXY(x, settings.led_height - 2) and not random.randint(0, scale):
            h, s, v = hsv
            newV = int(v * (100 - random.randint(0, pcnt)) / 100)
            color = led_init.hsv2rgb_rainbow(h, s, newV)
            led_init.setColorXY(x, settings.led_height - 1, color)
        else:
            led_init.setColorXY(x, settings.led_height - 1, (0, 0, 0))
Exemplo n.º 2
0
def matrixRoutine(scale):
    for x in range(settings.led_width):
        for y in range(settings.led_height - 1):
            led_init.setColorXY(x, y, led_init.getColorXY(x, y + 1))

    for x in range(settings.led_width):
        _, g, _ = led_init.getColorXY(x, settings.led_height - 1)
        if not g:
            if not random.randint(0, scale):
                led_init.setColorXY(x, settings.led_height - 1, (0, 92, 0))
        elif g <= 16:
            led_init.setColorXY(x, settings.led_height - 1, (0, 0, 0))
        else:
            led_init.setColorXY(x, settings.led_height - 1, (0, g - 16, 0))
Exemplo n.º 3
0
def move_cars(status, size, frontColor, rearColor, carColor):
    for x in range(settings.led_width):
        for y in reversed(range(1, settings.led_height)):
            led_init.setColorXY(x, y, led_init.getColorXY(x, y - 1))
    remainder = settings.led_width % (size + 3)
    for i in range(len(status)):
        val = status[i] + 1
        if val == 0:
            r = random.randint(0, 2)
            val = r * 10
            led_init.setColorXY(remainder + r + i * (size + 3), 0, frontColor)
            led_init.setColorXY(remainder + r + i * (size + 3) + size - 1, 0, frontColor)
            for j in range(1, size - 1):
                led_init.setColorXY(remainder + r + i * (size + 3) + j, 0, carColor)
        elif val % 10 == size - 1:
            r = val // 10
            val = random.randint(-size, -size // 2)
            led_init.setColorXY(remainder + r + i * (size + 3), 0, rearColor)
            led_init.setColorXY(remainder + r + i * (size + 3) + size - 1, 0, rearColor)
            for j in range(1, size - 1):
                led_init.setColorXY(remainder + r + i * (size + 3) + j, 0, carColor)
        elif val > 0:
            r = val // 10
            for j in range(0, size):
                led_init.setColorXY(remainder + r + i * (size + 3) + j, 0, carColor)
        else:
            for j in range(0, size + 2):
                led_init.setColorXY(remainder + i * (size + 3) + j, 0, (0, 0, 0))
        status[i] = val
    return status
Exemplo n.º 4
0
def rainbowRoutine(status, type_):
    for x in reversed(range(1, settings.led_width)):
        for y in range(settings.led_height):
            led_init.setColorXY(x, y, led_init.getColorXY(x - 1, y))
    if type_:
        color = led_init.hsv2rgb_rainbow(int(status * 255 / (settings.led_width - 1)), 255, 128)
    else:
        color = led_init.hsv2rgb(int(status * 255 / (settings.led_width - 1)), 255, 128)
    for y in range(settings.led_height):
        led_init.setColorXY(0, y, color)
    return (status + 1) % (settings.led_width - 1)
Exemplo n.º 5
0
def move_clouds(status, size, color):
    for x in reversed(range(1, settings.led_width)):
        for y in range(settings.led_height):
            led_init.setColorXY(x, y, led_init.getColorXY(x - 1, y))
    val = status + 1
    if val >= 0:
        if val == 0:
            val = random.randint(0, settings.led_height - 2) * 10
        k = val // 10
        led_init.setColorXY(0, k, color)
        led_init.setColorXY(0, k + 1, color)
        if val % 10 == 2 or val % 10 == 3:
            led_init.setColorXY(0, k + 2, color)
        else:
            led_init.setColorXY(0, k + 2, (0, 0, 0))

        if val % 10 == 5:
            val = -1 * size
    else:
        for y in range(settings.led_height):
            led_init.setColorXY(0, y, (0, 0, 0))
    return val