コード例 #1
0
 def __init__(self, leds=32, columns=3, gap_leds=4, skip_leds=0):
     LEDStrip.__init__(self, leds, True)
     self.driver.spi.max_speed_hz = 7000000 #12000000
     print 'Changed spi freq to %d' % self.driver.spi.max_speed_hz
     self.columns = columns
     self._column_data = [0] * columns
     self._gap_leds = gap_leds # + 1
     self._skip_leds = skip_leds
     self._column_leds = (leds - skip_leds - (self._gap_leds * (columns - 1)))/columns
     print 'Leds per col: %d' % self._column_leds
     self._color = 0.0
コード例 #2
0
 def __init__(self, leds=32, columns=3, gap_leds=4, skip_leds=0):
     LEDStrip.__init__(self, leds, True)
     self.driver.spi.max_speed_hz = 7000000  #12000000
     print 'Changed spi freq to %d' % self.driver.spi.max_speed_hz
     self.columns = columns
     self._column_data = [0] * columns
     self._gap_leds = gap_leds  # + 1
     self._skip_leds = skip_leds
     self._column_leds = (leds - skip_leds - (self._gap_leds *
                                              (columns - 1))) / columns
     print 'Leds per col: %d' % self._column_leds
     self._color = 0.0
コード例 #3
0
ファイル: main.py プロジェクト: jollex/Harmony
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()
コード例 #4
0
ファイル: main.py プロジェクト: jollex/Harmony
 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}
コード例 #5
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)
コード例 #6
0
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()

コード例 #7
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)