Esempio n. 1
0
def wave(led_max=150, frame_delay=0.02, frame_count=None, initial_brightness=None, direction=None):
    """
    Creates a wave effect through the PiGlow board.

    Args (all are optional):
        led_max (int): the LED brightness at the peak of the wave.
        frame_delay (float): the time between each transition.
        frame_count (int): the number of transitions in a single wave.
        initial_brightness (int): the current brightness of the LEDs.
        direction (string): either 'inward' or 'outward'.
    """
    if initial_brightness is None:
        initial_brightness = min(piglow.get())

    if direction is None:
        direction = 'outward'

    if frame_count is None:
        frame_count = len(LEDS)

    if direction == 'outward':
        LEDS.reverse()

    led_set_count = len(LEDS)

    # initialise all of the LEDs
    piglow.all(initial_brightness)
    piglow.show()

    wave = _create_led_sine_wave(led_max, frame_count, initial_brightness, led_set_count)

    for wave_point in _window(wave, led_set_count):
        for i, led_set in enumerate(LEDS):
            for led in led_set:
                piglow.led(led, int(wave_point[i]))

            piglow.show()
            sleep(frame_delay)
Esempio n. 2
0
def wave(led_max=150, frame_delay=0.02, frame_count=None, initial_brightness=None, direction=None):
    """
    Creates a wave effect through the PiGlow board.

    Args (all are optional):
        led_max (int): the LED brightness at the peak of the wave.
        frame_delay (float): the time between each transition.
        frame_count (int): the number of transitions in a single wave.
        initial_brightness (int): the current brightness of the LEDs.
        direction (string): either 'inward' or 'outward'.
    """
    if initial_brightness is None:
        initial_brightness = min(piglow.get())

    if direction is None:
        direction = 'outward'

    if frame_count is None:
        frame_count = len(LEDS)

    if direction == 'outward':
        LEDS.reverse()

    led_set_count = len(LEDS)

    # initialise all of the LEDs
    piglow.all(initial_brightness)
    piglow.show()

    wave = _create_led_sine_wave(led_max, frame_count, initial_brightness, led_set_count)

    for wave_point in _window(wave, led_set_count):
        for i, led_set in enumerate(LEDS):
            for led in led_set:
                piglow.led(led, int(wave_point[i]))

            piglow.show()
            sleep(frame_delay)
Esempio n. 3
0
#!/usr/bin/env python

import time

import piglow


i = 0
x = 0

while True:
    if i % 32 == 0:
        piglow.leg((x % 3), 64)
        x += 1
    piglow.set(0, list(map(lambda x: x - 1 if x > 1 else 0, piglow.get())))
    piglow.show()
    time.sleep(0.1)
    i += 1