Exemple #1
0
class Light(object):
    def __init__(self):
        self.led_strip = LEDStrip(config.LED_COUNT)
        self.led_strip.set_master_brightness(0.9)
        self.led_strip.all_off()
        self.colors = {user['color']: False for user in config.USERS}

    def change_color(self, color, on):
        self.colors[color] = on
        self.update_light()

    def update_light(self):
        on_colors = [color for color, on in self.colors.items() if on]
        if len(on_colors) > 0:
            color = tuple(int(sum(x) / len(x)) for x in zip(*on_colors))
            self.led_strip.fill_rgb(*color)
        else:
            self.led_strip.fill_off()
        self.led_strip.update()
from raspledstrip.ledstrip import LEDStrip
from raspledstrip.LPD8806 import LPD8806SPI
from raspledstrip.animation import AlertStrobe, FillFromCenter, BreathingLight
from raspledstrip.color import Color

led_strip = LEDStrip(LPD8806SPI(36))
led_strip.all_off()

alert_color = Color(255, 0, 0, 1.0)
fill_animation = FillFromCenter(led_strip, alert_color)
fill_animation.run(1, 30, 18)
alert_animation = AlertStrobe(led_strip, alert_color)
alert_animation.run(1, 20, 24)
led_strip.all_off()
fill_animation = BreathingLight(led_strip, 0, 255, 0, 0.1, 1.0, 0, 0)
fill_animation.run(1, 30, 1000)
led_strip.all_off()

Exemple #3
0
    # render label into image draw area
    draw = ImageDraw.Draw(imgOut)
    for i in range(n):
        draw.text((0, sizey * i), label * n, fill=fgcolor, font=font)

    if rotate_angle:
        imgOut = imgOut.rotate(rotate_angle)

    return imgOut


def show_text(led, text, x_offset=0, y_offset=0, sleep=0.5):
    for char in text:
        img = txt2img(char)
        arr = np.array(img.getdata()).reshape(img.size[::-1]).T[::, ::-1]

        for x, y in np.argwhere(arr < 100):
            led_num = xy_to_led_coordinates(x + x_offset, y - y_offset)
            led.set(led_num, color_hex("#6bc325"))
        led.update()
        time.sleep(sleep)
        led.all_off()


if __name__ == '__main__':
    led = LEDStrip(100)
    led.all_off()

    show_text(led, 'NEVER GRADUATE!', x_offset=3, y_offset=1)
    # render label into image draw area
    draw = ImageDraw.Draw(imgOut)
    for i in range(n):
        draw.text((0, sizey*i), label*n, fill=fgcolor, font=font)

    if rotate_angle:
        imgOut = imgOut.rotate(rotate_angle)

    return imgOut

def show_text(led, text, x_offset=0, y_offset=0, sleep=0.5):
    for char in text:
        img = txt2img(char)
        arr = np.array(img.getdata()).reshape(img.size[::-1]).T[::, ::-1]

        for x, y in np.argwhere(arr < 100):
            led_num = xy_to_led_coordinates(x+x_offset, y-y_offset)
            led.set(led_num, color_hex("#6bc325"))
        led.update()
        time.sleep(sleep)
        led.all_off()



if __name__ == '__main__':
    led = LEDStrip(100)
    led.all_off()

    show_text(led, 'NEVER GRADUATE!', x_offset=3, y_offset=1)