diff --git a/examples/led_animation_all_animations.py b/examples/led_animation_all_animations.py index 3b7a20e..0d55804 100644 --- a/examples/led_animation_all_animations.py +++ b/examples/led_animation_all_animations.py @@ -21,7 +21,7 @@ from adafruit_led_animation.animation.rainbowcomet import RainbowComet from adafruit_led_animation.animation.solid import Solid from adafruit_led_animation.animation.colorcycle import ColorCycle from adafruit_led_animation.animation.rainbow import Rainbow -from adafruit_led_animation.animation.customcolorschase import CustomColorsChase +from adafruit_led_animation.animation.customcolorchase import CustomColorChase from adafruit_led_animation.sequence import AnimationSequence from adafruit_led_animation.color import PURPLE, WHITE, AMBER, JADE, MAGENTA, ORANGE @@ -44,9 +44,7 @@ sparkle_pulse = SparklePulse(pixels, speed=0.1, period=3, color=JADE) rainbow_comet = RainbowComet(pixels, speed=0.1, tail_length=7, bounce=True) rainbow_chase = RainbowChase(pixels, speed=0.1, size=3, spacing=2, step=8) rainbow_sparkle = RainbowSparkle(pixels, speed=0.1, num_sparkles=15) -custom_colors_chase = CustomColorsChase( - pixels, speed=0.1, size=2, spacing=3, colors=[ORANGE, WHITE, JADE] -) +custom_color_chase = CustomColorChase(pixels, speed=0.1, size=2, spacing=3,colors=[ORANGE, WHITE, JADE]) animations = AnimationSequence( @@ -61,7 +59,7 @@ animations = AnimationSequence( rainbow_comet, sparkle_pulse, rainbow_chase, - custom_colors_chase, + custom_color_chase, advance_interval=5, auto_clear=True, ) diff --git a/examples/led_animation_customcolorchase.py b/examples/led_animation_customcolorchase.py new file mode 100644 index 0000000..85b4e9e --- /dev/null +++ b/examples/led_animation_customcolorchase.py @@ -0,0 +1,60 @@ +""" +This example displays the basic animations in sequence, at a five second interval. + +For NeoPixel FeatherWing. Update pixel_pin and pixel_num to match your wiring if using +a different form of NeoPixels. + +This example may not work on SAMD21 (M0) boards. +""" +import board +import neopixel + +from adafruit_led_animation.animation.customcolorchase import CustomColorChase +from adafruit_led_animation.sequence import AnimationSequence +# colorwheel only needed for rainbowchase example +from adafruit_led_animation.color import colorwheel +# Colors for customcolorchase examples +from adafruit_led_animation.color import PINK, GREEN, RED, BLUE + +# Update to match the pin connected to your NeoPixels +pixel_pin = board.D5 +# Update to match the number of NeoPixels you have connected +pixel_num = 30 +brightness = 0.3 + +pixels = neopixel.NeoPixel( + pixel_pin, pixel_num, brightness=brightness, auto_write=False +) + +# colors default to RAINBOW as defined in color.py +custom_color_chase_rainbow = CustomColorChase(pixels, speed=0.1, size=2, spacing=3) +custom_color_chase_rainbow_r = CustomColorChase(pixels, speed=0.1, size=3, spacing=3,reverse=True) + +# Example with same colors as RainbowChase +steps=30 +#This was taken from rainbowchase.py +rainbow_colors = [colorwheel(n % 256) for n in range(0, 512, steps)] +#Now use rainbow_colors with CustomColorChase +custom_color_chase_rainbowchase = CustomColorChase(pixels, speed=0.1, colors=rainbow_colors, size=2, spacing=3) + +custom_color_chase_bgp = CustomColorChase( + pixels, speed=0.1, colors=[BLUE, GREEN, PINK], size=3, spacing=2 +) + +# Can use integer values for color, 0 is black +custom_color_chase_br = CustomColorChase( + pixels, speed=0.1, colors=[BLUE, 0, RED, 0], size=2, spacing=0 ) + +animations = AnimationSequence( + custom_color_chase_rainbow, + custom_color_chase_rainbow_r, + custom_color_chase_rainbowchase, + custom_color_chase_bgp, + custom_color_chase_br, + advance_interval=6, + #advance_on_cycle_complete=True, + auto_clear=True, +) + +while True: + animations.animate()