From 5b48c48551c2050950287446b7df1d0af0aa4041 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Fri, 16 Dec 2016 19:09:24 -0800 Subject: [PATCH] Add stop all (#147) --- src/NeoPixelAnimator.h | 2 ++ src/internal/NeoPixelAnimator.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/NeoPixelAnimator.h b/src/NeoPixelAnimator.h index 62e52d5..21eb2ad 100644 --- a/src/NeoPixelAnimator.h +++ b/src/NeoPixelAnimator.h @@ -79,6 +79,8 @@ public: void StartAnimation(uint16_t indexAnimation, uint16_t duration, AnimUpdateCallback animUpdate); void StopAnimation(uint16_t indexAnimation); + void StopAll(); + void RestartAnimation(uint16_t indexAnimation) { if (indexAnimation >= _countAnimations || _animations[indexAnimation]._duration == 0) diff --git a/src/internal/NeoPixelAnimator.cpp b/src/internal/NeoPixelAnimator.cpp index 70f803d..db51a5d 100644 --- a/src/internal/NeoPixelAnimator.cpp +++ b/src/internal/NeoPixelAnimator.cpp @@ -108,6 +108,16 @@ void NeoPixelAnimator::StopAnimation(uint16_t indexAnimation) } } +void NeoPixelAnimator::StopAll() +{ + for (uint16_t indexAnimation = 0; indexAnimation < _countAnimations; ++indexAnimation) + { + _animations[indexAnimation].StopAnimation(); + } + _activeAnimations = 0; +} + + void NeoPixelAnimator::UpdateAnimations() { if (_isRunning)