Skip to content

Instantly share code, notes, and snippets.

@Ruffo324
Created August 5, 2020 20:59
Show Gist options
  • Save Ruffo324/d46fe6281f121992634d296b62f70af7 to your computer and use it in GitHub Desktop.
Save Ruffo324/d46fe6281f121992634d296b62f70af7 to your computer and use it in GitHub Desktop.
Do stuff for multiple pixelBus stripes.
#include <Arduino.h>
#include <NeoPixelBus.h>
#include <NeoPixelAnimator.h>
const int amountLeds = 20;
// ggf. hier den generischen teil(<..,..>) von NeoPixelBus an deine stripes anpassen.
typedef NeoPixelBus<NeoRbgFeature, NeoEsp32BitBang800KbpsMethod> stripeDef;
stripeDef stripe1(amountLeds, 21);
stripeDef stripe2(amountLeds, 23);
typedef std::function<void(stripeDef *)> stripeFunctionType;
void forAllStripes(stripeFunctionType stripeFunction)
{
stripeFunction(&stripe1); // Hier stripe 1 eintragen
stripeFunction(&stripe2); // hier stripe 2 eintragen.
}
///////////////////////////////////////////
// Der Teil hierdrunter ist nur beispüiel.,.
///////////////////////////////////////////
void setup()
{
forAllStripes([](stripeDef *stripe) {
(*stripe).Begin();
(*stripe).Show();
});
}
int colorVal = 0;
bool flip = false;
void loop()
{
delay(10); // Just for visibility.
RgbColor color(colorVal, colorVal, colorVal);
forAllStripes([color](stripeDef *stripe) {
for (int i = 0; i < amountLeds; i++)
(*stripe).SetPixelColor(i, color);
(*stripe).Show();
});
if (colorVal >= 128)
flip = true;
else if (colorVal <= 1)
flip = false;
if (flip)
colorVal--;
else
colorVal++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment