Beispiel #1
0
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)
    (77, 96, GREEN),
    (98, 119, TEAL),
    (120, 145, BLUE),
    (150, 173, PURPLE),
    (180, 200, MAGENTA),
)

# Cap touch board setup   ------------------------------------------------------
i2c = busio.I2C(board.SCL, board.SDA)
mpr121 = adafruit_mpr121.MPR121(i2c)

# Demo MODE LED Animations  ------------------------------------------------------
rainbow = Rainbow(pixels, speed=0, period=10, name="rainbow", step=1)
rainbow_chase = RainbowChase(pixels, speed=0, size=5, spacing=10)
chase = Chase(pixels, speed=0.1, color=RED, size=1, spacing=6)
rainbow_comet = RainbowComet(pixels, speed=0.01, tail_length=60, bounce=True)

# Animation Sequence Playlist -- rearrange to change the order of animations

animations = AnimationSequence(
    rainbow_chase,
    chase,
    rainbow_comet,
    auto_clear=True,
    auto_reset=True,
)

def go_dark():
    '''set all pixels to black'''
    pixels.fill(BLACK)
    pixels.show()
Beispiel #3
0
        pixels.fill(WHITE)
        pixels.show()
        time.sleep(0.02)
        pixels.fill(BLACK)
        pixels.show()
        time.sleep(0.005)
        pixels.fill(TILT_COLOR)
        pixels.show()
        time.sleep(0.01)
        pixels.fill(BLACK)
        pixels.show()
        time.sleep(0.03)


# Cusomize LED Animations  ------------------------------------------------------
powerup = RainbowComet(pixel_map[3], speed=0, tail_length=25, bounce=False)
rainbow = Rainbow(pixel_map[4], speed=0, period=6, name="rainbow", step=2.4)
rainbow_chase = RainbowChase(pixel_map[3],
                             speed=0,
                             size=3,
                             spacing=15,
                             step=10)
rainbow_chase2 = RainbowChase(pixel_map[2],
                              speed=0,
                              size=10,
                              spacing=1,
                              step=18)
chase = Chase(pixel_map[1], speed=0.1, color=RED, size=1, spacing=6)
rainbow_comet = RainbowComet(pixel_map[2],
                             speed=0,
                             tail_length=80,
Beispiel #4
0

def power_on(duration):
    """
    Animate NeoPixels for power on.
    """
    start_time = time.monotonic()  # Save start time
    while True:
        elapsed = time.monotonic() - start_time  # Time spent
        if elapsed > duration:  # Past duration?
            break  # Stop animating
        powerup.animate()


# Cusomize LED Animations  ------------------------------------------------------
powerup = RainbowComet(pixel_map[3], speed=0, tail_length=25, bounce=False)
rainbow = Rainbow(pixel_map[2], speed=0, period=6, name="rainbow", step=2.4)
rainbow_chase = RainbowChase(pixels, speed=0, size=6, spacing=15, step=10)
rainbow_chase2 = RainbowChase(pixels,
                              speed=0,
                              size=10,
                              spacing=1,
                              step=18,
                              name="rainbow_chase2")
chase = RainbowChase(pixel_map[3], speed=0, size=20, spacing=20)
chase2 = Chase(pixels, speed=0.1, color=ORANGE, size=6, spacing=6)
rainbow_comet = RainbowComet(pixel_map[2],
                             speed=0,
                             tail_length=200,
                             bounce=True)
rainbow_comet2 = RainbowComet(pixels,
Beispiel #5
0
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)
#pulse2 = Pulse(rect2, speed=0.1, period=3, color=0x0000FF)
sparkle2 = Sparkle(rect2, speed=0.1, color=PURPLE, num_sparkles=10)
solid2 = Solid(rect2, color=0x0000FF)
# Number of pixels in the collar (arranged in two rows)
pixel_num = 24

pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.5, auto_write=False)

# Create a switch from the ItsyBity's on-board pushbutton to toggle charge mode
mode_pin = digitalio.DigitalInOut(board.SWITCH)
mode_pin.direction = digitalio.Direction.INPUT
mode_pin.pull = digitalio.Pull.UP
switch = Debouncer(mode_pin)

# Create the animations
comet = Comet(pixels, speed=0.06, color=(180,0,255), tail_length=10, bounce=True)
chase = Chase(pixels, speed=0.05, size=3, spacing=3, color=(0,255,255), reverse=True)
rainbow_comet = RainbowComet(pixels, speed=.06)
pulse = Pulse(pixels, speed=.04, color=(255,0,0), period = 0.2)


