Merge branch 'main' into multicolor_comet

# Conflicts:
#	adafruit_led_animation/animation/comet.py
This commit is contained in:
foamyguy 2023-02-24 17:26:50 -06:00
commit 0629e1418e
3 changed files with 9 additions and 4 deletions

View file

@ -16,3 +16,4 @@ jobs:
uses: adafruit/workflows-circuitpython-libs/release-gh@main uses: adafruit/workflows-circuitpython-libs/release-gh@main
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
upload-url: ${{ github.event.release.upload_url }}

View file

@ -37,11 +37,13 @@ class Comet(Animation):
:param pixel_object: The initialised LED object. :param pixel_object: The initialised LED object.
:param float speed: Animation speed in seconds, e.g. ``0.1``. :param float speed: Animation speed in seconds, e.g. ``0.1``.
:param color: Animation color in ``(r, g, b)`` tuple, or ``0x000000`` hex format. :param color: Animation color in ``(r, g, b)`` tuple, or ``0x000000`` hex format.
:param background_color: Background color in ``(r, g, b)`` tuple, or ``0x000000`` hex format.
Defaults to BLACK.
:param int tail_length: The length of the comet. Defaults to 25% of the length of the :param int tail_length: The length of the comet. Defaults to 25% of the length of the
``pixel_object``. Automatically compensates for a minimum of 2 and a ``pixel_object``. Automatically compensates for a minimum of 2 and a
maximum of the length of the ``pixel_object``. maximum of the length of the ``pixel_object``.
:param bool reverse: Animates the comet in the reverse order. Defaults to ``False``. :param bool reverse: Animates the comet in the reverse order. Defaults to ``False``.
:param bool bounce: Comet will bounce back and forth. Defaults to ``True``. :param bool bounce: Comet will bounce back and forth. Defaults to ``False``.
:param Optional[string] name: A human-readable name for the Animation. :param Optional[string] name: A human-readable name for the Animation.
Used by the to string function. Used by the to string function.
:param bool ring: Ring mode. Defaults to ``False``. :param bool ring: Ring mode. Defaults to ``False``.
@ -53,6 +55,7 @@ class Comet(Animation):
pixel_object, pixel_object,
speed, speed,
color, color,
background_color=BLACK,
tail_length=0, tail_length=0,
reverse=False, reverse=False,
bounce=False, bounce=False,
@ -70,6 +73,7 @@ class Comet(Animation):
self._color_step = 0.95 / tail_length self._color_step = 0.95 / tail_length
self._comet_colors = None self._comet_colors = None
self._computed_color = color self._computed_color = color
self._background_color = background_color
self._num_pixels = len(pixel_object) self._num_pixels = len(pixel_object)
self._direction = -1 if reverse else 1 self._direction = -1 if reverse else 1
self._left_side = -self._tail_length self._left_side = -self._tail_length
@ -84,7 +88,7 @@ class Comet(Animation):
on_cycle_complete_supported = True on_cycle_complete_supported = True
def _set_color(self, color): def _set_color(self, color):
self._comet_colors = [BLACK] self._comet_colors = [self._background_color]
for n in range(self._tail_length): for n in range(self._tail_length):
self._comet_colors.append( self._comet_colors.append(
calculate_intensity(color, n * self._color_step + 0.05) calculate_intensity(color, n * self._color_step + 0.05)

View file

@ -40,7 +40,7 @@ class RainbowComet(Comet):
pixels present in the pixel object, e.g. if the strip is 30 pixels pixels present in the pixel object, e.g. if the strip is 30 pixels
long, the ``tail_length`` cannot exceed 30 pixels. long, the ``tail_length`` cannot exceed 30 pixels.
:param bool reverse: Animates the comet in the reverse order. Defaults to ``False``. :param bool reverse: Animates the comet in the reverse order. Defaults to ``False``.
:param bool bounce: Comet will bounce back and forth. Defaults to ``True``. :param bool bounce: Comet will bounce back and forth. Defaults to ``False``.
:param int colorwheel_offset: Offset from start of colorwheel (0-255). :param int colorwheel_offset: Offset from start of colorwheel (0-255).
:param int step: Colorwheel step (defaults to automatic). :param int step: Colorwheel step (defaults to automatic).
:param bool ring: Ring mode. Defaults to ``False``. :param bool ring: Ring mode. Defaults to ``False``.
@ -65,7 +65,7 @@ class RainbowComet(Comet):
self._colorwheel_step = step self._colorwheel_step = step
self._colorwheel_offset = colorwheel_offset self._colorwheel_offset = colorwheel_offset
super().__init__( super().__init__(
pixel_object, speed, 0, tail_length, reverse, bounce, name, ring pixel_object, speed, 0, 0, tail_length, reverse, bounce, name, ring
) )
def _set_color(self, color): def _set_color(self, color):