Example #1
0
)

# speed color mode
pulse_rings_m1 = Pulse(pixel_ringsAll, speed=0.02, color=RED, period=BEAT / 2)
pulse_jewel_m1 = Pulse(pixel_jewel, speed=0.02, color=RED, period=BEAT / 2)
comet_stripA_m1 = Comet(
    pixel_stripA, speed=b64TH, color=RED, tail_length=9, bounce=False
)
comet_stripB_m1 = Comet(
    pixel_stripB, speed=b64TH, color=RED, tail_length=9, bounce=False
)

solid_white = Solid(pixel_ringsAll, color=WHITE)

# ---Anim Modes---
vu_strip_animations_mode0 = AnimationGroup(comet_stripA_m0, comet_stripB_m0, sync=True)
vu_strip_animations_mode1 = AnimationGroup(comet_stripA_m1, comet_stripB_m1, sync=True)

#  ---Audio Setup---
if mode_state:
    BGM = "/lucio/bgmheal.mp3"
else:
    BGM = "/lucio/bgmspeed.mp3"
sample0 = audiomp3.MP3Decoder(open(BGM, "rb"))
FX = "/lucio/shoot.mp3"
sample1 = audiomp3.MP3Decoder(open(FX, "rb"))
speaker.play(mixer)
mixer.voice[0].play(sample0, loop=True)
mixer.voice[0].level = 0.3 * VOLUME_MULT
mixer.voice[1].level = 0.7 * VOLUME_MULT
Example #2
0
from adafruit_led_animation.group import AnimationGroup
from adafruit_led_animation.sequence import AnimationSequence

import adafruit_led_animation.color as color

strip_pixels = neopixel.NeoPixel(board.A1,
                                 30,
                                 brightness=0.5,
                                 auto_write=False)
cp.pixels.brightness = 0.5

