FPS = max(MIN_FPS, min(FPS + MOVE, MAX_FPS)) SPEED = 1.0 / FPS CRYSTAL_COMET.speed = SPEED #RAINBOW.speed = SPEED #CP_RAINBOW.speed = SPEED print("crystal speed = ", SPEED) else: BRIGHTNESS = max(MIN_BRIGHTNESS, min(BRIGHTNESS + MOVE, MAX_BRIGHTNESS)) LEVEL = BRIGHTNESS * 0.1 if LEVEL > 2: LEVEL = 2 cp.pixels.brightness = LEVEL/2 PIXEL_MAP_RINGS.brightness = LEVEL/2 PIXEL_MAP_CRYSTALS.brightness = LEVEL print("ring brightness = ", LEVEL/2, "crystal brightness = ", LEVEL) LAST_POSITION = POSITION if not BUTTON_VALUE and BUTTON_STATE is None: BUTTON_STATE = "pressed" if BUTTON_VALUE and BUTTON_STATE == "pressed": print("Button pressed.") if MODE == 1: MODE = 2 else: MODE = 1 BUTTON_STATE = None if MODE == 1: ANIMATIONS.animate() else: DARK.animate()
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 while True: if mode_state: # heal mode on startup vu_strip_animations_mode0.animate() pulse_rings_m0.animate() pulse_jewel_m0.animate() else: # speed mode on startup vu_strip_animations_mode1.animate() pulse_rings_m1.animate() pulse_jewel_m1.animate() # Change modes if mode_switch.value: if mode_state == 0: # state has changed, toggle it BGM = "/lucio/bgmheal.mp3" sample0.file = open(BGM, "rb") mixer.voice[0].play(sample0, loop=True) vu_strip_animations_mode0.animate() pulse_rings_m0.animate()
# 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()
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()
MOVE = POSITION - LAST_POSITION if cp.switch: FPS = max(MIN_FPS, min(FPS + MOVE, MAX_FPS)) SPEED = 1.0 / FPS COMET.speed = SPEED print("comet speed = ", SPEED) else: BRIGHTNESS = max(MIN_BRIGHTNESS, min(BRIGHTNESS + MOVE, MAX_BRIGHTNESS)) LEVEL = BRIGHTNESS * 0.1 if LEVEL > 1: LEVEL = 1 cp.pixels.brightness = LEVEL PIXELS.brightness = LEVEL print("brightness = ", LEVEL) LAST_POSITION = POSITION if not BUTTON_VALUE and BUTTON_STATE is None: BUTTON_STATE = "pressed" if BUTTON_VALUE and BUTTON_STATE == "pressed": print("Button pressed.") if MODE == 1: MODE = 2 else: MODE = 1 BUTTON_STATE = None if MODE == 1: ANIMATIONS.animate() else: DARK.animate()