From 33a95d63dc6bfc160cddb171d013acdc4b24730d Mon Sep 17 00:00:00 2001 From: cjsieh Date: Sun, 14 Jun 2020 18:50:43 -0500 Subject: [PATCH 01/26] Add files via upload Add ability to select custom colors for chase animation --- .../animation/customcolorchase.py | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 adafruit_led_animation/animation/customcolorchase.py diff --git a/adafruit_led_animation/animation/customcolorchase.py b/adafruit_led_animation/animation/customcolorchase.py new file mode 100644 index 0000000..52d43ba --- /dev/null +++ b/adafruit_led_animation/animation/customcolorchase.py @@ -0,0 +1,77 @@ +# The MIT License (MIT) +# +# Copyright (c) 2019-2020 Roy Hooper +# Copyright (c) 2020 Kattni Rembor for Adafruit Industries +# Copyright (c) 2020 Connie Sieh +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +""" +`adafruit_led_animation.animation.rainbowchase` +================================================================================ + +Rainbow chase animation for CircuitPython helper library for LED animations. + +* Author(s): Roy Hooper, Kattni Rembor, Connie Sieh + +Implementation Notes +-------------------- + +**Hardware:** + +* `Adafruit NeoPixels `_ +* `Adafruit DotStars `_ + +**Software and Dependencies:** + +* Adafruit CircuitPython firmware for the supported boards: + https://circuitpython.org/downloads + + +""" + +from adafruit_led_animation.animation.chase import Chase +from adafruit_led_animation.color import RAINBOW + + +class CustomColorChase(Chase): + """ + Chase pixels in one direction, like a theater marquee but with Custom Color! + + :param pixel_object: The initialised LED object. + :param float speed: Animation speed rate in seconds, e.g. ``0.1``. + :param colors: Animation color in list of `(r, g, b)`` tuple, or ``0x000000`` hex format. + :param size: Number of pixels to turn on in a row. + :param spacing: Number of pixels to turn off in a row. + :param reverse: Reverse direction of movement. + """ + + # pylint: disable=too-many-arguments + def __init__( + self, pixel_object, speed, size=2, spacing=3, reverse=False, name=None, colors=RAINBOW): + self._num_colors = len(colors) + self._colors = colors + self._color_idx = 0 + super().__init__(pixel_object, speed, 0, size, spacing, reverse, name) + + def bar_color(self, n, pixel_no=0): + return self._colors[self._color_idx - (n % len(self._colors))] + + def on_cycle_complete(self): + self._color_idx = (self._color_idx + self._direction) % len(self._colors) + super().on_cycle_complete() From ca806b8207e308b3766f377c684ffdcbf9242c63 Mon Sep 17 00:00:00 2001 From: cjsieh Date: Sun, 14 Jun 2020 18:52:32 -0500 Subject: [PATCH 02/26] Add files via upload Added CustomColorChase example. Updated All example with new CustomColorChase --- examples/led_animation_all_animations.py | 3 ++ examples/led_animation_customcolorchase.py | 55 ++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 examples/led_animation_customcolorchase.py diff --git a/examples/led_animation_all_animations.py b/examples/led_animation_all_animations.py index 16a82bd..0d55804 100644 --- a/examples/led_animation_all_animations.py +++ b/examples/led_animation_all_animations.py @@ -21,6 +21,7 @@ from adafruit_led_animation.animation.solid import Solid from adafruit_led_animation.animation.colorcycle import ColorCycle from adafruit_led_animation.animation.rainbow import Rainbow +from adafruit_led_animation.animation.customcolorchase import CustomColorChase from adafruit_led_animation.sequence import AnimationSequence from adafruit_led_animation.color import PURPLE, WHITE, AMBER, JADE, MAGENTA, ORANGE @@ -43,6 +44,7 @@ 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]) animations = AnimationSequence( @@ -57,6 +59,7 @@ rainbow_comet, sparkle_pulse, rainbow_chase, + custom_color_chase, advance_interval=5, auto_clear=True, ) diff --git a/examples/led_animation_customcolorchase.py b/examples/led_animation_customcolorchase.py new file mode 100644 index 0000000..c7e149d --- /dev/null +++ b/examples/led_animation_customcolorchase.py @@ -0,0 +1,55 @@ +""" +This example displays the basic animations in sequence, at a five second interval. + +For NeoPixel FeatherWing. Update pixel_pin and pixel_num to match your wiring if using +a different form of NeoPixels. + +This example may not work on SAMD21 (M0) boards. +""" +import board +import neopixel + +from adafruit_led_animation.animation.customcolorchase import CustomColorChase +from adafruit_led_animation.sequence import AnimationSequence +from adafruit_led_animation.color import ( + PINK, + PURPLE, + GREEN, + RED, + WHITE, + BLUE +) + +# Update to match the pin connected to your NeoPixels +pixel_pin = board.D5 +# Update to match the number of NeoPixels you have connected +pixel_num = 32 +brightness = 0.3 + +pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=brightness, auto_write=False) + +# colors default to RAINBOW +custom_color_chase_rainbow = CustomColorChase(pixels, speed=0.1, size=2, spacing=3) +# Patriotic +custom_color_chase_rwb = CustomColorChase(pixels, speed=0.1, colors=[RED, WHITE, BLUE], size=2, spacing=3) +# St Pat Day +custom_color_chase_gw = CustomColorChase(pixels, speed=0.1, colors=[GREEN, WHITE], size=2, spacing=3) +# Christmas +custom_color_chase_rg = CustomColorChase(pixels, speed=0.1, colors=[RED, GREEN], size=2, spacing=3) +custom_color_chase_rg_r = CustomColorChase(pixels, speed=0.1, colors=[RED, GREEN], size=2, spacing=3, reverse=True) +# Valentines Day +custom_color_chase_rp = CustomColorChase(pixels, speed=0.1, colors=[RED , PINK], size=2, spacing=3) + + +animations = AnimationSequence( + custom_color_chase_rainbow, + custom_color_chase_rp, + custom_color_chase_gw, + custom_color_chase_rwb, + custom_color_chase_rg, + custom_color_chase_rg_r, + advance_interval=6, auto_clear=True, +) + +while True: + animations.animate() From a6ff8746cc739b860fe28382dd51f9a5acdd430b Mon Sep 17 00:00:00 2001 From: cjsieh Date: Mon, 15 Jun 2020 11:24:06 -0500 Subject: [PATCH 03/26] Add files via upload Changed from customcolorchase to customcolorschase --- examples/led_animation_customcolorschase.py | 55 +++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 examples/led_animation_customcolorschase.py diff --git a/examples/led_animation_customcolorschase.py b/examples/led_animation_customcolorschase.py new file mode 100644 index 0000000..6d65488 --- /dev/null +++ b/examples/led_animation_customcolorschase.py @@ -0,0 +1,55 @@ +""" +This example displays the basic animations in sequence, at a five second interval. + +For NeoPixel FeatherWing. Update pixel_pin and pixel_num to match your wiring if using +a different form of NeoPixels. + +This example may not work on SAMD21 (M0) boards. +""" +import board +import neopixel + +from adafruit_led_animation.animation.customcolorschase import CustomColorsChase +from adafruit_led_animation.sequence import AnimationSequence +from adafruit_led_animation.color import ( + PINK, + PURPLE, + GREEN, + RED, + WHITE, + BLUE +) + +# Update to match the pin connected to your NeoPixels +pixel_pin = board.D5 +# Update to match the number of NeoPixels you have connected +pixel_num = 32 +brightness = 0.3 + +pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=brightness, auto_write=False) + +# colors default to RAINBOW +custom_colors_chase_rainbow = CustomColorsChase(pixels, speed=0.1, size=2, spacing=3) +# Patriotic +custom_colors_chase_rwb = CustomColorsChase(pixels, speed=0.1, colors=[RED, WHITE, BLUE], size=2, spacing=3) +# St Pat Day +custom_colors_chase_gw = CustomColorsChase(pixels, speed=0.1, colors=[GREEN, WHITE], size=2, spacing=3) +# Christmas +custom_colors_chase_rg = CustomColorsChase(pixels, speed=0.1, colors=[RED, GREEN], size=2, spacing=3) +custom_colors_chase_rg_r = CustomColorsChase(pixels, speed=0.1, colors=[RED, GREEN], size=1, spacing=2, reverse=True) +# Valentines Day +custom_colors_chase_rp = CustomColorsChase(pixels, speed=0.1, colors=[RED , PINK], size=2, spacing=3) + + +animations = AnimationSequence( + custom_colors_chase_rainbow, + custom_colors_chase_rp, + custom_colors_chase_gw, + custom_colors_chase_rwb, + custom_colors_chase_rg, + custom_colors_chase_rg_r, + advance_interval=6, auto_clear=True, +) + +while True: + animations.animate() From 9d416515034ab05eee28d0220c5c7a091b1495f6 Mon Sep 17 00:00:00 2001 From: cjsieh Date: Mon, 15 Jun 2020 11:25:30 -0500 Subject: [PATCH 04/26] Delete led_animation_customcolorchase.py Changed from customcolorchase to customcolorschase --- examples/led_animation_customcolorchase.py | 55 ---------------------- 1 file changed, 55 deletions(-) delete mode 100644 examples/led_animation_customcolorchase.py diff --git a/examples/led_animation_customcolorchase.py b/examples/led_animation_customcolorchase.py deleted file mode 100644 index c7e149d..0000000 --- a/examples/led_animation_customcolorchase.py +++ /dev/null @@ -1,55 +0,0 @@ -""" -This example displays the basic animations in sequence, at a five second interval. - -For NeoPixel FeatherWing. Update pixel_pin and pixel_num to match your wiring if using -a different form of NeoPixels. - -This example may not work on SAMD21 (M0) boards. -""" -import board -import neopixel - -from adafruit_led_animation.animation.customcolorchase import CustomColorChase -from adafruit_led_animation.sequence import AnimationSequence -from adafruit_led_animation.color import ( - PINK, - PURPLE, - GREEN, - RED, - WHITE, - BLUE -) - -# Update to match the pin connected to your NeoPixels -pixel_pin = board.D5 -# Update to match the number of NeoPixels you have connected -pixel_num = 32 -brightness = 0.3 - -pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=brightness, auto_write=False) - -# colors default to RAINBOW -custom_color_chase_rainbow = CustomColorChase(pixels, speed=0.1, size=2, spacing=3) -# Patriotic -custom_color_chase_rwb = CustomColorChase(pixels, speed=0.1, colors=[RED, WHITE, BLUE], size=2, spacing=3) -# St Pat Day -custom_color_chase_gw = CustomColorChase(pixels, speed=0.1, colors=[GREEN, WHITE], size=2, spacing=3) -# Christmas -custom_color_chase_rg = CustomColorChase(pixels, speed=0.1, colors=[RED, GREEN], size=2, spacing=3) -custom_color_chase_rg_r = CustomColorChase(pixels, speed=0.1, colors=[RED, GREEN], size=2, spacing=3, reverse=True) -# Valentines Day -custom_color_chase_rp = CustomColorChase(pixels, speed=0.1, colors=[RED , PINK], size=2, spacing=3) - - -animations = AnimationSequence( - custom_color_chase_rainbow, - custom_color_chase_rp, - custom_color_chase_gw, - custom_color_chase_rwb, - custom_color_chase_rg, - custom_color_chase_rg_r, - advance_interval=6, auto_clear=True, -) - -while True: - animations.animate() From 4e7ffc12cc825d45102f420fe930f8c666ee1d5d Mon Sep 17 00:00:00 2001 From: cjsieh Date: Mon, 15 Jun 2020 11:26:34 -0500 Subject: [PATCH 05/26] Add files via upload Changed example CustomColorChase to CustomColorsChase --- examples/led_animation_all_animations.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/led_animation_all_animations.py b/examples/led_animation_all_animations.py index 0d55804..4518113 100644 --- a/examples/led_animation_all_animations.py +++ b/examples/led_animation_all_animations.py @@ -21,7 +21,7 @@ from adafruit_led_animation.animation.solid import Solid from adafruit_led_animation.animation.colorcycle import ColorCycle from adafruit_led_animation.animation.rainbow import Rainbow -from adafruit_led_animation.animation.customcolorchase import CustomColorChase +from adafruit_led_animation.animation.customcolorschase import CustomColorsChase from adafruit_led_animation.sequence import AnimationSequence from adafruit_led_animation.color import PURPLE, WHITE, AMBER, JADE, MAGENTA, ORANGE @@ -44,7 +44,7 @@ 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]) +custom_colors_chase = CustomColorsChase(pixels, speed=0.1, size=2, spacing=3,colors=[ORANGE, WHITE, JADE]) animations = AnimationSequence( @@ -59,7 +59,7 @@ rainbow_comet, sparkle_pulse, rainbow_chase, - custom_color_chase, + custom_colors_chase, advance_interval=5, auto_clear=True, ) From 85edc47550cb57b1c19778e42830e67f2712bf59 Mon Sep 17 00:00:00 2001 From: cjsieh Date: Mon, 15 Jun 2020 11:28:24 -0500 Subject: [PATCH 06/26] Add files via upload Change from CustomColorChase to CustomColorsChase --- .../animation/customcolorschase.py | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 adafruit_led_animation/animation/customcolorschase.py diff --git a/adafruit_led_animation/animation/customcolorschase.py b/adafruit_led_animation/animation/customcolorschase.py new file mode 100644 index 0000000..f1cc02c --- /dev/null +++ b/adafruit_led_animation/animation/customcolorschase.py @@ -0,0 +1,77 @@ +# The MIT License (MIT) +# +# Copyright (c) 2019-2020 Roy Hooper +# Copyright (c) 2020 Kattni Rembor for Adafruit Industries +# Copyright (c) 2020 Connie Sieh +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +""" +`adafruit_led_animation.animation.rainbowchase` +================================================================================ + +Rainbow chase animation for CircuitPython helper library for LED animations. + +* Author(s): Roy Hooper, Kattni Rembor, Connie Sieh + +Implementation Notes +-------------------- + +**Hardware:** + +* `Adafruit NeoPixels `_ +* `Adafruit DotStars `_ + +**Software and Dependencies:** + +* Adafruit CircuitPython firmware for the supported boards: + https://circuitpython.org/downloads + + +""" + +from adafruit_led_animation.animation.chase import Chase +from adafruit_led_animation.color import RAINBOW + + +class CustomColorsChase(Chase): + """ + Chase pixels in one direction, like a theater marquee with Custom Colors + + :param pixel_object: The initialised LED object. + :param float speed: Animation speed rate in seconds, e.g. ``0.1``. + :param colors: Animation color in list of `(r, g, b)`` tuple, or ``0x000000`` hex format, default is RAINBOW. + :param size: Number of pixels to turn on in a row. + :param spacing: Number of pixels to turn off in a row. + :param reverse: Reverse direction of movement. + """ + + # pylint: disable=too-many-arguments + def __init__( + self, pixel_object, speed, size=2, spacing=3, reverse=False, name=None, colors=RAINBOW): + self._num_colors = len(colors) + self._colors = colors + self._color_idx = 0 + super().__init__(pixel_object, speed, 0, size, spacing, reverse, name) + + def bar_color(self, n, pixel_no=0): + return self._colors[self._color_idx - (n % len(self._colors))] + + def on_cycle_complete(self): + self._color_idx = (self._color_idx + self._direction) % len(self._colors) + super().on_cycle_complete() From e62e5177e0235591aca02c72adde2ecc5ccb0ab7 Mon Sep 17 00:00:00 2001 From: cjsieh Date: Mon, 15 Jun 2020 11:29:05 -0500 Subject: [PATCH 07/26] Delete customcolorchase.py changed from customcolorchase to customcolorschase --- .../animation/customcolorchase.py | 77 ------------------- 1 file changed, 77 deletions(-) delete mode 100644 adafruit_led_animation/animation/customcolorchase.py diff --git a/adafruit_led_animation/animation/customcolorchase.py b/adafruit_led_animation/animation/customcolorchase.py deleted file mode 100644 index 52d43ba..0000000 --- a/adafruit_led_animation/animation/customcolorchase.py +++ /dev/null @@ -1,77 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2019-2020 Roy Hooper -# Copyright (c) 2020 Kattni Rembor for Adafruit Industries -# Copyright (c) 2020 Connie Sieh -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -""" -`adafruit_led_animation.animation.rainbowchase` -================================================================================ - -Rainbow chase animation for CircuitPython helper library for LED animations. - -* Author(s): Roy Hooper, Kattni Rembor, Connie Sieh - -Implementation Notes --------------------- - -**Hardware:** - -* `Adafruit NeoPixels `_ -* `Adafruit DotStars `_ - -**Software and Dependencies:** - -* Adafruit CircuitPython firmware for the supported boards: - https://circuitpython.org/downloads - - -""" - -from adafruit_led_animation.animation.chase import Chase -from adafruit_led_animation.color import RAINBOW - - -class CustomColorChase(Chase): - """ - Chase pixels in one direction, like a theater marquee but with Custom Color! - - :param pixel_object: The initialised LED object. - :param float speed: Animation speed rate in seconds, e.g. ``0.1``. - :param colors: Animation color in list of `(r, g, b)`` tuple, or ``0x000000`` hex format. - :param size: Number of pixels to turn on in a row. - :param spacing: Number of pixels to turn off in a row. - :param reverse: Reverse direction of movement. - """ - - # pylint: disable=too-many-arguments - def __init__( - self, pixel_object, speed, size=2, spacing=3, reverse=False, name=None, colors=RAINBOW): - self._num_colors = len(colors) - self._colors = colors - self._color_idx = 0 - super().__init__(pixel_object, speed, 0, size, spacing, reverse, name) - - def bar_color(self, n, pixel_no=0): - return self._colors[self._color_idx - (n % len(self._colors))] - - def on_cycle_complete(self): - self._color_idx = (self._color_idx + self._direction) % len(self._colors) - super().on_cycle_complete() From b068b7c80d52ae6d9ef6af0adca52e0b0e95e83c Mon Sep 17 00:00:00 2001 From: cjsieh Date: Mon, 15 Jun 2020 11:58:22 -0500 Subject: [PATCH 08/26] Add files via upload fixed spaces before/after parameters --- examples/led_animation_all_animations.py | 2 +- examples/led_animation_customcolorschase.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/led_animation_all_animations.py b/examples/led_animation_all_animations.py index 4518113..e322082 100644 --- a/examples/led_animation_all_animations.py +++ b/examples/led_animation_all_animations.py @@ -44,7 +44,7 @@ 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_colors_chase = CustomColorsChase(pixels, speed=0.1, size=2, spacing=3,colors=[ORANGE, WHITE, JADE]) +custom_colors_chase = CustomColorsChase(pixels, speed=0.1, size=2, spacing=3, colors=[ORANGE, WHITE, JADE]) animations = AnimationSequence( diff --git a/examples/led_animation_customcolorschase.py b/examples/led_animation_customcolorschase.py index 6d65488..eb11c16 100644 --- a/examples/led_animation_customcolorschase.py +++ b/examples/led_animation_customcolorschase.py @@ -38,7 +38,7 @@ custom_colors_chase_rg = CustomColorsChase(pixels, speed=0.1, colors=[RED, GREEN], size=2, spacing=3) custom_colors_chase_rg_r = CustomColorsChase(pixels, speed=0.1, colors=[RED, GREEN], size=1, spacing=2, reverse=True) # Valentines Day -custom_colors_chase_rp = CustomColorsChase(pixels, speed=0.1, colors=[RED , PINK], size=2, spacing=3) +custom_colors_chase_rp = CustomColorsChase(pixels, speed=0.1, colors=[RED, PINK], size=2, spacing=3) animations = AnimationSequence( From 5892c2550b8ff54d75522cfe3a142afe813f6177 Mon Sep 17 00:00:00 2001 From: cjsieh Date: Mon, 15 Jun 2020 13:37:03 -0500 Subject: [PATCH 09/26] Add files via upload reformatted via black --- examples/led_animation_all_animations.py | 4 ++- examples/led_animation_customcolorschase.py | 36 ++++++++++++--------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/examples/led_animation_all_animations.py b/examples/led_animation_all_animations.py index e322082..3b7a20e 100644 --- a/examples/led_animation_all_animations.py +++ b/examples/led_animation_all_animations.py @@ -44,7 +44,9 @@ 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_colors_chase = CustomColorsChase(pixels, speed=0.1, size=2, spacing=3, colors=[ORANGE, WHITE, JADE]) +custom_colors_chase = CustomColorsChase( + pixels, speed=0.1, size=2, spacing=3, colors=[ORANGE, WHITE, JADE] +) animations = AnimationSequence( diff --git a/examples/led_animation_customcolorschase.py b/examples/led_animation_customcolorschase.py index eb11c16..76aa7e2 100644 --- a/examples/led_animation_customcolorschase.py +++ b/examples/led_animation_customcolorschase.py @@ -11,14 +11,7 @@ from adafruit_led_animation.animation.customcolorschase import CustomColorsChase from adafruit_led_animation.sequence import AnimationSequence -from adafruit_led_animation.color import ( - PINK, - PURPLE, - GREEN, - RED, - WHITE, - BLUE -) +from adafruit_led_animation.color import PINK, PURPLE, GREEN, RED, WHITE, BLUE # Update to match the pin connected to your NeoPixels pixel_pin = board.D5 @@ -26,19 +19,31 @@ pixel_num = 32 brightness = 0.3 -pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=brightness, auto_write=False) +pixels = neopixel.NeoPixel( + pixel_pin, pixel_num, brightness=brightness, auto_write=False +) # colors default to RAINBOW custom_colors_chase_rainbow = CustomColorsChase(pixels, speed=0.1, size=2, spacing=3) # Patriotic -custom_colors_chase_rwb = CustomColorsChase(pixels, speed=0.1, colors=[RED, WHITE, BLUE], size=2, spacing=3) +custom_colors_chase_rwb = CustomColorsChase( + pixels, speed=0.1, colors=[RED, WHITE, BLUE], size=2, spacing=3 +) # St Pat Day -custom_colors_chase_gw = CustomColorsChase(pixels, speed=0.1, colors=[GREEN, WHITE], size=2, spacing=3) +custom_colors_chase_gw = CustomColorsChase( + pixels, speed=0.1, colors=[GREEN, WHITE], size=2, spacing=3 +) # Christmas -custom_colors_chase_rg = CustomColorsChase(pixels, speed=0.1, colors=[RED, GREEN], size=2, spacing=3) -custom_colors_chase_rg_r = CustomColorsChase(pixels, speed=0.1, colors=[RED, GREEN], size=1, spacing=2, reverse=True) +custom_colors_chase_rg = CustomColorsChase( + pixels, speed=0.1, colors=[RED, GREEN], size=2, spacing=3 +) +custom_colors_chase_rg_r = CustomColorsChase( + pixels, speed=0.1, colors=[RED, GREEN], size=1, spacing=2, reverse=True +) # Valentines Day -custom_colors_chase_rp = CustomColorsChase(pixels, speed=0.1, colors=[RED, PINK], size=2, spacing=3) +custom_colors_chase_rp = CustomColorsChase( + pixels, speed=0.1, colors=[RED, PINK], size=2, spacing=3 +) animations = AnimationSequence( @@ -48,7 +53,8 @@ custom_colors_chase_rwb, custom_colors_chase_rg, custom_colors_chase_rg_r, - advance_interval=6, auto_clear=True, + advance_interval=6, + auto_clear=True, ) while True: From 3a224b09f974bec08c7a04bfcfd2e49ee81ee399 Mon Sep 17 00:00:00 2001 From: cjsieh Date: Mon, 15 Jun 2020 13:37:50 -0500 Subject: [PATCH 10/26] Add files via upload reformatted via black --- adafruit_led_animation/animation/customcolorschase.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/adafruit_led_animation/animation/customcolorschase.py b/adafruit_led_animation/animation/customcolorschase.py index f1cc02c..3645344 100644 --- a/adafruit_led_animation/animation/customcolorschase.py +++ b/adafruit_led_animation/animation/customcolorschase.py @@ -63,7 +63,15 @@ class CustomColorsChase(Chase): # pylint: disable=too-many-arguments def __init__( - self, pixel_object, speed, size=2, spacing=3, reverse=False, name=None, colors=RAINBOW): + self, + pixel_object, + speed, + size=2, + spacing=3, + reverse=False, + name=None, + colors=RAINBOW, + ): self._num_colors = len(colors) self._colors = colors self._color_idx = 0 From 05c690803f87422feaff5b328677256e00e0041f Mon Sep 17 00:00:00 2001 From: cjsieh Date: Mon, 15 Jun 2020 13:47:55 -0500 Subject: [PATCH 11/26] Add files via upload fixed "line too long" as indicated by pylint --- adafruit_led_animation/animation/customcolorschase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_led_animation/animation/customcolorschase.py b/adafruit_led_animation/animation/customcolorschase.py index 3645344..02f66e3 100644 --- a/adafruit_led_animation/animation/customcolorschase.py +++ b/adafruit_led_animation/animation/customcolorschase.py @@ -55,7 +55,7 @@ class CustomColorsChase(Chase): :param pixel_object: The initialised LED object. :param float speed: Animation speed rate in seconds, e.g. ``0.1``. - :param colors: Animation color in list of `(r, g, b)`` tuple, or ``0x000000`` hex format, default is RAINBOW. + :param colors: Animation colors in list of `(r, g, b)`` tuple, or ``0x000000`` hex format :param size: Number of pixels to turn on in a row. :param spacing: Number of pixels to turn off in a row. :param reverse: Reverse direction of movement. From 2135dcbc813427192e1522c4b03caa5f17c826aa Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Thu, 18 Jun 2020 18:07:51 -0400 Subject: [PATCH 12/26] Fix differing argument. --- adafruit_led_animation/sequence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_led_animation/sequence.py b/adafruit_led_animation/sequence.py index f1aba9c..cf9ce3f 100644 --- a/adafruit_led_animation/sequence.py +++ b/adafruit_led_animation/sequence.py @@ -317,6 +317,6 @@ def on_cycle_complete(self): super().on_cycle_complete() self._running = False - def animate(self): + def animate(self, show=True): super().animate() return self._running From ab9fd1c32d28f7e3811274ec3afe06ee95a99173 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Thu, 18 Jun 2020 20:22:11 -0400 Subject: [PATCH 13/26] pass show param to super --- adafruit_led_animation/sequence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_led_animation/sequence.py b/adafruit_led_animation/sequence.py index cf9ce3f..31aac05 100644 --- a/adafruit_led_animation/sequence.py +++ b/adafruit_led_animation/sequence.py @@ -318,5 +318,5 @@ def on_cycle_complete(self): self._running = False def animate(self, show=True): - super().animate() + super().animate(show) return self._running From 4d8971d38303767d0d3b219d53b722cd2128ece7 Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Fri, 19 Jun 2020 16:06:13 -0400 Subject: [PATCH 14/26] Add sequence fix. --- adafruit_led_animation/sequence.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_led_animation/sequence.py b/adafruit_led_animation/sequence.py index f1aba9c..31aac05 100644 --- a/adafruit_led_animation/sequence.py +++ b/adafruit_led_animation/sequence.py @@ -317,6 +317,6 @@ def on_cycle_complete(self): super().on_cycle_complete() self._running = False - def animate(self): - super().animate() + def animate(self, show=True): + super().animate(show) return self._running From c88584d4bb675ffc6253dc7e701ba4f230b4d333 Mon Sep 17 00:00:00 2001 From: cjsieh Date: Fri, 19 Jun 2020 21:22:52 -0500 Subject: [PATCH 15/26] Add files via upload remove references to rainbowchase. Change customcolorschase to customcolorchase. --- customcolorchase.py | 85 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 customcolorchase.py diff --git a/customcolorchase.py b/customcolorchase.py new file mode 100644 index 0000000..7defcb6 --- /dev/null +++ b/customcolorchase.py @@ -0,0 +1,85 @@ +# The MIT License (MIT) +# +# Copyright (c) 2019-2020 Roy Hooper +# Copyright (c) 2020 Kattni Rembor for Adafruit Industries +# Copyright (c) 2020 Connie Sieh +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +""" +`adafruit_led_animation.animation.customcolorchase` +================================================================================ + +Custom color chase animation for CircuitPython helper library for LED animations. + +* Author(s): Roy Hooper, Kattni Rembor, Connie Sieh + +Implementation Notes +-------------------- + +**Hardware:** + +* `Adafruit NeoPixels `_ +* `Adafruit DotStars `_ + +**Software and Dependencies:** + +* Adafruit CircuitPython firmware for the supported boards: + https://circuitpython.org/downloads + + +""" + +from adafruit_led_animation.animation.chase import Chase +from adafruit_led_animation.color import RAINBOW + + +class CustomColorChase(Chase): + """ + Chase pixels in one direction, like a theater marquee with Custom Colors + + :param pixel_object: The initialised LED object. + :param float speed: Animation speed rate in seconds, e.g. ``0.1``. + :param colors: Animation colors in list of `(r, g, b)`` tuple, or ``0x000000`` hex format + :param size: Number of pixels to turn on in a row. + :param spacing: Number of pixels to turn off in a row. + :param reverse: Reverse direction of movement. + """ + + # pylint: disable=too-many-arguments + def __init__( + self, + pixel_object, + speed, + size=2, + spacing=3, + reverse=False, + name=None, + colors=RAINBOW, + ): + self._num_colors = len(colors) + self._colors = colors + self._color_idx = 0 + super().__init__(pixel_object, speed, 0, size, spacing, reverse, name) + + def bar_color(self, n, pixel_no=0): + return self._colors[self._color_idx - (n % len(self._colors))] + + def on_cycle_complete(self): + self._color_idx = (self._color_idx + self._direction) % len(self._colors) + super().on_cycle_complete() From 5554e360c21ef29623f551f51305eacc9b6ef9ee Mon Sep 17 00:00:00 2001 From: cjsieh Date: Fri, 19 Jun 2020 21:23:34 -0500 Subject: [PATCH 16/26] Delete customcolorchase.py put in wrong place --- customcolorchase.py | 85 --------------------------------------------- 1 file changed, 85 deletions(-) delete mode 100644 customcolorchase.py diff --git a/customcolorchase.py b/customcolorchase.py deleted file mode 100644 index 7defcb6..0000000 --- a/customcolorchase.py +++ /dev/null @@ -1,85 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2019-2020 Roy Hooper -# Copyright (c) 2020 Kattni Rembor for Adafruit Industries -# Copyright (c) 2020 Connie Sieh -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -""" -`adafruit_led_animation.animation.customcolorchase` -================================================================================ - -Custom color chase animation for CircuitPython helper library for LED animations. - -* Author(s): Roy Hooper, Kattni Rembor, Connie Sieh - -Implementation Notes --------------------- - -**Hardware:** - -* `Adafruit NeoPixels `_ -* `Adafruit DotStars `_ - -**Software and Dependencies:** - -* Adafruit CircuitPython firmware for the supported boards: - https://circuitpython.org/downloads - - -""" - -from adafruit_led_animation.animation.chase import Chase -from adafruit_led_animation.color import RAINBOW - - -class CustomColorChase(Chase): - """ - Chase pixels in one direction, like a theater marquee with Custom Colors - - :param pixel_object: The initialised LED object. - :param float speed: Animation speed rate in seconds, e.g. ``0.1``. - :param colors: Animation colors in list of `(r, g, b)`` tuple, or ``0x000000`` hex format - :param size: Number of pixels to turn on in a row. - :param spacing: Number of pixels to turn off in a row. - :param reverse: Reverse direction of movement. - """ - - # pylint: disable=too-many-arguments - def __init__( - self, - pixel_object, - speed, - size=2, - spacing=3, - reverse=False, - name=None, - colors=RAINBOW, - ): - self._num_colors = len(colors) - self._colors = colors - self._color_idx = 0 - super().__init__(pixel_object, speed, 0, size, spacing, reverse, name) - - def bar_color(self, n, pixel_no=0): - return self._colors[self._color_idx - (n % len(self._colors))] - - def on_cycle_complete(self): - self._color_idx = (self._color_idx + self._direction) % len(self._colors) - super().on_cycle_complete() From 201bb4781a8a1ae3e20cc484584c5cadc15bd5fe Mon Sep 17 00:00:00 2001 From: cjsieh Date: Fri, 19 Jun 2020 21:24:34 -0500 Subject: [PATCH 17/26] Add files via upload Changed references to rainbowchase. Changed from CustomColorsChase to CustomColorChase --- .../animation/customcolorchase.py | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 adafruit_led_animation/animation/customcolorchase.py diff --git a/adafruit_led_animation/animation/customcolorchase.py b/adafruit_led_animation/animation/customcolorchase.py new file mode 100644 index 0000000..7defcb6 --- /dev/null +++ b/adafruit_led_animation/animation/customcolorchase.py @@ -0,0 +1,85 @@ +# The MIT License (MIT) +# +# Copyright (c) 2019-2020 Roy Hooper +# Copyright (c) 2020 Kattni Rembor for Adafruit Industries +# Copyright (c) 2020 Connie Sieh +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +""" +`adafruit_led_animation.animation.customcolorchase` +================================================================================ + +Custom color chase animation for CircuitPython helper library for LED animations. + +* Author(s): Roy Hooper, Kattni Rembor, Connie Sieh + +Implementation Notes +-------------------- + +**Hardware:** + +* `Adafruit NeoPixels `_ +* `Adafruit DotStars `_ + +**Software and Dependencies:** + +* Adafruit CircuitPython firmware for the supported boards: + https://circuitpython.org/downloads + + +""" + +from adafruit_led_animation.animation.chase import Chase +from adafruit_led_animation.color import RAINBOW + + +class CustomColorChase(Chase): + """ + Chase pixels in one direction, like a theater marquee with Custom Colors + + :param pixel_object: The initialised LED object. + :param float speed: Animation speed rate in seconds, e.g. ``0.1``. + :param colors: Animation colors in list of `(r, g, b)`` tuple, or ``0x000000`` hex format + :param size: Number of pixels to turn on in a row. + :param spacing: Number of pixels to turn off in a row. + :param reverse: Reverse direction of movement. + """ + + # pylint: disable=too-many-arguments + def __init__( + self, + pixel_object, + speed, + size=2, + spacing=3, + reverse=False, + name=None, + colors=RAINBOW, + ): + self._num_colors = len(colors) + self._colors = colors + self._color_idx = 0 + super().__init__(pixel_object, speed, 0, size, spacing, reverse, name) + + def bar_color(self, n, pixel_no=0): + return self._colors[self._color_idx - (n % len(self._colors))] + + def on_cycle_complete(self): + self._color_idx = (self._color_idx + self._direction) % len(self._colors) + super().on_cycle_complete() From ef4435c4bf8b4aeb7882e4d3ba357adc5847f7b6 Mon Sep 17 00:00:00 2001 From: cjsieh Date: Fri, 19 Jun 2020 21:26:18 -0500 Subject: [PATCH 18/26] Delete customcolorschase.py changed from customcolorschase to customcolorchase --- .../animation/customcolorschase.py | 85 ------------------- 1 file changed, 85 deletions(-) delete mode 100644 adafruit_led_animation/animation/customcolorschase.py diff --git a/adafruit_led_animation/animation/customcolorschase.py b/adafruit_led_animation/animation/customcolorschase.py deleted file mode 100644 index 02f66e3..0000000 --- a/adafruit_led_animation/animation/customcolorschase.py +++ /dev/null @@ -1,85 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2019-2020 Roy Hooper -# Copyright (c) 2020 Kattni Rembor for Adafruit Industries -# Copyright (c) 2020 Connie Sieh -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -""" -`adafruit_led_animation.animation.rainbowchase` -================================================================================ - -Rainbow chase animation for CircuitPython helper library for LED animations. - -* Author(s): Roy Hooper, Kattni Rembor, Connie Sieh - -Implementation Notes --------------------- - -**Hardware:** - -* `Adafruit NeoPixels `_ -* `Adafruit DotStars `_ - -**Software and Dependencies:** - -* Adafruit CircuitPython firmware for the supported boards: - https://circuitpython.org/downloads - - -""" - -from adafruit_led_animation.animation.chase import Chase -from adafruit_led_animation.color import RAINBOW - - -class CustomColorsChase(Chase): - """ - Chase pixels in one direction, like a theater marquee with Custom Colors - - :param pixel_object: The initialised LED object. - :param float speed: Animation speed rate in seconds, e.g. ``0.1``. - :param colors: Animation colors in list of `(r, g, b)`` tuple, or ``0x000000`` hex format - :param size: Number of pixels to turn on in a row. - :param spacing: Number of pixels to turn off in a row. - :param reverse: Reverse direction of movement. - """ - - # pylint: disable=too-many-arguments - def __init__( - self, - pixel_object, - speed, - size=2, - spacing=3, - reverse=False, - name=None, - colors=RAINBOW, - ): - self._num_colors = len(colors) - self._colors = colors - self._color_idx = 0 - super().__init__(pixel_object, speed, 0, size, spacing, reverse, name) - - def bar_color(self, n, pixel_no=0): - return self._colors[self._color_idx - (n % len(self._colors))] - - def on_cycle_complete(self): - self._color_idx = (self._color_idx + self._direction) % len(self._colors) - super().on_cycle_complete() From 9d2b2062c37463eafacaef618a2305bfb3ca5910 Mon Sep 17 00:00:00 2001 From: cjsieh Date: Fri, 19 Jun 2020 21:28:19 -0500 Subject: [PATCH 19/26] Add files via upload change from CustomColorsChase to CustomColorChase --- examples/led_animation_all_animations.py | 8 ++- examples/led_animation_customcolorchase.py | 60 ++++++++++++++++++++++ 2 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 examples/led_animation_customcolorchase.py diff --git a/examples/led_animation_all_animations.py b/examples/led_animation_all_animations.py index 3b7a20e..0d55804 100644 --- a/examples/led_animation_all_animations.py +++ b/examples/led_animation_all_animations.py @@ -21,7 +21,7 @@ from adafruit_led_animation.animation.solid import Solid from adafruit_led_animation.animation.colorcycle import ColorCycle from adafruit_led_animation.animation.rainbow import Rainbow -from adafruit_led_animation.animation.customcolorschase import CustomColorsChase +from adafruit_led_animation.animation.customcolorchase import CustomColorChase from adafruit_led_animation.sequence import AnimationSequence from adafruit_led_animation.color import PURPLE, WHITE, AMBER, JADE, MAGENTA, ORANGE @@ -44,9 +44,7 @@ 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_colors_chase = CustomColorsChase( - pixels, speed=0.1, size=2, spacing=3, colors=[ORANGE, WHITE, JADE] -) +custom_color_chase = CustomColorChase(pixels, speed=0.1, size=2, spacing=3,colors=[ORANGE, WHITE, JADE]) animations = AnimationSequence( @@ -61,7 +59,7 @@ rainbow_comet, sparkle_pulse, rainbow_chase, - custom_colors_chase, + custom_color_chase, advance_interval=5, auto_clear=True, ) diff --git a/examples/led_animation_customcolorchase.py b/examples/led_animation_customcolorchase.py new file mode 100644 index 0000000..85b4e9e --- /dev/null +++ b/examples/led_animation_customcolorchase.py @@ -0,0 +1,60 @@ +""" +This example displays the basic animations in sequence, at a five second interval. + +For NeoPixel FeatherWing. Update pixel_pin and pixel_num to match your wiring if using +a different form of NeoPixels. + +This example may not work on SAMD21 (M0) boards. +""" +import board +import neopixel + +from adafruit_led_animation.animation.customcolorchase import CustomColorChase +from adafruit_led_animation.sequence import AnimationSequence +# colorwheel only needed for rainbowchase example +from adafruit_led_animation.color import colorwheel +# Colors for customcolorchase examples +from adafruit_led_animation.color import PINK, GREEN, RED, BLUE + +# Update to match the pin connected to your NeoPixels +pixel_pin = board.D5 +# Update to match the number of NeoPixels you have connected +pixel_num = 30 +brightness = 0.3 + +pixels = neopixel.NeoPixel( + pixel_pin, pixel_num, brightness=brightness, auto_write=False +) + +# colors default to RAINBOW as defined in color.py +custom_color_chase_rainbow = CustomColorChase(pixels, speed=0.1, size=2, spacing=3) +custom_color_chase_rainbow_r = CustomColorChase(pixels, speed=0.1, size=3, spacing=3,reverse=True) + +# Example with same colors as RainbowChase +steps=30 +#This was taken from rainbowchase.py +rainbow_colors = [colorwheel(n % 256) for n in range(0, 512, steps)] +#Now use rainbow_colors with CustomColorChase +custom_color_chase_rainbowchase = CustomColorChase(pixels, speed=0.1, colors=rainbow_colors, size=2, spacing=3) + +custom_color_chase_bgp = CustomColorChase( + pixels, speed=0.1, colors=[BLUE, GREEN, PINK], size=3, spacing=2 +) + +# Can use integer values for color, 0 is black +custom_color_chase_br = CustomColorChase( + pixels, speed=0.1, colors=[BLUE, 0, RED, 0], size=2, spacing=0 ) + +animations = AnimationSequence( + custom_color_chase_rainbow, + custom_color_chase_rainbow_r, + custom_color_chase_rainbowchase, + custom_color_chase_bgp, + custom_color_chase_br, + advance_interval=6, + #advance_on_cycle_complete=True, + auto_clear=True, +) + +while True: + animations.animate() From 1d0b9dad1e2c735855aa9a67a8d0fd6334cc9c81 Mon Sep 17 00:00:00 2001 From: cjsieh Date: Fri, 19 Jun 2020 21:28:57 -0500 Subject: [PATCH 20/26] Delete led_animation_customcolorschase.py changed from ccustomcolorschase to customcolorchase --- examples/led_animation_customcolorschase.py | 61 --------------------- 1 file changed, 61 deletions(-) delete mode 100644 examples/led_animation_customcolorschase.py diff --git a/examples/led_animation_customcolorschase.py b/examples/led_animation_customcolorschase.py deleted file mode 100644 index 76aa7e2..0000000 --- a/examples/led_animation_customcolorschase.py +++ /dev/null @@ -1,61 +0,0 @@ -""" -This example displays the basic animations in sequence, at a five second interval. - -For NeoPixel FeatherWing. Update pixel_pin and pixel_num to match your wiring if using -a different form of NeoPixels. - -This example may not work on SAMD21 (M0) boards. -""" -import board -import neopixel - -from adafruit_led_animation.animation.customcolorschase import CustomColorsChase -from adafruit_led_animation.sequence import AnimationSequence -from adafruit_led_animation.color import PINK, PURPLE, GREEN, RED, WHITE, BLUE - -# Update to match the pin connected to your NeoPixels -pixel_pin = board.D5 -# Update to match the number of NeoPixels you have connected -pixel_num = 32 -brightness = 0.3 - -pixels = neopixel.NeoPixel( - pixel_pin, pixel_num, brightness=brightness, auto_write=False -) - -# colors default to RAINBOW -custom_colors_chase_rainbow = CustomColorsChase(pixels, speed=0.1, size=2, spacing=3) -# Patriotic -custom_colors_chase_rwb = CustomColorsChase( - pixels, speed=0.1, colors=[RED, WHITE, BLUE], size=2, spacing=3 -) -# St Pat Day -custom_colors_chase_gw = CustomColorsChase( - pixels, speed=0.1, colors=[GREEN, WHITE], size=2, spacing=3 -) -# Christmas -custom_colors_chase_rg = CustomColorsChase( - pixels, speed=0.1, colors=[RED, GREEN], size=2, spacing=3 -) -custom_colors_chase_rg_r = CustomColorsChase( - pixels, speed=0.1, colors=[RED, GREEN], size=1, spacing=2, reverse=True -) -# Valentines Day -custom_colors_chase_rp = CustomColorsChase( - pixels, speed=0.1, colors=[RED, PINK], size=2, spacing=3 -) - - -animations = AnimationSequence( - custom_colors_chase_rainbow, - custom_colors_chase_rp, - custom_colors_chase_gw, - custom_colors_chase_rwb, - custom_colors_chase_rg, - custom_colors_chase_rg_r, - advance_interval=6, - auto_clear=True, -) - -while True: - animations.animate() From 1a600cf7994c4c445cf0bef3abc2057358eb36f1 Mon Sep 17 00:00:00 2001 From: cjsieh Date: Fri, 19 Jun 2020 21:40:51 -0500 Subject: [PATCH 21/26] Add files via upload prefixed "black" formating --- examples/led_animation_all_animations.py | 4 +++- examples/led_animation_customcolorchase.py | 21 ++++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/examples/led_animation_all_animations.py b/examples/led_animation_all_animations.py index 0d55804..5eb8287 100644 --- a/examples/led_animation_all_animations.py +++ b/examples/led_animation_all_animations.py @@ -44,7 +44,9 @@ 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]) +custom_color_chase = CustomColorChase( + pixels, speed=0.1, size=2, spacing=3, colors=[ORANGE, WHITE, JADE] +) animations = AnimationSequence( diff --git a/examples/led_animation_customcolorchase.py b/examples/led_animation_customcolorchase.py index 85b4e9e..449179a 100644 --- a/examples/led_animation_customcolorchase.py +++ b/examples/led_animation_customcolorchase.py @@ -11,8 +11,10 @@ from adafruit_led_animation.animation.customcolorchase import CustomColorChase from adafruit_led_animation.sequence import AnimationSequence + # colorwheel only needed for rainbowchase example from adafruit_led_animation.color import colorwheel + # Colors for customcolorchase examples from adafruit_led_animation.color import PINK, GREEN, RED, BLUE @@ -28,14 +30,18 @@ # colors default to RAINBOW as defined in color.py custom_color_chase_rainbow = CustomColorChase(pixels, speed=0.1, size=2, spacing=3) -custom_color_chase_rainbow_r = CustomColorChase(pixels, speed=0.1, size=3, spacing=3,reverse=True) +custom_color_chase_rainbow_r = CustomColorChase( + pixels, speed=0.1, size=3, spacing=3, reverse=True +) # Example with same colors as RainbowChase -steps=30 -#This was taken from rainbowchase.py +steps = 30 +# This was taken from rainbowchase.py rainbow_colors = [colorwheel(n % 256) for n in range(0, 512, steps)] -#Now use rainbow_colors with CustomColorChase -custom_color_chase_rainbowchase = CustomColorChase(pixels, speed=0.1, colors=rainbow_colors, size=2, spacing=3) +# Now use rainbow_colors with CustomColorChase +custom_color_chase_rainbowchase = CustomColorChase( + pixels, speed=0.1, colors=rainbow_colors, size=2, spacing=3 +) custom_color_chase_bgp = CustomColorChase( pixels, speed=0.1, colors=[BLUE, GREEN, PINK], size=3, spacing=2 @@ -43,7 +49,8 @@ # Can use integer values for color, 0 is black custom_color_chase_br = CustomColorChase( - pixels, speed=0.1, colors=[BLUE, 0, RED, 0], size=2, spacing=0 ) + pixels, speed=0.1, colors=[BLUE, 0, RED, 0], size=2, spacing=0 +) animations = AnimationSequence( custom_color_chase_rainbow, @@ -52,7 +59,7 @@ custom_color_chase_bgp, custom_color_chase_br, advance_interval=6, - #advance_on_cycle_complete=True, + # advance_on_cycle_complete=True, auto_clear=True, ) From a8ad8eba2c46a49154a6d6a506b459f2c161b4a1 Mon Sep 17 00:00:00 2001 From: cjsieh Date: Fri, 19 Jun 2020 22:04:36 -0500 Subject: [PATCH 22/26] Add files via upload fixed description removed reference to advance_on_cycle_complete as not used now --- examples/led_animation_customcolorchase.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/led_animation_customcolorchase.py b/examples/led_animation_customcolorchase.py index 449179a..bc9d891 100644 --- a/examples/led_animation_customcolorchase.py +++ b/examples/led_animation_customcolorchase.py @@ -1,5 +1,5 @@ """ -This example displays the basic animations in sequence, at a five second interval. +This example displays custom color chase animations in sequence, at a six second interval. For NeoPixel FeatherWing. Update pixel_pin and pixel_num to match your wiring if using a different form of NeoPixels. @@ -59,7 +59,6 @@ custom_color_chase_bgp, custom_color_chase_br, advance_interval=6, - # advance_on_cycle_complete=True, auto_clear=True, ) From 7b5ba8222ea2da098b61671a26139defbe8cffa3 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Mon, 22 Jun 2020 17:50:16 -0400 Subject: [PATCH 23/26] fix color setting so that animations like blink aren't reset on color setting --- adafruit_led_animation/animation/__init__.py | 16 ++++++++-------- adafruit_led_animation/animation/blink.py | 2 +- adafruit_led_animation/animation/comet.py | 5 +---- adafruit_led_animation/animation/rainbowcomet.py | 2 +- adafruit_led_animation/animation/solid.py | 2 +- adafruit_led_animation/animation/sparkle.py | 2 +- 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/adafruit_led_animation/animation/__init__.py b/adafruit_led_animation/animation/__init__.py index 5265296..b9e76c1 100644 --- a/adafruit_led_animation/animation/__init__.py +++ b/adafruit_led_animation/animation/__init__.py @@ -68,7 +68,7 @@ def __init__(self, pixel_object, speed, color, peers=None, paused=False, name=No self._time_left_at_pause = 0 self._also_notify = [] self.speed = speed # sets _speed_ns - self.color = color # Triggers _recompute_color + self.color = color # Triggers _set_color self.name = name self.cycle_complete = False self.notify_cycles = 1 @@ -185,10 +185,16 @@ def color(self): def color(self, color): if self._color == color: return + self._set_color(color) + + def _set_color(self, color): + """ + Called after the color is changed, which includes at initialization. + Override as needed. + """ if isinstance(color, int): color = (color >> 16 & 0xFF, color >> 8 & 0xFF, color & 0xFF) self._color = color - self._recompute_color(color) @property def speed(self): @@ -201,12 +207,6 @@ def speed(self): def speed(self, seconds): self._speed_ns = int(seconds * NANOS_PER_SECOND) - def _recompute_color(self, color): - """ - Called if the color is changed, which includes at initialization. - Override as needed. - """ - def on_cycle_complete(self): """ Called by some animations when they complete an animation cycle. diff --git a/adafruit_led_animation/animation/blink.py b/adafruit_led_animation/animation/blink.py index fe6ec10..8d482f8 100644 --- a/adafruit_led_animation/animation/blink.py +++ b/adafruit_led_animation/animation/blink.py @@ -60,5 +60,5 @@ class Blink(ColorCycle): def __init__(self, pixel_object, speed, color, name=None): super().__init__(pixel_object, speed, [color, BLACK], name=name) - def _recompute_color(self, color): + def _set_color(self, color): self.colors = [color, BLACK] diff --git a/adafruit_led_animation/animation/comet.py b/adafruit_led_animation/animation/comet.py index bbe54e7..85e36d2 100644 --- a/adafruit_led_animation/animation/comet.py +++ b/adafruit_led_animation/animation/comet.py @@ -92,10 +92,7 @@ def __init__( on_cycle_complete_supported = True - def _recompute_color(self, color): - self._comet_recompute_color(color) - - def _comet_recompute_color(self, color): + def _set_color(self, color): self._comet_colors = [BLACK] for n in range(self._tail_length): self._comet_colors.append( diff --git a/adafruit_led_animation/animation/rainbowcomet.py b/adafruit_led_animation/animation/rainbowcomet.py index 572f859..3cc84bf 100644 --- a/adafruit_led_animation/animation/rainbowcomet.py +++ b/adafruit_led_animation/animation/rainbowcomet.py @@ -82,7 +82,7 @@ def __init__( self._colorwheel_offset = colorwheel_offset super().__init__(pixel_object, speed, 0, tail_length, reverse, bounce, name) - def _comet_recompute_color(self, color): + def _set_color(self, color): self._comet_colors = [BLACK] for n in range(self._tail_length): invert = self._tail_length - n - 1 diff --git a/adafruit_led_animation/animation/solid.py b/adafruit_led_animation/animation/solid.py index 7fa90e6..497fff3 100644 --- a/adafruit_led_animation/animation/solid.py +++ b/adafruit_led_animation/animation/solid.py @@ -58,5 +58,5 @@ class Solid(ColorCycle): def __init__(self, pixel_object, color, name=None): super().__init__(pixel_object, speed=1, colors=[color], name=name) - def _recompute_color(self, color): + def _set_color(self, color): self.colors = [color] diff --git a/adafruit_led_animation/animation/sparkle.py b/adafruit_led_animation/animation/sparkle.py index 8f0e691..b975f24 100644 --- a/adafruit_led_animation/animation/sparkle.py +++ b/adafruit_led_animation/animation/sparkle.py @@ -71,7 +71,7 @@ def __init__(self, pixel_object, speed, color, num_sparkles=1, name=None): self._pixels = [] super().__init__(pixel_object, speed, color, name=name) - def _recompute_color(self, color): + def _set_color(self, color): half_color = tuple(color[rgb] // 4 for rgb in range(len(color))) dim_color = tuple(color[rgb] // 10 for rgb in range(len(color))) for pixel in range(len(self.pixel_object)): From beaa41f0cb5961096398e1388bf0989d82cdc0a3 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Mon, 22 Jun 2020 18:15:08 -0400 Subject: [PATCH 24/26] fix sparklepulse to use _set_color --- adafruit_led_animation/animation/__init__.py | 4 ++-- adafruit_led_animation/animation/sparklepulse.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/adafruit_led_animation/animation/__init__.py b/adafruit_led_animation/animation/__init__.py index b9e76c1..2876afe 100644 --- a/adafruit_led_animation/animation/__init__.py +++ b/adafruit_led_animation/animation/__init__.py @@ -185,6 +185,8 @@ def color(self): def color(self, color): if self._color == color: return + if isinstance(color, int): + color = (color >> 16 & 0xFF, color >> 8 & 0xFF, color & 0xFF) self._set_color(color) def _set_color(self, color): @@ -192,8 +194,6 @@ def _set_color(self, color): Called after the color is changed, which includes at initialization. Override as needed. """ - if isinstance(color, int): - color = (color >> 16 & 0xFF, color >> 8 & 0xFF, color & 0xFF) self._color = color @property diff --git a/adafruit_led_animation/animation/sparklepulse.py b/adafruit_led_animation/animation/sparklepulse.py index 8e41bf2..9a06848 100644 --- a/adafruit_led_animation/animation/sparklepulse.py +++ b/adafruit_led_animation/animation/sparklepulse.py @@ -80,6 +80,9 @@ def __init__( ) self._generator = pulse_generator(self._period, self, dotstar_pwm=dotstar) + def _set_color(self, color): + self._color = color + def draw(self): self._sparkle_color = next(self._generator) super().draw() From 09e5f656cead18132876c26d93f7fa3b52e2916f Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Mon, 22 Jun 2020 19:11:36 -0400 Subject: [PATCH 25/26] make animation fill show the pixels. --- adafruit_led_animation/animation/__init__.py | 1 + adafruit_led_animation/sequence.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_led_animation/animation/__init__.py b/adafruit_led_animation/animation/__init__.py index 5265296..51d097d 100644 --- a/adafruit_led_animation/animation/__init__.py +++ b/adafruit_led_animation/animation/__init__.py @@ -173,6 +173,7 @@ def fill(self, color): Fills the pixel object with a color. """ self.pixel_object.fill(color) + self.pixel_object.show() @property def color(self): diff --git a/adafruit_led_animation/sequence.py b/adafruit_led_animation/sequence.py index 31aac05..bdf8eff 100644 --- a/adafruit_led_animation/sequence.py +++ b/adafruit_led_animation/sequence.py @@ -172,7 +172,6 @@ def _advance(self): self.current_animation.reset() if self.auto_clear: self.current_animation.fill(self.clear_color) - self.current_animation.show() if self._random: self.random() else: From cda21457fefb827491de7a6bc3ddf6386bd46a22 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Mon, 22 Jun 2020 20:59:31 -0400 Subject: [PATCH 26/26] fix sync when there are multiple different pixel objects involved --- adafruit_led_animation/group.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/adafruit_led_animation/group.py b/adafruit_led_animation/group.py index 0005170..a036a03 100644 --- a/adafruit_led_animation/group.py +++ b/adafruit_led_animation/group.py @@ -47,6 +47,8 @@ __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_LED_Animation.git" +from adafruit_led_animation.animation import Animation + class AnimationGroup: """ @@ -158,7 +160,14 @@ def animate(self, show=True): if self._sync: result = self._members[0].animate(show=False) if result and show: - self._members[0].show() + last_strip = None + for member in self._members: + if isinstance(member, Animation): + if last_strip != member.pixel_object: + member.pixel_object.show() + last_strip = member.pixel_object + else: + member.show() return result return any([item.animate(show) for item in self._members])