|
50 | 50 |
|
51 | 51 | class AnimationGroup: |
52 | 52 | """ |
53 | | - A group of animations that are active together. An example would be grouping a strip of |
54 | | - pixels connected to a board and the onboard LED. |
| 53 | + AnimationGroup synchronizes multiple animations. Allows for multiple animations to be kept in |
| 54 | + sync, whether or not the same animation or pixel object is in use. |
55 | 55 |
|
56 | 56 | :param members: The animation objects or groups. |
57 | | - :param bool sync: Synchronises the timing of all members of the group to the settings of the |
58 | | - first member of the group. Defaults to ``False``. |
59 | | -
|
| 57 | + :param bool sync: Synchronises when draw is called for all members of the group to the settings |
| 58 | + of the first member of the group. Defaults to ``False``. |
| 59 | +
|
| 60 | +
|
| 61 | + Example: |
| 62 | +
|
| 63 | + .. code-block:: |
| 64 | +
|
| 65 | + import board |
| 66 | + import neopixel |
| 67 | + from adafruit_circuitplayground import cp |
| 68 | + from adafruit_led_animation.animation.blink import Blink |
| 69 | + from adafruit_led_animation.animation.comet import Comet |
| 70 | + from adafruit_led_animation.animation.chase import Chase |
| 71 | + from adafruit_led_animation.group import AnimationGroup |
| 72 | + from adafruit_led_animation.sequence import AnimationSequence |
| 73 | +
|
| 74 | + import adafruit_led_animation.color as color |
| 75 | +
|
| 76 | + strip_pixels = neopixel.NeoPixel(board.A1, 30, brightness=0.5, auto_write=False) |
| 77 | + cp.pixels.brightness = 0.5 |
| 78 | +
|
| 79 | + animations = AnimationSequence( |
| 80 | + # Synchronized to 0.5 seconds. Ignores the second animation setting of 3 seconds. |
| 81 | + AnimationGroup( |
| 82 | + Blink(cp.pixels, 0.5, color.CYAN), |
| 83 | + Blink(strip_pixels, 3.0, color.AMBER), |
| 84 | + sync=True, |
| 85 | + ), |
| 86 | + # Different speeds |
| 87 | + AnimationGroup( |
| 88 | + Comet(cp.pixels, 0.1, color.MAGENTA, tail_length=5), |
| 89 | + Comet(strip_pixels, 0.01, color.MAGENTA, tail_length=15), |
| 90 | + ), |
| 91 | + # Sequential animations on the built-in NeoPixels then the NeoPixel strip |
| 92 | + Chase(cp.pixels, 0.05, size=2, spacing=3, color=color.PURPLE), |
| 93 | + Chase(strip_pixels, 0.05, size=2, spacing=3, color=color.PURPLE), |
| 94 | + advance_interval=3.0, |
| 95 | + auto_clear=True, |
| 96 | + auto_reset=True, |
| 97 | + ) |
| 98 | +
|
| 99 | + while True: |
| 100 | + animations.animate() |
60 | 101 | """ |
61 | 102 |
|
62 | 103 | def __init__(self, *members, sync=False, name=None): |
|
0 commit comments