Skip to content

Commit

Permalink
Adding a new effect - Blink
Browse files Browse the repository at this point in the history
  • Loading branch information
ajesler committed Apr 14, 2015
1 parent 20d2fbb commit f985f01
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
21 changes: 21 additions & 0 deletions RGBEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -288,6 +306,9 @@ void RGBEffects::setEffect(RGBEffectType effect){
case EFFECT_CUBE:
_currentEffectIndex = 3;
break;
case EFFECT_BLINK:
_currentEffectIndex = 4;
break;
}

_curEffect = effect;
Expand Down
3 changes: 2 additions & 1 deletion RGBEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ enum RGBEffectType {
EFFECT_RAINBOW,
EFFECT_FADE,
EFFECT_CUBE,
EFFECT_BLINK,
EFFECT_COUNTER_FINAL // dont use this one, just for counting
};

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f985f01

Please sign in to comment.