|
| 1 | +""" |
| 2 | +This example displays the basic animations in sequence, at a five second interval. |
| 3 | +
|
| 4 | +For NeoPixel FeatherWing. Update pixel_pin and pixel_num to match your wiring if using |
| 5 | +a different form of NeoPixels. |
| 6 | +
|
| 7 | +This example may not work on SAMD21 (M0) boards. |
| 8 | +""" |
| 9 | +import board |
| 10 | +import neopixel |
| 11 | + |
| 12 | +from adafruit_led_animation.animation.customcolorchase import CustomColorChase |
| 13 | +from adafruit_led_animation.sequence import AnimationSequence |
| 14 | +# colorwheel only needed for rainbowchase example |
| 15 | +from adafruit_led_animation.color import colorwheel |
| 16 | +# Colors for customcolorchase examples |
| 17 | +from adafruit_led_animation.color import PINK, GREEN, RED, BLUE |
| 18 | + |
| 19 | +# Update to match the pin connected to your NeoPixels |
| 20 | +pixel_pin = board.D5 |
| 21 | +# Update to match the number of NeoPixels you have connected |
| 22 | +pixel_num = 30 |
| 23 | +brightness = 0.3 |
| 24 | + |
| 25 | +pixels = neopixel.NeoPixel( |
| 26 | + pixel_pin, pixel_num, brightness=brightness, auto_write=False |
| 27 | +) |
| 28 | + |
| 29 | +# colors default to RAINBOW as defined in color.py |
| 30 | +custom_color_chase_rainbow = CustomColorChase(pixels, speed=0.1, size=2, spacing=3) |
| 31 | +custom_color_chase_rainbow_r = CustomColorChase(pixels, speed=0.1, size=3, spacing=3,reverse=True) |
| 32 | + |
| 33 | +# Example with same colors as RainbowChase |
| 34 | +steps=30 |
| 35 | +#This was taken from rainbowchase.py |
| 36 | +rainbow_colors = [colorwheel(n % 256) for n in range(0, 512, steps)] |
| 37 | +#Now use rainbow_colors with CustomColorChase |
| 38 | +custom_color_chase_rainbowchase = CustomColorChase(pixels, speed=0.1, colors=rainbow_colors, size=2, spacing=3) |
| 39 | + |
| 40 | +custom_color_chase_bgp = CustomColorChase( |
| 41 | + pixels, speed=0.1, colors=[BLUE, GREEN, PINK], size=3, spacing=2 |
| 42 | +) |
| 43 | + |
| 44 | +# Can use integer values for color, 0 is black |
| 45 | +custom_color_chase_br = CustomColorChase( |
| 46 | + pixels, speed=0.1, colors=[BLUE, 0, RED, 0], size=2, spacing=0 ) |
| 47 | + |
| 48 | +animations = AnimationSequence( |
| 49 | + custom_color_chase_rainbow, |
| 50 | + custom_color_chase_rainbow_r, |
| 51 | + custom_color_chase_rainbowchase, |
| 52 | + custom_color_chase_bgp, |
| 53 | + custom_color_chase_br, |
| 54 | + advance_interval=6, |
| 55 | + #advance_on_cycle_complete=True, |
| 56 | + auto_clear=True, |
| 57 | +) |
| 58 | + |
| 59 | +while True: |
| 60 | + animations.animate() |
0 commit comments