From 829cd1d7af7f67a989c2dbf6bf73ffd9971b5d22 Mon Sep 17 00:00:00 2001 From: arturo182 Date: Mon, 22 Aug 2022 15:35:27 +0200 Subject: [PATCH] sequence: Add a function to play the previous animation --- adafruit_led_animation/sequence.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/adafruit_led_animation/sequence.py b/adafruit_led_animation/sequence.py index 2ec690c..fe522e9 100644 --- a/adafruit_led_animation/sequence.py +++ b/adafruit_led_animation/sequence.py @@ -179,6 +179,13 @@ class AnimationSequence: self.on_cycle_complete() self.activate(current % len(self._members)) + def previous(self): + """ + Jump to the previous animation. + """ + current = self._current - 1 + self.activate(current % len(self._members)) + def random(self): """ Jump to a random animation.