From f985f01e614ff6f0f3d7ecba7096ab1712977045 Mon Sep 17 00:00:00 2001 From: Andrew Esler Date: Wed, 15 Apr 2015 00:30:14 +1200 Subject: [PATCH] Adding a new effect - Blink --- RGBEffects.cpp | 21 +++++++++++++++++++++ RGBEffects.h | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/RGBEffects.cpp b/RGBEffects.cpp index d633a18..c20fa0e 100644 --- a/RGBEffects.cpp +++ b/RGBEffects.cpp @@ -206,6 +206,24 @@ rgb CubeEffect::update(){ return _colour; } +class BlinkEffect : public Effect { + public: + virtual void setup(); + virtual rgb update(); + private: + byte _blinkOn; +}; + +void BlinkEffect::setup(){ + _blinkOn = 1; +} + +rgb BlinkEffect::update(){ + rgb c = (_blinkOn) ? BLUE : OFF; + _blinkOn = !_blinkOn; + return c; +} + /* RGBEffects class */ @@ -288,6 +306,9 @@ void RGBEffects::setEffect(RGBEffectType effect){ case EFFECT_CUBE: _currentEffectIndex = 3; break; + case EFFECT_BLINK: + _currentEffectIndex = 4; + break; } _curEffect = effect; diff --git a/RGBEffects.h b/RGBEffects.h index 41f37b5..e13047a 100644 --- a/RGBEffects.h +++ b/RGBEffects.h @@ -40,6 +40,7 @@ enum RGBEffectType { EFFECT_RAINBOW, EFFECT_FADE, EFFECT_CUBE, + EFFECT_BLINK, EFFECT_COUNTER_FINAL // dont use this one, just for counting }; @@ -70,7 +71,7 @@ class RGBEffects int _bluePin; int _numLeds; SolidEffect *_solidEffect; // this is ugly, but need to be able to change the colour - Effect * _effects[4]; + Effect * _effects[5]; int _currentEffectIndex; RGBEffectType _curEffect; void setLEDsColour(int red, int green, int blue);