# Our animations sequence
seconds_per_animation = 10
animations = AnimationSequence(comet, rainbow_comet, chase, advance_interval=seconds_per_animation, auto_clear=True)
# Current display determines whether we are showing the animation sequence or the pulse animation
current_display = animations

# Mode changes the color of random animations randomly
random_color_mode = True

def random_animation_color(anims):
    if random_color_mode:
        anims.color = colorwheel(random.randint(0,255))
Beispiel #7
0
import neopixel
import supervisor
import math
from ICM20602 import ICM20602
from adafruit_led_animation.animation.rainbowcomet import RainbowComet

supervisor.set_rgb_status_brightness(0)
ADDRESS = 0x68

i2c = board.I2C()

pixels = neopixel.NeoPixel(board.D5, 6, brightness = 0.1, auto_write = False)
pixels.fill((0, 0, 0))
pixels.show()

rainbow_comet = RainbowComet(pixels, speed=0.1, tail_length=6, bounce = False)

imu = ICM20602(i2c, 0x68)
light = analogio.AnalogIn(board.A0)

pos = 0
nextPrint = time.monotonic()+0.3

while True:
    acc = imu.acceleration

    if time.monotonic() > nextPrint:
        print(imu.gyro)
        print(acc)
        print(light.value)
        nextPrint += 0.3
Beispiel #8
0
# input_floor = 50

# You might want to print the input_floor to help adjust other values.
print(input_floor)

# Corresponds to sensitivity: lower means more pixels light up with lower sound
# Adjust this as you see fit.
input_ceiling = input_floor + 100

peak = 0

# Cusomize LED Animations  ------------------------------------------------------
rainbow = Rainbow(pixels, speed=0, period=6, name="rainbow", step=2.4)
rainbow_chase = RainbowChase(pixels, speed=0.1, size=5, spacing=5, step=5)
chase = Chase(pixels, speed=0.2, color=ORANGE, size=2, spacing=6)
rainbow_comet = RainbowComet(pixels, speed=0.1, tail_length=30, bounce=True)
rainbow_comet2 = RainbowComet(pixels,
                              speed=0.1,
                              tail_length=104,
                              colorwheel_offset=80,
                              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,
Beispiel #9
0
                                  board.A2,
                                  num_pixels,
                                  auto_write=False,
                                  brightness=0.1)
pixel_framebuf = PixelFramebuffer(pixels,
                                  pixel_width,
                                  pixel_height,
                                  rotation=1,
                                  alternating=False,
                                  reverse_x=True)
# Fancy animations from https://learn.adafruit.com/circuitpython-led-animations
rainbow_chase = RainbowChase(pixels, speed=0.1, size=3, spacing=6, step=8)
chase = Chase(pixels, speed=0.1, color=CYAN, size=3, spacing=6)
rainbow_comet = RainbowComet(pixels,
                             speed=0.1,
                             tail_length=5,
                             bounce=True,
                             colorwheel_offset=170)


def scroll_framebuf_neg_x(word, color, shift_x, shift_y):
    pixel_framebuf.fill(0)
    color_int = int('0x%02x%02x%02x' % color, 16)

    # negate x so that the word can be shown from left to right
    pixel_framebuf.text(word, -shift_x, shift_y, color_int)
    pixel_framebuf.display()
    time.sleep(SCROLL_TEXT_WAIT)


def scroll_text(packet, word):
        ''' 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),
)

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),
Beispiel #11
0
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,
    chase,
    pulse,
    sparkle,
Beispiel #12
0
                speed=0.1,
                color=AMBER,
                tail_length=6,
                bounce=True)
chase_h = Chase(pixel_wing_horizontal,
                speed=0.1,
                size=3,
                spacing=6,
                color=JADE)
rainbow_chase_v = RainbowChase(pixel_wing_vertical,
                               speed=0.1,
                               size=3,
                               spacing=2,
                               step=8)
rainbow_comet_v = RainbowComet(pixel_wing_vertical,
                               speed=0.1,
                               tail_length=7,
                               bounce=True)
rainbow_v = Rainbow(pixel_wing_vertical, speed=0.1, period=2)
rainbow_chase_h = RainbowChase(pixel_wing_horizontal,
                               speed=0.1,
                               size=3,
                               spacing=3)

animations = AnimationSequence(
    rainbow_v,
    comet_h,
    rainbow_comet_v,
    chase_h,
    rainbow_chase_v,
    comet_v,
    rainbow_chase_h,