Skip to content

Commit

Permalink
Added mode: Merry Christmas (green/red running lights)
Browse files Browse the repository at this point in the history
  • Loading branch information
kitesurfer1404 committed Dec 10, 2016
1 parent 0682d9f commit 0267697
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This library features a variety of blinken effects for the WS2811/WS2812/NeoPixe
Features
--------

* 44 different effects. And counting.
* 45 different effects. And counting.
* Free of any delay()
* Tested on Arduino Nano, Uno, Micro and ESP8266.
* All effects with printable names - easy to use in user interfaces.
Expand Down Expand Up @@ -97,3 +97,4 @@ Effects
* **Comet** - Fireing comets from one end.
* **Fireworks** - Firework sparks.
* **Fireworks Random** - Random colored firework sparks.
* **Merry Christmas** - Alternating green/red pixels running.
17 changes: 17 additions & 0 deletions WS2812FX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1157,3 +1157,20 @@ void WS2812FX::mode_fireworks_random(void) {
mode_fireworks();
}


/*
* Alternating red/green pixels running.
*/
void WS2812FX::mode_merry_christmas(void) {
for(uint16_t i=0; i < _led_count; i++) {
if((i + _counter_mode_step) % 4 < 2) {
Adafruit_NeoPixel::setPixelColor(i, 255, 0, 0);
} else {
Adafruit_NeoPixel::setPixelColor(i, 0, 255, 0);
}
}
Adafruit_NeoPixel::show();

_counter_mode_step = (_counter_mode_step + 1) % 4;
_mode_delay = 50 + ((75 * (uint32_t)(SPEED_MAX - _speed)) / _led_count);
}
8 changes: 6 additions & 2 deletions WS2812FX.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
#define BRIGHTNESS_MIN 0
#define BRIGHTNESS_MAX 255

#define MODE_COUNT 44
#define MODE_COUNT 45

#define FX_MODE_STATIC 0
#define FX_MODE_BLINK 1
Expand Down Expand Up @@ -111,6 +111,7 @@
#define FX_MODE_COMET 41
#define FX_MODE_FIREWORKS 42
#define FX_MODE_FIREWORKS_RANDOM 43
#define FX_MODE_MERRY_CHRISTMAS 44


class WS2812FX : public Adafruit_NeoPixel {
Expand Down Expand Up @@ -164,6 +165,7 @@ class WS2812FX : public Adafruit_NeoPixel {
_mode[FX_MODE_COMET] = &WS2812FX::mode_comet;
_mode[FX_MODE_FIREWORKS] = &WS2812FX::mode_fireworks;
_mode[FX_MODE_FIREWORKS_RANDOM] = &WS2812FX::mode_fireworks_random;
_mode[FX_MODE_MERRY_CHRISTMAS] = &WS2812FX::mode_merry_christmas;

_name[FX_MODE_STATIC] = "Static";
_name[FX_MODE_BLINK] = "Blink";
Expand Down Expand Up @@ -209,6 +211,7 @@ class WS2812FX : public Adafruit_NeoPixel {
_name[FX_MODE_COMET] = "Comet";
_name[FX_MODE_FIREWORKS] = "Fireworks";
_name[FX_MODE_FIREWORKS_RANDOM] = "Fireworks Random";
_name[FX_MODE_MERRY_CHRISTMAS] = "Merry Christmas";

_mode_index = DEFAULT_MODE;
_speed = DEFAULT_SPEED;
Expand Down Expand Up @@ -300,7 +303,8 @@ class WS2812FX : public Adafruit_NeoPixel {
mode_larson_scanner(void),
mode_comet(void),
mode_fireworks(void),
mode_fireworks_random(void);
mode_fireworks_random(void),
mode_merry_christmas(void);

boolean
_running;
Expand Down
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ FX_MODE_LARSON_SCANNER KEYWORD2
FX_MODE_COMET KEYWORD2
FX_MODE_FIREWORKS KEYWORD2
FX_MODE_FIREWORKS_RANDOM KEYWORD2
FX_MODE_MERRY_CHRISTMAS KEYWORD2

0 comments on commit 0267697

Please sign in to comment.