diff --git a/adafruit_led_animation/animation/volume.py b/adafruit_led_animation/animation/volume.py index 5827ba1..cbfb8d1 100644 --- a/adafruit_led_animation/animation/volume.py +++ b/adafruit_led_animation/animation/volume.py @@ -1,22 +1,6 @@ -# The MIT License (MIT) +# SPDX-FileCopyrightText: 2020 Gamblor21 # -# 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. +# SPDX-License-Identifier: MIT """ `adafruit_led_animation.animation.volume` ================================================================================ diff --git a/adafruit_led_animation/timedsequence.py b/adafruit_led_animation/timedsequence.py index 42773c6..a08c5e1 100644 --- a/adafruit_led_animation/timedsequence.py +++ b/adafruit_led_animation/timedsequence.py @@ -1,22 +1,6 @@ -# The MIT License (MIT) +# SPDX-FileCopyrightText: 2020 Gamblor21 # -# 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. +# SPDX-License-Identifier: MIT """ `adafruit_led_animation.timedsequence` ================================================================================ diff --git a/examples/led_animation_timedsequence.py b/examples/led_animation_timedsequence.py new file mode 100644 index 0000000..b6e05bf --- /dev/null +++ b/examples/led_animation_timedsequence.py @@ -0,0 +1,21 @@ +# SPDX-FileCopyrightText: 2020 Gamblor21 +# +# SPDX-License-Identifier: MIT +""" +Example for TimedSequence +""" +import board +import neopixel +from adafruit_led_animation.timedsequence import TimedAnimationSequence +import adafruit_led_animation.animation.comet as comet_animation +import adafruit_led_animation.animation.sparkle as sparkle_animation +import adafruit_led_animation.animation.blink as blink_animation +from adafruit_led_animation import color + +strip_pixels = neopixel.NeoPixel(board.D6, 32, brightness=0.1, auto_write=False) +blink = blink_animation.Blink(strip_pixels, 0.3, color.RED) +comet = comet_animation.Comet(strip_pixels, 0.1, color.BLUE) +sparkle = sparkle_animation.Sparkle(strip_pixels, 0.05, color.GREEN) +animations = TimedAnimationSequence(blink, 2, comet, 4, sparkle, 5) +while True: + animations.animate() diff --git a/examples/led_animation_volume.py b/examples/led_animation_volume.py new file mode 100644 index 0000000..2448636 --- /dev/null +++ b/examples/led_animation_volume.py @@ -0,0 +1,34 @@ +# SPDX-FileCopyrightText: 2023 Tim Cocks +# +# SPDX-License-Identifier: MIT + +"""Volume Animation Example""" +import board +from audiomp3 import MP3Decoder +import neopixel +from adafruit_led_animation.animation import volume + +try: + from audioio import AudioOut +except ImportError: + try: + from audiopwmio import PWMAudioOut as AudioOut + except ImportError: + pass # not always supported by every board! + +# Fill in your own MP3 file or use the one from the learn guide: +# https://learn.adafruit.com/circuitpython-essentials/circuitpython-mp3-audio#installing-project-code-3067700 +mp3file = "happy.mp3" +with open(mp3file, "rb") as mp3: + decoder = MP3Decoder(mp3) + audio = AudioOut(board.SPEAKER) + + strip_pixels = neopixel.NeoPixel(board.D4, 30, brightness=0.1, auto_write=False) + volume_anim = volume.Volume(strip_pixels, 0.3, (0, 255, 0), decoder, 400) + + while True: + audio.play(decoder) + print("playing", mp3file) + + while audio.playing: + volume_anim.animate()