) comet_stripB_m0 = Comet( pixel_stripB, speed=b64TH, color=ORANGE, tail_length=9, bounce=False ) # 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)
group.append(rect1) group.append(rect2) group.append(rect3) group.append(rect4) display.show(group) pixels = rect1 blink = Blink(pixels, speed=0.5, color=0x00FF00) colorcycle = ColorCycle(pixels, speed=0.4, colors=[MAGENTA, YELLOW]) comet = Comet(pixels, speed=0.01, color=PURPLE, tail_length=10, bounce=True) chase = Chase(pixels, speed=0.1, size=3, spacing=6, color=WHITE) #pulse = Pulse(pixels, speed=0.1, period=3, color=0x00FF00) sparkle = Sparkle(pixels, speed=0.1, color=PURPLE, num_sparkles=10) solid = Solid(pixels, color=0x00FF00) #rainbow = Rainbow(pixels, speed=0.1, period=2) sparkle_pulse = SparklePulse(pixels, speed=0.1, period=3, color=0x00FF00) 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_color_chase = CustomColorChase(pixels, speed=0.1, size=2, spacing=3, colors=[ORANGE, WHITE, JADE]) blink2 = Blink(rect2, speed=0.5, color=0x0000FF) colorcycle2 = ColorCycle(rect2, speed=0.4, colors=[MAGENTA, BLUE]) comet2 = Comet(rect2, speed=0.01, color=PURPLE, tail_length=10, bounce=True) chase2 = Chase(rect2, speed=0.1, size=3, spacing=6, color=WHITE)
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) blink = Blink(pixels, speed=0.5, color=JADE) colorcycle = ColorCycle(pixels, speed=0.4, colors=[MAGENTA, ORANGE]) comet = Comet(pixels, speed=0.01, color=PURPLE, tail_length=10, bounce=True) chase = Chase(pixels, speed=0.1, size=3, spacing=6, color=WHITE) pulse = Pulse(pixels, speed=0.1, period=3, color=AMBER) sparkle = Sparkle(pixels, speed=0.1, color=PURPLE, num_sparkles=10) solid = Solid(pixels, color=JADE) rainbow = Rainbow(pixels, speed=0.1, period=2) 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_color_chase = CustomColorChase(pixels, speed=0.1, size=2, spacing=3, colors=[ORANGE, WHITE, JADE]) animations = AnimationSequence( comet, blink, rainbow_sparkle,
bounce=True) rainbow_comet3 = RainbowComet(pixels, speed=0, tail_length=25, colorwheel_offset=80, step=4, bounce=False) strum = RainbowComet(pixels, speed=0.1, tail_length=25, bounce=False, colorwheel_offset=50, step=4) sparkle = Sparkle(pixels, speed=0.1, color=BLUE, num_sparkles=10) sparkle2 = Sparkle(pixels, speed=0.5, color=PURPLE, num_sparkles=4) off = Solid(pixels, color=BLACK) # Animations Playlist - reorder as desired. AnimationGroups play at the same time animations = AnimationSequence( rainbow_comet2, # rainbow_comet, # chase, # rainbow_chase, # rainbow, # AnimationGroup( sparkle, strum, ), AnimationGroup( sparkle2, rainbow_comet3,
enable.direction = Direction.OUTPUT enable.value = False strip = neopixel.NeoPixel(NEOPIXEL_PIN, NUM_PIXELS, brightness=.5, auto_write=False) strip.fill(0) # NeoPixels off ASAP on startup strip.show() # default NeoPixel color is white COLOR = (255, 255, 255) # NeoPixel animations pulse = Pulse(strip, speed=0.05, color=COLOR, period=3) solid = Solid(strip, color=COLOR) comet = Comet(strip, speed=0.05, color=COLOR, tail_length=40) #audio try: from audiocore import WaveFile except ImportError: from audioio import WaveFile try: from audioio import AudioOut except ImportError: try: from audiopwmio import PWMAudioOut as AudioOut except ImportError: pass # not always supported by every board!
def __init__(self, pixel_object, speed, name): # define animation super().__init__(pixel_object, speed=speed, color=WHITE, name=name) def draw(self): # draw the animation ''' fades the entire strip through the whole spectrum ''' self.color = colorwheel(self._color_index + 1) self._color_index = (self._color_index + 1) % 256 self.fill(self.color) # ANIMATION DEFINITIONS -- # create as many animations as you'd like and define their attributes here. # 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)) focus = Solid(pixels, color=RED) breakTime = Solid(pixels, color=GREEN) 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),
from adafruit_led_animation.color import RED, BLUE # 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 # Update to matchpin connected to button that connect logic high when pushed button_pin = board.D3 pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False) button = DigitalInOut(button_pin) button.direction = Direction.INPUT button.pull = Pull.UP solid_blue = Solid(pixels, color=BLUE) solid_red = Solid(pixels, color=RED) animation_sequence = AnimationSequence(solid_blue, solid_red, auto_clear=True) while True: animation_sequence.animate() # Pressing the button pauses the animation permanently if not button.value: animation_sequence.next() while button.value: time.sleep(0.1) # Used for button debouncing
# 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,
# 114 colors is the minimum value for all the rainbow animations. 128 use same memory. rect1 = anisha.Arect(16, 1, 30, 30, outline=0x004000, stroke=2, colors=128) group = displayio.Group() group.append(rect1) display.show(group) blink = Blink(rect1, speed=0.5, color=JADE) colorcycle = ColorCycle(rect1, speed=0.4, colors=[MAGENTA, ORANGE]) comet = Comet(rect1, speed=0.01, color=PURPLE, tail_length=10, bounce=True) chase = Chase(rect1, speed=0.1, size=3, spacing=6, color=WHITE) pulse = Pulse(rect1, speed=0.1, period=3, color=AMBER) sparkle = Sparkle(rect1, speed=0.1, color=PURPLE, num_sparkles=10) solid = Solid(rect1, color=JADE) rainbow = Rainbow(rect1, speed=0.1, period=2) sparkle_pulse = SparklePulse(rect1, speed=0.1, period=3, color=JADE) rainbow_comet = RainbowComet(rect1, speed=0.1, tail_length=7, bounce=True) rainbow_chase = RainbowChase(rect1, speed=0.1, size=3, spacing=2, step=8) rainbow_sparkle = RainbowSparkle(rect1, speed=0.1, num_sparkles=15) custom_color_chase = CustomColorChase(rect1, speed=0.1, size=2, spacing=3, colors=[ORANGE, WHITE, JADE]) animations = AnimationSequence( comet, blink, rainbow_sparkle,
def __init__(self, pixel_object, speed, name): # define animation super().__init__(pixel_object, speed=speed, color=WHITE, name=name) def draw(self): # draw the animation ''' fades the entire strip through the whole spectrum ''' self.color = colorwheel(self._color_index + 1) self._color_index = (self._color_index + 1) % 256 self.fill(self.color) # ANIMATION DEFINITIONS -- # create as many animations as you'd like and define their attributes here. # 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), )
tail_length=strip_comet_tail), ), AnimationGroup( Comet(pixels, magtag_comet_speed, comet_two_color, tail_length=magtag_comet_tail), Comet(strip, strip_comet_speed, comet_two_color, tail_length=strip_comet_tail), ), ), ), AnimationGroup( # Turn the LEDs off. Solid(pixels, 0), Solid(strip, 0), ), auto_clear=True, ) # Set the background image. magtag.set_background("/adaflake.bmp") # Add lines of text including button labels. magtag.add_text(text_color=0xFFFFFF, text_position=(0, 10), text_scale=2) magtag.set_text("Button functions:") magtag.add_text(text_color=0xFFFFFF, text_position=(0, 65)) magtag.set_text( " Button A: Color Cycle\n" " Button B: Sparkle\n"
# 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
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, ), chase, rainbow_chase2, rainbow,
# 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, ) solid.speed = 0.01 solid_color = 0
PIXEL_MAP_RINGS = PixelMap(PIXELS, [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 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,
PINK, MAGENTA, ORANGE, ) # 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) solid = Solid(pixels, color=PINK) blink = Blink(pixels, speed=0.5, color=JADE) colorcycle = ColorCycle(pixels, speed=0.4, colors=[MAGENTA, ORANGE, TEAL]) chase = Chase(pixels, speed=0.1, color=WHITE, size=3, spacing=6) comet = Comet(pixels, speed=0.01, color=PURPLE, tail_length=10, bounce=True) pulse = Pulse(pixels, speed=0.1, color=AMBER, period=3) animations = AnimationSequence( solid, blink, colorcycle, chase, comet, pulse, advance_interval=5, auto_clear=True,