animations = AnimationSequence(
    # Synchronized to 0.5 seconds. Ignores the second animation setting of 3 seconds.
    AnimationGroup(
        Blink(cp.pixels, 0.5, color.CYAN),
        Blink(strip_pixels, 3.0, color.AMBER),
        sync=True,
    ),
    # Different speeds
    AnimationGroup(
        Comet(cp.pixels, 0.1, color.MAGENTA, tail_length=5),
        Comet(strip_pixels, 0.01, color.MAGENTA, tail_length=15),
    ),
    # Different animations
    AnimationGroup(
        Blink(cp.pixels, 0.5, color.JADE),
        Comet(strip_pixels, 0.05, color.TEAL, tail_length=15),
    ),
    # Sequential animations on the built-in NeoPixels then the NeoPixel strip
    Chase(cp.pixels, 0.05, size=2, spacing=3, color=color.PURPLE),
    Chase(strip_pixels, 0.05, size=2, spacing=3, color=color.PURPLE),
Example #3
0
chase4 = Chase(rect4, speed=0.1, size=3, spacing=6, color=WHITE)
#pulse4 = Pulse(rect4, speed=0.1, period=3, color=0x00C000)
sparkle4 = Sparkle(rect4, speed=0.1, color=PURPLE, num_sparkles=10)
solid4 = Solid(rect4, color=0x004000)
#rainbow4 = Rainbow(rect4, speed=0.1, period=2)
sparkle_pulse4 = SparklePulse(rect4, speed=0.1, period=3, color=0x00C000)
rainbow_comet4 = RainbowComet(rect4, speed=0.1, tail_length=7, bounce=True)
rainbow_chase4 = RainbowChase(rect4, speed=0.1, size=3, spacing=2, step=8)
#rainbow_sparkle4 = RainbowSparkle(rect4, speed=0.1, num_sparkles=15)
custom_color_chase4 = CustomColorChase(rect4,
                                       speed=0.1,
                                       size=2,
                                       spacing=3,
                                       colors=[ORANGE, WHITE, JADE])

animations = AnimationSequence(AnimationGroup(comet, comet2, comet3, comet4),
                               AnimationGroup(blink, blink2, blink3, blink4),
                               AnimationGroup(colorcycle, colorcycle2,
                                              colorcycle3, colorcycle4),
                               AnimationGroup(chase, chase2, chase3, chase4),
                               AnimationGroup(sparkle, sparkle2, sparkle3,
                                              sparkle4),
                               AnimationGroup(solid, solid2, solid3, solid4),
                               AnimationGroup(rainbow_comet, rainbow_comet2,
                                              rainbow_comet3, rainbow_comet4),
                               AnimationGroup(sparkle_pulse, sparkle_pulse2,
                                              sparkle_pulse3, sparkle_pulse4),
                               AnimationGroup(rainbow_chase, rainbow_chase2,
                                              rainbow_chase3, rainbow_chase4),
                               AnimationGroup(custom_color_chase,
                                              custom_color_chase2,
# the keyboard object!
cc = ConsumerControl(usb_hid.devices)
# our array of button objects
buttons = []

# make all pin objects, make them inputs w/pullups
for pin in buttonpins:
    button = digitalio.DigitalInOut(pin)
    button.direction = digitalio.Direction.INPUT
    button.pull = digitalio.Pull.UP
    buttons.append(button)

animations = AnimationSequence(
    AnimationGroup(
        Pulse(pixels, speed=0.05, color=WHITE, period=6),
        Solid(internal_pixel, color=BLACK),
    ), )

print("Waiting for button presses")

while True:
    # animate neopixel jewel
    animations.animate()
    # check each button
    for button in buttons:
        if not button.value:  # pressed?
            i = buttons.index(button)

            print("Button #%d Pressed" % i)

            while not button.value:
magtag = MagTag()
boardPixels = magtag.peripherals.neopixels
boardPixels.brightness = boardBrightness
magtag.peripherals.neopixel_disable = False
stripPixels = neopixel.NeoPixel(stripPin,
                                stripCnt,
                                brightness=stripBrightness,
                                auto_write=False)

###   Animation Sequences & Groups   ###
# Creates and organizes the animations

animations = AnimationSequence(
    AnimationGroup(
        Solid(boardPixels, WHITE),
        ColorCycle(stripPixels, cycleSpeed, cycleColors),
        sync=True,
    ),
    AnimationSequence(
        AnimateOnce(
            AnimationGroup(
                Solid(boardPixels, WHITE),
                Comet(stripPixels,
                      stripCometSpeed,
                      cometColorA,
                      tail_length=stripCometTailLen),
            ),
            AnimationGroup(
                Solid(boardPixels, WHITE),
                Comet(stripPixels,
                      stripCometSpeed,
Example #6
0
    45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
    66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83
    ], individual_pixels=True)



# LED ANIMATIONS -----------------------------------------------------------

RAINBOW = Rainbow(PIXEL_MAP_RINGS, speed=0.01, period=10, step=3)
CP_RAINBOW = Rainbow(cp.pixels, speed=0.01, period=10, step=3)
CRYSTAL_COMET = Comet(PIXEL_MAP_CRYSTALS, speed=SPEED, tail_length=8,
                      color=PURPLE, bounce=True)
DARK_RINGS = Solid(PIXELS, color=BLACK)
DARK_CPB = Solid(cp.pixels, color=BLACK)
DARK = AnimationGroup(
        DARK_RINGS,
        DARK_CPB,
        )

# Animations Playlist, reorder as desired. AnimationGroups play at same time
ANIMATIONS = AnimationSequence(
    AnimationGroup(
        CRYSTAL_COMET,
        RAINBOW,
        CP_RAINBOW,
        ),
    auto_clear=True,
    auto_reset=True,
)

# MAIN LOOP ----------------------------------------------------------------
SPARKLE_SPEED = 0.03  # Lower numbers increase the animation speed

# Create the NeoPixel strip
strip_pixels = neopixel.NeoPixel(board.A1,
                                 STRIP_PIXEL_NUMBER,
                                 auto_write=False)

# Setup BLE connection
ble = BLERadio()
uart = UARTService()
advertisement = ProvideServicesAdvertisement(uart)

# Setup animations
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)),
)
Example #8
0
# Customize for your strands here
num_strands = 8
strand_length = 30

# Make the object to control the pixels
pixels = NeoPIO(board.GP0, board.GP1, board.GP2, num_strands*strand_length,
    num_strands=num_strands, auto_write=False, brightness=.18)

# Make a virtual PixelMap so that each strip can be controlled independently
strips = [PixelMap(pixels, range(i*30, (i+1)*30), individual_pixels=True)
    for i in range(num_strands)]

# This function makes a comet animation with slightly random settings
def make_animation(strip):
    speed = (1+random.random()) * 0.02
    length = random.randrange(18, 22)
    bounce = random.random() > .5
    offset = random.randint(0, 255)
    return RainbowComet(strip, speed=speed, tail_length=length, bounce=bounce,
        colorwheel_offset=offset)

# Make an animation for each virtual strip
animations = [make_animation(strip) for strip in strips]

# Put the animations into a group so that we can animate them together
group = AnimationGroup(*animations, )

# Show the animations forever
while True:
    group.animate()
Example #9
0
from adafruit_led_animation.group import AnimationGroup
from adafruit_led_animation.sequence import AnimationSequence

import adafruit_led_animation.color as color

strip_pixels = neopixel.NeoPixel(board.A1,
                                 16,
                                 brightness=0.5,
                                 auto_write=False)
cp.pixels.brightness = 0.5

animations = AnimationSequence(
    # Synchronized to 0.5 seconds. Ignores the second animation setting of 3 seconds.
    AnimationGroup(
        Sparkle(cp.pixels, 0.1, color.GREEN, num_sparkles=1),
        Sparkle(strip_pixels, 0.1, color.GREEN, num_sparkles=1),
    ),
    AnimationGroup(
        Blink(cp.pixels, 0.25, color.RED),
        Blink(strip_pixels, 0.25, color.RED),
        sync=True,
    ),
    # Different speeds
    AnimationGroup(
        Comet(cp.pixels, 0.05, color.GREEN, tail_length=5),
        Comet(strip_pixels, 0.05, color.GREEN, tail_length=5),
    ),
    AnimationGroup(
        Pulse(cp.pixels, 0.05, color.RED, period=3),
        Pulse(strip_pixels, 0.05, color.RED, period=3),
    ),
Example #10
0
            print("Response is", cheerlights_update_info)

            # Get the color from the fetched info for use below.
            cheerlights_color = cheerlights_update_info[0]

            # If red, blue or pink, do a comet animation in the specified color.
            if cheerlights_color in ('red', 'blue', 'pink'):
                if cheerlights_color == 'red':
                    comet_color = RED
                elif cheerlights_color == 'blue':
                    comet_color = BLUE
                elif cheerlights_color == 'pink':
                    comet_color = PINK
                animations = AnimationSequence(
                    AnimationGroup(
                        Comet(magtag_pixels, 0.3, color=comet_color, tail_length=3),
                        Comet(strip_pixels, 0.05, color=comet_color, tail_length=15),
                    )
                )

            # If green or orange, do a pulse animation in the specified color.
            if cheerlights_color in ('green', 'orange'):
                if cheerlights_color == 'green':
                    pulse_color = GREEN
                elif cheerlights_color == 'orange':
                    pulse_color = ORANGE
                animations = AnimationSequence(
                    AnimationGroup(
                        Pulse(magtag_pixels, speed=0.1, color=pulse_color, period=3),
                        Pulse(strip_pixels, speed=0.1, color=pulse_color, period=3),
                    )
                )
magtag = MagTag()

# Setup pixels.
pixels = magtag.peripherals.neopixels
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,
Example #12
0
#  sets colors of circles to transparent to reveal dates that have passed & current date
for i in range(day):
    circle_group[i].fill = None
    time.sleep(0.1)

#  updates display with bitmap and current circle colors
magtag.display.show(group)
magtag.display.refresh()
time.sleep(5)

# Neopixel strip
magtag.peripherals.neopixel_disable = True
strip_pin = board.D10
strip_brightness = 0.25
days_left = 25 - day
pixel_list = range(days_left)
pixel_strip = neopixel.NeoPixel(strip_pin, 30, brightness=strip_brightness, auto_write=False)
green = PixelMap(pixel_strip, pixel_list[0:days_left:2], True)
red = PixelMap(pixel_strip, pixel_list[1:days_left:2], True)
AnimationGroup(Solid(green, GREEN), Solid(red, RED)).animate()

#  goes into deep sleep till a 'stroke' past midnight
print("entering deep sleep")
seconds_to_sleep = 24*60*60 - seconds_since_midnight + 10
print( f"sleeping for {seconds_to_sleep} seconds")
magtag.exit_and_deep_sleep(seconds_to_sleep)

#  entire code will run again after deep sleep cycle
#  similar to hitting the reset button
PIXELS.show()

ENCODER = rotaryio.IncrementalEncoder(board.A2, board.A3)

# LED ANIMATIONS -----------------------------------------------------------

COMET = Comet(PIXELS, speed=SPEED, tail_length=8, color=PURPLE, bounce=True)
CP_COMET = Comet(cp.pixels,
                 speed=SPEED,
                 tail_length=8,
                 color=PURPLE,
                 bounce=True)
DARK_RINGS = Solid(PIXELS, color=BLACK)
DARK_CPB = Solid(cp.pixels, color=BLACK)
DARK = AnimationGroup(
    DARK_RINGS,
    DARK_CPB,
)

# Animations Playlist, reorder as desired. AnimationGroups play at same time
ANIMATIONS = AnimationGroup(
    COMET,
    CP_COMET,
)

# MAIN LOOP ----------------------------------------------------------------

LAST_POSITION = ENCODER.position
MODE = 1
while True:

    POSITION = ENCODER.position
Example #14
0
import board
import neopixel
from adafruit_led_animation.animation.sparkle import Sparkle
from adafruit_led_animation.group import AnimationGroup
from adafruit_led_animation.sequence import AnimationSequence

pixel_pin = board.A1
num_pixels = 35
SPARKLE_SPEED = 0.3
purple = (200, 0, 200)

strip_pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.3, auto_write=False)

animations = AnimationSequence(
    AnimationGroup(
        Sparkle(strip_pixels, SPARKLE_SPEED, purple)
    ),
)

while True:

    animations.animate()
# Setup for sparkle animation
SPARKLE_SPEED = 0.1  # Lower numbers increase the animation speed

# Create the NeoPixel strip
strip_pixels = neopixel.NeoPixel(board.D5,
                                 STRIP_PIXEL_NUMBER,
                                 auto_write=False)

# Setup BLE connection
ble = BLERadio()
uart = UARTService()
advertisement = ProvideServicesAdvertisement(uart)

# Setup animations
animations = AnimationSequence(
    AnimationGroup(Sparkle(strip_pixels, SPARKLE_SPEED, color.TEAL)),
    AnimationGroup(
        Comet(strip_pixels,
              COMET_SPEED,
              color.TEAL,
              tail_length=STRIP_COMET_TAIL_LENGTH,
              bounce=STRIP_COMET_BOUNCE)),
)

animation_color = None
mode = 0
blanked = False

while True:
    ble.start_advertising(advertisement)  # Start advertising.
    was_connected = False
Example #16
0
star1 = anisha.Astar(119, 42, 5, 20, outline=GOLD, colors=16)

lights = anisha.Apoints([(105, 125), (100, 170), (75, 180), (50, 180),
                         (80, 135), (60, 145), (95, 100), (80, 110), (119, 85),
                         (158, 110), (143, 100), (178, 145), (158, 135),
                         (188, 180), (163, 180), (138, 170), (133, 125)],
                        size=2,
                        outline=0xFF0000,
                        colors=4)

group = displayio.Group(max_size=5, scale=1)

group.append(arc1)
group.append(arc2)
group.append(tree)
group.append(star1)
group.append(lights)

display.show(group)

star_pulse = Pulse(star1, speed=0.05, period=6, color=GOLD)

tree_sparke = Sparkle(tree, speed=0.3, color=0x00FF00, num_sparkles=20)

lights_blink = Chase(lights, speed=1, size=1, spacing=2, color=0xFF0000)

animation_group = AnimationGroup(star_pulse, tree_sparke, lights_blink)

while True:
    animation_group.animate()
Example #17
0
                      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,
    ),
    chase,
    rainbow_chase2,
    rainbow,
    AnimationGroup(
        rainbow_comet,
        sparkle3,
    ),
    AnimationGroup(
        rainbow_comet2,
        sparkle3,
    ),
    AnimationGroup(
        sparkle,
#    They can be a single line or a group of animations - the groups will play
#    at the same time, overlaid on top of each other.

readingLight = Solid(pixels, color=0xFF7D13)  #warm white color HEX code
brightWhite = Solid(pixels, color=(150, 150, 150))
rainbow = Rainbow(pixels, speed=0.1, period=10, step=0.5)
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,
Example #19
0
             tail_length=40,
             bounce=False)
sparkle = Sparkle(pixel_map[4], speed=0.01, color=BLUE, num_sparkles=10)
sparkle2 = Sparkle(pixel_map[1], speed=0.05, color=PURPLE, num_sparkles=4)

# Animations Playlist - reorder as desired. AnimationGroups play at the same time
animations = AnimationSequence(
    rainbow,
    rainbow_chase,
    rainbow_chase2,
    chase,
    lava,
    rainbow_comet,
    rainbow_comet2,
    AnimationGroup(
        sparkle,
        strum,
    ),
    AnimationGroup(
        sparkle2,
        rainbow_comet3,
    ),
    auto_clear=True,
    auto_reset=True,
)

MODE = 0
LASTMODE = 1  # start up in sound reactive mode
i = 0

# Main loop
while True:
Example #20
0
                       start_angle=180,
                       end_angle=360,
                       angle_offset=0,
                       outline=0xFF0000)
circle1 = anisha.Acircle(46, 18, 13, outline=0x0000FF, angle_offset=90)

group = displayio.Group(max_size=4)
group.append(ellipse1)
group.append(arc1)
group.append(circle1)

display.show(group)

blink1 = Blink(arc1, speed=0.3, color=0xFF0000)
blink2 = Blink(ellipse1, speed=0.7, color=0x004000)
blink3 = Blink(circle1, speed=0.5, color=0x0000FF)

comet1 = Comet(ellipse1, speed=0.01, color=PURPLE, tail_length=10, bounce=True)
comet2 = Comet(arc1, speed=0.01, color=PURPLE, tail_length=10, bounce=True)
comet3 = Comet(circle1, speed=0.01, color=PURPLE, tail_length=10, bounce=True)

animations = AnimationSequence(AnimationGroup(blink1, blink2, blink3),
                               AnimationGroup(comet1, comet2, comet3),
                               advance_interval=d,
                               auto_clear=True)

time.sleep(10)

while True:
    animations.animate()