Esempio n. 1
0
 def update(strip, num_led, num_steps_per_cycle, current_step,
            current_cycle):
     brightness = round(100 * current_step / num_steps_per_cycle)
     lamp = Pixel(255, 0, 0, brightness)
     for i in range(start, end + 1):
         strip[i] = lamp
     return 1  # Repaint
Esempio n. 2
0
 def update(strip, num_led, num_steps_per_cycle, current_step,
            current_cycle):
     r, g, b = 255, 96, 12
     for i in range(start, end + 1):
         flicker = randint(0, 40)
         strip[i] = Pixel(r - flicker, g - flicker, b - flicker, 100)
     return 1  # Repaint
Esempio n. 3
0
 def update(strip, num_led, num_steps_per_cycle, current_step,
            current_cycle):
     last_step = num_steps_per_cycle - ceil(hold_pct * num_steps_per_cycle)
     if current_step > last_step:
         return 0
     brightness = round(100 * current_step / last_step)
     if direction != 1:
         # Fade down
         brightness = 100 - brightness
     for i in range(start, end + 1):
         # Copy all the colors and change brightness.
         strip[i] = Pixel(*strip[i][0:3], brightness=brightness)
     return 1  # Repaint
Esempio n. 4
0
 def next():
     nonlocal width, b_step, led, direction
     led += direction
     if led == end + width:
         direction = -1
         led = end
     if led == start - width:
         direction = 1
         led = start
     bright = 100
     for i in range(led, led + (-direction * width), -direction):
         if start <= i <= end:
             strip[i] = Pixel(255, 0, 0, bright)
         bright -= b_step
Esempio n. 5
0
    def update(strip, num_led, num_steps_per_cycle, current_step,
               current_cycle):
        nonlocal led, direction
        led += direction
        if led == end + width:
            direction = -1
            led = end
        if led == start - width:
            direction = 1
            led = start
        bright = 100
        for i in range(start, end + 1):
            strip[i] = Pixel.BLACK
        for i in range(led, led + (-direction * width), -direction):
            if start <= i <= end:
                strip[i] = Pixel(255, 0, 0, bright)
            bright -= b_step

        return 1  # Repaint
Esempio n. 6
0
#!/usr/bin/env python3
"""Ultra simple sample on how to use the library"""
from apa102 import APA102, Pixel
import time

# Initialize the library and the strip
strip = APA102(num_led=80, global_brightness=20, mosi=10, sclk=11, order='rbg')

# Turn off all pixels (sometimes a few light up when the strip gets power)
strip.clear_strip()

# Prepare a few individual pixels through the various APIs.
strip[0] = (255, 0, 0)  # Red
strip[12] = Pixel.BLUE
strip[24] = Pixel(red=0xFF, green=0xFF, blue=0xFF, brightness=100)  # White
strip[36] = (255, 255, 0, 100)  # Yellow
strip.set_pixel_rgb(40, 0x00FF00)  # Green

# Copy the buffer to the Strip (i.e. show the prepared pixels)
strip.show()

# Wait a few Seconds, to check the result
time.sleep(20)

# Clear the strip and shut down
strip.clear_strip()
strip.cleanup()