animations = AnimationSequence( AnimationGroup(Blink(cpb.pixels, BLINK_SPEED, BLINK_INITIAL_COLOR), Blink(strip_pixels, BLINK_SPEED, BLINK_INITIAL_COLOR), sync=True), AnimationGroup( Comet(cpb.pixels, COMET_SPEED, color.MAGENTA, tail_length=CPB_COMET_TAIL_LENGTH, bounce=CPB_COMET_BOUNCE), Comet(strip_pixels, COMET_SPEED, color.MAGENTA, tail_length=STRIP_COMET_TAIL_LENGTH, bounce=STRIP_COMET_BOUNCE)), AnimationGroup(Sparkle(cpb.pixels, SPARKLE_SPEED, color.PURPLE), Sparkle(strip_pixels, SPARKLE_SPEED, color.PURPLE)), ) animation_color = None mode = 0 blanked = False while True: ble.start_advertising(advertisement) # Start advertising. was_connected = False while not was_connected or ble.connected: if not blanked: # If LED-off signal is not being sent... animations.animate() # Run the animations. if ble.connected: # If BLE is connected... was_connected = True
import board import neopixel from adafruit_led_animation.animation.sparkle import Sparkle from adafruit_led_animation.animation.sparklepulse import SparklePulse from adafruit_led_animation.sequence import AnimationSequence from adafruit_led_animation.color import AMBER, JADE # Update to match the pin connected to your NeoPixels pixel_pin = board.D6 # Update to match the number of NeoPixels you have connected pixel_num = 32 pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False) sparkle = Sparkle(pixels, speed=0.05, color=AMBER, num_sparkles=10) sparkle_pulse = SparklePulse(pixels, speed=0.05, period=3, color=JADE) animations = AnimationSequence( sparkle, sparkle_pulse, advance_interval=5, auto_clear=True, ) while True: animations.animate()
tail_length=50, bounce=False, colorwheel_offset=50, step=4) fuego = RainbowComet(pixel_map[4], speed=0.05, colorwheel_offset=40, step=2, tail_length=40) fuego2 = RainbowComet(pixel_map[4], speed=0.02, colorwheel_offset=40, step=2, tail_length=40) lava = Comet(pixel_map[4], speed=0, color=ORANGE, tail_length=40, bounce=False) sparkle = Sparkle(pixel_map[3], speed=0.05, color=BLUE, num_sparkles=10) sparkle2 = Sparkle(pixels, speed=0.05, color=PURPLE, num_sparkles=4) sparkle3 = Sparkle(pixels, speed=0, color=WHITE, num_sparkles=1) carve_left = Solid(pixel_map[0], color=GREEN) carve_right = Solid(pixel_map[1], color=RED) black_left = Solid(pixel_map[0], color=BLACK, name="BLACK") black_right = Solid(pixel_map[1], color=BLACK) # Animations Playlist - reorder as desired. AnimationGroups play at the same time animations = AnimationSequence( AnimationGroup( fuego, fuego2, lava, sparkle, ),
pixel_pin = board.A1 pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=1, auto_write=False) # Animation Setup rainbow = Rainbow(pixels, speed=speeds[current_speed], period=2, name="rainbow", step=3) sparkle = Sparkle(pixels, speed=speeds[current_speed], color=WHITE, name="sparkle") rainbowfade = RainbowFade(pixels, speed=speeds[current_speed], name="rainbowfade") solid = Solid(pixels, color=colorwheel(0), name="solid") # Animation Sequence Playlist -- rearrange to change the order of animations animations = AnimationSequence( rainbow, rainbowfade, solid, sparkle, auto_clear=True, auto_reset=True,
rainbowfade = RainbowFade(pixels, speed=0.4, name="rainbowfade") powerup = RainbowComet(pixels, speed=0, tail_length=50, bounce=False) off = Solid(pixels, color=BLACK) #startup animation will play just once startup = AnimateOnce(powerup) #starrynight and fire are animation groups with layered effects. starrynight = AnimationGroup( SparklePulse(pixels, speed=0.01, color=(0, 0, 150), period=1), Comet(pixels, speed=0, tail_length=8, color=(150, 150, 150), bounce=False), ) fire = AnimationGroup( Comet(pixels, speed=0, tail_length=1, color=BLACK), Sparkle(pixels, speed=0.05, num_sparkles=10, color=AMBER), Sparkle(pixels, speed=0.05, num_sparkles=10, color=RED), Sparkle(pixels, speed=0.05, num_sparkles=20, color=ORANGE), Sparkle(pixels, speed=0.05, num_sparkles=5, color=0xFF7D13), Sparkle(pixels, speed=0.05, num_sparkles=10, color=BLACK), ) # Here is the animation playlist where you set the order of modes animations = AnimationSequence( readingLight, fire, rainbow, starrynight, rainbowfade, brightWhite,
pixels.brightness = pixel_brightness magtag.peripherals.neopixel_disable = False strip = neopixel.NeoPixel(strip_pin, strip_num, brightness=strip_brightness, auto_write=False) # Create animations in sequences and groups. animations = AnimationSequence( AnimationGroup( ColorCycle(pixels, cycle_speed, color_cycle_colors), ColorCycle(strip, cycle_speed, color_cycle_colors), sync=True, ), AnimationGroup( Sparkle(pixels, sparkle_speed, sparkle_color, 15), Sparkle(strip, sparkle_speed, sparkle_color, 1), ), AnimationSequence( AnimateOnce( AnimationGroup( Comet(pixels, magtag_comet_speed, comet_one_color, tail_length=magtag_comet_tail), Comet(strip, strip_comet_speed, comet_one_color, tail_length=strip_comet_tail), ), AnimationGroup(