-
Notifications
You must be signed in to change notification settings - Fork 45
Customcolorschase #51
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
Changes from 11 commits
33a95d6
ca806b8
a6ff874
9d41651
4e7ffc1
85edc47
e62e517
b068b7c
5892c25
3a224b0
05c6908
4d8971d
c88584d
5554e36
201bb47
ef4435c
9d2b206
1d0b9da
1a600cf
a8ad8eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.rainbowchase` | ||
================================================================================ | ||
|
||
Rainbow chase animation for CircuitPython helper library for LED animations. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be updated to describe the module, e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed |
||
|
||
* Author(s): Roy Hooper, Kattni Rembor, Connie Sieh | ||
|
||
Implementation Notes | ||
-------------------- | ||
|
||
**Hardware:** | ||
|
||
* `Adafruit NeoPixels <https://www.adafruit.com/category/168>`_ | ||
* `Adafruit DotStars <https://www.adafruit.com/category/885>`_ | ||
|
||
**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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Class names are typically singular. Please update this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed |
||
""" | ||
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() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.customcolorschase import CustomColorsChase | ||
from adafruit_led_animation.sequence import AnimationSequence | ||
from adafruit_led_animation.color import PURPLE, WHITE, AMBER, JADE, MAGENTA, ORANGE | ||
|
||
|
@@ -43,6 +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( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Call this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed |
||
pixels, speed=0.1, size=2, spacing=3, colors=[ORANGE, WHITE, JADE] | ||
) | ||
|
||
|
||
animations = AnimationSequence( | ||
|
@@ -57,6 +61,7 @@ | |
rainbow_comet, | ||
sparkle_pulse, | ||
rainbow_chase, | ||
custom_colors_chase, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update this to match, e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed |
||
advance_interval=5, | ||
auto_clear=True, | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
""" | ||
This example displays the basic animations in sequence, at a five second interval. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment needs to be updated to describe the new example. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed |
||
|
||
# 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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would update this to |
||
# Patriotic | ||
custom_colors_chase_rwb = CustomColorsChase( | ||
pixels, speed=0.1, colors=[RED, WHITE, BLUE], size=2, spacing=3 | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have a worldwide community and want everyone to feel welcome and included. Including this color combination under this name limits the scope of the example to the US, and could create a situation where users from elsewhere in the world, or even in the US, feel excluded. In light of the current climate, I feel it should be removed altogether. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed |
||
# St Pat Day | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Associating these color combinations with holidays could be exclusionary as some do not celebrate them. The colors are fine, but please remove the holiday themed comments. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed |
||
custom_colors_chase_gw = CustomColorsChase( | ||
pixels, speed=0.1, colors=[GREEN, WHITE], size=2, spacing=3 | ||
) | ||
# Christmas | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, re: removing holiday themed comments. |
||
custom_colors_chase_rg = CustomColorsChase( | ||
pixels, speed=0.1, colors=[RED, GREEN], size=2, spacing=3 | ||
) | ||
custom_colors_chase_rg_r = CustomColorsChase( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider renaming this to |
||
pixels, speed=0.1, colors=[RED, GREEN], size=1, spacing=2, reverse=True | ||
) | ||
# Valentines Day | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, re: removing holiday themed comments. |
||
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be updated to match the module name, e.g.
adafruit_led_animation.animation.customcolorchase
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed