mirror of
https://github.com/Fishwaldo/WLED.git
synced 2025-03-15 19:51:40 +00:00
Added 5 new effects from current WS2812FX library
This commit is contained in:
parent
007ca43ae7
commit
30b6fd8589
4 changed files with 248 additions and 9 deletions
|
@ -1328,6 +1328,228 @@ void WS2812FX::mode_fade_down(void)
|
|||
_mode_delay = 100 + ((100 * (uint32_t)(SPEED_MAX - _speed)) / SPEED_MAX);
|
||||
}
|
||||
|
||||
/*
|
||||
* Lights all LEDs after each other up starting from the outer edges and
|
||||
* finishing in the middle. Then turns them in reverse order off. Repeat.
|
||||
*/
|
||||
void WS2812FX::mode_dual_color_wipe_in_out(void) {
|
||||
int end = _led_count - _counter_mode_step - 1;
|
||||
bool odd = (_led_count % 2);
|
||||
int mid = odd ? ((_led_count / 2) + 1) : (_led_count / 2);
|
||||
if (_counter_mode_step < mid) {
|
||||
if (!_locked[_counter_mode_step])
|
||||
Adafruit_NeoPixel::setPixelColor(_counter_mode_step, _color);
|
||||
if (!_locked[end])
|
||||
Adafruit_NeoPixel::setPixelColor(end, _color);
|
||||
}
|
||||
else {
|
||||
if (odd) {
|
||||
// If odd, we need to 'double count' the center LED (once to turn it on,
|
||||
// once to turn it off). So trail one behind after the middle LED.
|
||||
if (!_locked[_counter_mode_step -1])
|
||||
Adafruit_NeoPixel::setPixelColor(_counter_mode_step - 1, 0);
|
||||
if (!_locked[end+1])
|
||||
Adafruit_NeoPixel::setPixelColor(end + 1, 0);
|
||||
} else {
|
||||
if (!_locked[_counter_mode_step])
|
||||
Adafruit_NeoPixel::setPixelColor(_counter_mode_step, 0);
|
||||
if (!_locked[end])
|
||||
Adafruit_NeoPixel::setPixelColor(end, 0);
|
||||
}
|
||||
}
|
||||
|
||||
_counter_mode_step++;
|
||||
if (odd) {
|
||||
if (_counter_mode_step > _led_count) {
|
||||
_counter_mode_step = 0;
|
||||
}
|
||||
} else {
|
||||
if (_counter_mode_step >= _led_count) {
|
||||
_counter_mode_step = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Adafruit_NeoPixel::show();
|
||||
|
||||
_mode_delay = 5 + ((50 * (uint32_t)(SPEED_MAX - _speed)) / _led_count);
|
||||
}
|
||||
|
||||
/*
|
||||
* Lights all LEDs after each other up starting from the outer edges and
|
||||
* finishing in the middle. Then turns them in that order off. Repeat.
|
||||
*/
|
||||
void WS2812FX::mode_dual_color_wipe_in_in(void) {
|
||||
bool odd = (_led_count % 2);
|
||||
int mid = _led_count / 2;
|
||||
if (odd) {
|
||||
if (_counter_mode_step <= mid) {
|
||||
if (!_locked[_counter_mode_step])
|
||||
Adafruit_NeoPixel::setPixelColor(_counter_mode_step, _color);
|
||||
if (!_locked[_led_count - _counter_mode_step - 1])
|
||||
Adafruit_NeoPixel::setPixelColor(_led_count - _counter_mode_step - 1, _color);
|
||||
} else {
|
||||
int i = _counter_mode_step - mid;
|
||||
if (!_locked[i-1])
|
||||
Adafruit_NeoPixel::setPixelColor(i - 1, 0);
|
||||
if (!_locked[_led_count - i])
|
||||
Adafruit_NeoPixel::setPixelColor(_led_count - i, 0);
|
||||
}
|
||||
} else {
|
||||
if (_counter_mode_step < mid) {
|
||||
if (!_locked[_counter_mode_step])
|
||||
Adafruit_NeoPixel::setPixelColor(_counter_mode_step, _color);
|
||||
if (!_locked[_led_count - _counter_mode_step - 1])
|
||||
Adafruit_NeoPixel::setPixelColor(_led_count - _counter_mode_step - 1, _color);
|
||||
} else {
|
||||
int i = _counter_mode_step - mid;
|
||||
if (!_locked[i])
|
||||
Adafruit_NeoPixel::setPixelColor(i, 0);
|
||||
if (!_locked[_led_count - i -1])
|
||||
Adafruit_NeoPixel::setPixelColor(_led_count - i - 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
_counter_mode_step++;
|
||||
if (odd) {
|
||||
if (_counter_mode_step > _led_count) {
|
||||
_counter_mode_step = 0;
|
||||
}
|
||||
} else {
|
||||
if (_counter_mode_step >= _led_count) {
|
||||
_counter_mode_step = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Adafruit_NeoPixel::show();
|
||||
|
||||
_mode_delay = 5 + ((50 * (uint32_t)(SPEED_MAX - _speed)) / _led_count);
|
||||
}
|
||||
|
||||
/*
|
||||
* Lights all LEDs after each other up starting from the middle and
|
||||
* finishing at the edges. Then turns them in that order off. Repeat.
|
||||
*/
|
||||
void WS2812FX::mode_dual_color_wipe_out_out(void) {
|
||||
int end = _led_count - _counter_mode_step - 1;
|
||||
bool odd = (_led_count % 2);
|
||||
int mid = _led_count / 2;
|
||||
|
||||
if (odd) {
|
||||
if (_counter_mode_step <= mid) {
|
||||
if (!_locked[mid + _counter_mode_step])
|
||||
Adafruit_NeoPixel::setPixelColor(mid + _counter_mode_step, _color);
|
||||
if (!_locked[mid - _counter_mode_step])
|
||||
Adafruit_NeoPixel::setPixelColor(mid - _counter_mode_step, _color);
|
||||
} else {
|
||||
if (!_locked[_counter_mode_step -1])
|
||||
Adafruit_NeoPixel::setPixelColor(_counter_mode_step - 1, 0);
|
||||
if (!_locked[end +1])
|
||||
Adafruit_NeoPixel::setPixelColor(end + 1, 0);
|
||||
}
|
||||
} else {
|
||||
if (_counter_mode_step < mid) {
|
||||
if (!_locked[mid - _counter_mode_step -1])
|
||||
Adafruit_NeoPixel::setPixelColor(mid - _counter_mode_step - 1, _color);
|
||||
if (!_locked[mid + _counter_mode_step])
|
||||
Adafruit_NeoPixel::setPixelColor(mid + _counter_mode_step, _color);
|
||||
} else {
|
||||
if (!_locked[_counter_mode_step])
|
||||
Adafruit_NeoPixel::setPixelColor(_counter_mode_step, 0);
|
||||
if (!_locked[end])
|
||||
Adafruit_NeoPixel::setPixelColor(end, 0);
|
||||
}
|
||||
}
|
||||
|
||||
_counter_mode_step++;
|
||||
if (odd) {
|
||||
if (_counter_mode_step > _led_count) {
|
||||
_counter_mode_step = 0;
|
||||
}
|
||||
} else {
|
||||
if (_counter_mode_step >= _led_count) {
|
||||
_counter_mode_step = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Adafruit_NeoPixel::show();
|
||||
|
||||
_mode_delay = 5 + ((50 * (uint32_t)(SPEED_MAX - _speed)) / _led_count);
|
||||
}
|
||||
|
||||
/*
|
||||
* Lights all LEDs after each other up starting from the middle and
|
||||
* finishing at the edges. Then turns them in reverse order off. Repeat.
|
||||
*/
|
||||
void WS2812FX::mode_dual_color_wipe_out_in(void) {
|
||||
bool odd = (_led_count % 2);
|
||||
int mid = _led_count / 2;
|
||||
|
||||
if (odd) {
|
||||
if (_counter_mode_step <= mid) {
|
||||
if (!_locked[mid + _counter_mode_step])
|
||||
Adafruit_NeoPixel::setPixelColor(mid + _counter_mode_step, _color);
|
||||
if (!_locked[mid - _counter_mode_step])
|
||||
Adafruit_NeoPixel::setPixelColor(mid - _counter_mode_step, _color);
|
||||
} else {
|
||||
int i = _counter_mode_step - mid;
|
||||
if (!_locked[i -1])
|
||||
Adafruit_NeoPixel::setPixelColor(i - 1, 0);
|
||||
if (!_locked[_led_count - i])
|
||||
Adafruit_NeoPixel::setPixelColor(_led_count - i, 0);
|
||||
}
|
||||
} else {
|
||||
if (_counter_mode_step < mid) {
|
||||
if (!_locked[mid - _counter_mode_step -1])
|
||||
Adafruit_NeoPixel::setPixelColor(mid - _counter_mode_step - 1, _color);
|
||||
if (!_locked[mid + _counter_mode_step])
|
||||
Adafruit_NeoPixel::setPixelColor(mid + _counter_mode_step, _color);
|
||||
} else {
|
||||
int i = _counter_mode_step - mid;
|
||||
if (!_locked[i])
|
||||
Adafruit_NeoPixel::setPixelColor(i, 0);
|
||||
if (!_locked[_led_count - i -1])
|
||||
Adafruit_NeoPixel::setPixelColor(_led_count - i - 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
_counter_mode_step++;
|
||||
if (odd) {
|
||||
if (_counter_mode_step > _led_count) {
|
||||
_counter_mode_step = 0;
|
||||
}
|
||||
} else {
|
||||
if (_counter_mode_step >= _led_count) {
|
||||
_counter_mode_step = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Adafruit_NeoPixel::show();
|
||||
|
||||
_mode_delay = 5 + ((50 * (uint32_t)(SPEED_MAX - _speed)) / _led_count);
|
||||
}
|
||||
|
||||
/*
|
||||
* Alternating white/red/black pixels running.
|
||||
*/
|
||||
void WS2812FX::mode_circus_combustus(void) {
|
||||
for(uint16_t i=0; i < _led_count; i++) {
|
||||
if((i + _counter_mode_step) % 6 < 2) {
|
||||
if (!_locked[i])
|
||||
Adafruit_NeoPixel::setPixelColor(i, 255, 0, 0);
|
||||
} else if((i + _counter_mode_step) % 6 < 4){
|
||||
if (!_locked[i])
|
||||
Adafruit_NeoPixel::setPixelColor(i, 255, 255, 255);
|
||||
} else {
|
||||
if (!_locked[i])
|
||||
Adafruit_NeoPixel::setPixelColor(i, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
Adafruit_NeoPixel::show();
|
||||
|
||||
_counter_mode_step = (_counter_mode_step + 1) % 6;
|
||||
_mode_delay = 100 + ((100 * (uint32_t)(SPEED_MAX - _speed)) / _led_count);
|
||||
}
|
||||
|
||||
void WS2812FX::setIndividual(int i)
|
||||
{
|
||||
if (i >= 0 && i < _led_count)
|
||||
|
|
|
@ -27,10 +27,7 @@
|
|||
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.
|
||||
CHANGELOG
|
||||
2016-05-28 Initial beta release
|
||||
2016-06-03 Code cleanup, minor improvements, new modes
|
||||
2016-06-04 2 new fx, fixed setColor (now also resets _mode_color)
|
||||
Modified to work with WLED - differs from Github WS2812FX
|
||||
*/
|
||||
|
||||
#ifndef WS2812FX_h
|
||||
|
@ -50,7 +47,7 @@
|
|||
#define BRIGHTNESS_MIN 0
|
||||
#define BRIGHTNESS_MAX 255
|
||||
|
||||
#define MODE_COUNT 48
|
||||
#define MODE_COUNT 53
|
||||
|
||||
#define FX_MODE_STATIC 0
|
||||
#define FX_MODE_BLINK 1
|
||||
|
@ -100,6 +97,11 @@
|
|||
#define FX_MODE_FIRE_FLICKER 45
|
||||
#define FX_MODE_FIRE_FLICKER_SOFT 46
|
||||
#define FX_MODE_FADE_DOWN 47
|
||||
#define FX_MODE_DUAL_COLOR_WIPE_IN_OUT 48
|
||||
#define FX_MODE_DUAL_COLOR_WIPE_IN_IN 49
|
||||
#define FX_MODE_DUAL_COLOR_WIPE_OUT_OUT 50
|
||||
#define FX_MODE_DUAL_COLOR_WIPE_OUT_IN 51
|
||||
#define FX_MODE_CIRCUS_COMBUSTUS 52
|
||||
|
||||
class WS2812FX : public Adafruit_NeoPixel {
|
||||
|
||||
|
@ -156,6 +158,11 @@ class WS2812FX : public Adafruit_NeoPixel {
|
|||
_mode[FX_MODE_FIRE_FLICKER] = &WS2812FX::mode_fire_flicker;
|
||||
_mode[FX_MODE_FIRE_FLICKER_SOFT] = &WS2812FX::mode_fire_flicker_soft;
|
||||
_mode[FX_MODE_FADE_DOWN] = &WS2812FX::mode_fade_down;
|
||||
_mode[FX_MODE_DUAL_COLOR_WIPE_IN_OUT] = &WS2812FX::mode_dual_color_wipe_in_out;
|
||||
_mode[FX_MODE_DUAL_COLOR_WIPE_IN_IN] = &WS2812FX::mode_dual_color_wipe_in_in;
|
||||
_mode[FX_MODE_DUAL_COLOR_WIPE_OUT_OUT] = &WS2812FX::mode_dual_color_wipe_out_out;
|
||||
_mode[FX_MODE_DUAL_COLOR_WIPE_OUT_IN] = &WS2812FX::mode_dual_color_wipe_out_in;
|
||||
_mode[FX_MODE_CIRCUS_COMBUSTUS] = &WS2812FX::mode_circus_combustus;
|
||||
|
||||
_name[FX_MODE_STATIC] = "Static";
|
||||
_name[FX_MODE_BLINK] = "Blink";
|
||||
|
@ -205,6 +212,11 @@ class WS2812FX : public Adafruit_NeoPixel {
|
|||
_name[FX_MODE_FIRE_FLICKER] = "Fire Flicker";
|
||||
_name[FX_MODE_FIRE_FLICKER_SOFT] = "Fire Flicker (soft)";
|
||||
_name[FX_MODE_FADE_DOWN] = "Fade (Internal)";
|
||||
_name[FX_MODE_DUAL_COLOR_WIPE_IN_OUT] = "Dual Color Wipe In to Out";
|
||||
_name[FX_MODE_DUAL_COLOR_WIPE_IN_IN] = "Dual Color Wipe In to In";
|
||||
_name[FX_MODE_DUAL_COLOR_WIPE_OUT_OUT] = "Dual Color Wipe Out to Out";
|
||||
_name[FX_MODE_DUAL_COLOR_WIPE_OUT_IN] = "Dual Color Wipe Out to In";
|
||||
_name[FX_MODE_CIRCUS_COMBUSTUS] = "Circus Combustus";
|
||||
|
||||
_mode_index = DEFAULT_MODE;
|
||||
_speed = DEFAULT_SPEED;
|
||||
|
@ -318,7 +330,12 @@ class WS2812FX : public Adafruit_NeoPixel {
|
|||
mode_fire_flicker(void),
|
||||
mode_fire_flicker_soft(void),
|
||||
mode_fire_flicker_int(int),
|
||||
mode_fade_down(void);
|
||||
mode_fade_down(void),
|
||||
mode_dual_color_wipe_in_out(void),
|
||||
mode_dual_color_wipe_in_in(void),
|
||||
mode_dual_color_wipe_out_out(void),
|
||||
mode_dual_color_wipe_out_in(void),
|
||||
mode_circus_combustus(void);
|
||||
|
||||
boolean
|
||||
_triggered,
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -20,7 +20,7 @@
|
|||
#include "CallbackFunction.h"
|
||||
|
||||
//version in format yymmddb (b = daily build)
|
||||
#define VERSION 1706270
|
||||
#define VERSION 1709181
|
||||
|
||||
//to toggle usb serial debug (un)comment following line
|
||||
//#define DEBUG
|
||||
|
|
Loading…
Add table
Reference in a new issue