fablab-luenen / McLighting

The ESP8266 based multi-client lighting gadget
MIT License
215 stars 30 forks source link

Need help creating custom effects #119

Open mschnati opened 3 years ago

mschnati commented 3 years ago

Hey, I am not quite sure how to create customs effects since the code is a bit different compared to the standard WS2812FX library and the regular McLighting, where there is examples of how to do it.

Could someone explain to me how to implement this effect that i made for example:

include "FastLED.h"

define NUM_LEDS 480

CRGB leds[NUM_LEDS];

define PIN 7

void setup() { FastLED.addLeds<WS2812B, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); FastLED.setBrightness(50); }

void loop() { BounceFill(); }

void BounceFill() { for (int k = 16; k > 0; k--)//backwards { for (int i = 0; i < k; i++) //pixel { for (int j = 0; j < NUM_LEDS / 16; j++) //edges { setPixel(i + j 16, 0, 255, 0); if (i > 0) { setPixel(i - 1 + j 16, 0, 0, 0); } } FastLED.show(); delay(50); } } setAll(0,0,0); }

void setPixel(int Pixel, byte red, byte green, byte blue) { leds[Pixel].r = red; leds[Pixel].g = green; leds[Pixel].b = blue; }

void setAll(byte red, byte green, byte blue) { for (int i = 0; i < NUM_LEDS; i++ ) { setPixel(i, red, green, blue); } FastLED.show(); }