Skip to content

sequence: Add a function to play the previous animation #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 24, 2022

Conversation

arturo182
Copy link
Contributor

If we treat a Sequence as a list of animations that we switch between manually, then having a previous function to counteract next would be great :)

@tekktrik tekktrik requested a review from a team August 22, 2022 14:15
Copy link
Contributor

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is OK by me!

@dhalbert dhalbert requested a review from kattni August 24, 2022 13:53
Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Tested successfully on a NeoTrellisM4 with 8.0.3 beta with this modified example:

import adafruit_trellism4
import time
from adafruit_led_animation.animation.solid import Solid
from adafruit_led_animation.sequence import AnimationSequence
from adafruit_led_animation.color import RED, BLUE, YELLOW, GREEN, PINK


trellis = adafruit_trellism4.TrellisM4Express(rotation=90)
trellis.pixels.brightness = 0.2

solid_blue = Solid(trellis.pixels, color=BLUE)
solid_red = Solid(trellis.pixels, color=RED)
solid_yellow = Solid(trellis.pixels, color=YELLOW)
solid_green = Solid(trellis.pixels, color=GREEN)
solid_pink = Solid(trellis.pixels, color=PINK)

animation_sequence = AnimationSequence(solid_blue, solid_red, solid_pink, solid_yellow, solid_green, auto_clear=True)

while True:
    animation_sequence.animate()

    pressed = set(trellis.pressed_keys)
    for key in pressed:
        print(key)

    # Pressing the button pauses the animation permanently
    if pressed:
        animation_sequence.previous()
        time.sleep(0.3)

@FoamyGuy FoamyGuy merged commit 795be50 into adafruit:main Oct 24, 2022
@arturo182 arturo182 deleted the patch-1 branch October 24, 2022 18:06
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants