pixel_map_reverse = PixelMap(pixels, [ 0, 103, 1, 102, 2, 101, 3, 100, 4, 99, 5, 98, 6, 97, 7, 96, 8, 95, 9, 94, 10, 93, 11, 92, 12, 91, 13, 90, 14, 89, 15, 88, 16, 87, 17, 86, 18, 85, 19, 84, 20, 83, 21, 82, 22, 81, 23, 80, 24, 79, 25, 78, 26, 77, 27, 76, 28, 75, 29, 74, 30, 73, 31, 72, 32, 71, 33, 70, 34, 69, 35, 68, 36, 67, 37, 66, 38, 65, 39, 64, 40, 63, 41, 62, 42, 61, 43, 60, 44, 59, 45, 58, 46, 57, 47, 56, 48, 55, 49, 54, 50, 53, 51, 52, ], individual_pixels=True)
PIXELS = neopixel.NeoPixel(NEOPIXEL_PIN, NUM_PIXELS, brightness=LEVEL, auto_write=False) # NeoPixels off ASAP on startup cp.pixels.fill(0) # Onboard pixels cp.pixels.show() PIXELS.fill(0) # NeoPixel strip PIXELS.show() ENCODER = rotaryio.IncrementalEncoder(board.A2, board.A3) # PIXEL MAPS reorder pixels so animations run in different configs --------- # Crystals Only PIXEL_MAP_CRYSTALS = PixelMap(PIXELS, [ 84, 85, 86, 87, 88, 89, 90, 91 ], individual_pixels=True) # Rings Only 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)
pixel_map_right = PixelMap(pixels, [ 150, 151, 152, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, ], individual_pixels=True)
from adafruit_led_animation.animation.rainbowcomet import RainbowComet from adafruit_led_animation.helper import PixelMap from adafruit_led_animation.group import AnimationGroup from neopio import NeoPIO import board # 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
# 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
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 * strand_length, (i + 1) * strand_length), 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)