From 265ae2f0ac80b9b0ed7178ba15008091a6492323 Mon Sep 17 00:00:00 2001 From: starcalc Date: Tue, 2 Jul 2019 18:34:45 +0200 Subject: [PATCH] NEXT - Effekt --- esp-pixelbox.ino | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/esp-pixelbox.ino b/esp-pixelbox.ino index b3aba9d..004c232 100644 --- a/esp-pixelbox.ino +++ b/esp-pixelbox.ino @@ -34,6 +34,7 @@ int x = matrix.width(); int pass = 0; bool stopAfterCompletion; +int effect = 0; void StripComplete() { if (stopAfterCompletion) @@ -251,6 +252,59 @@ void loopHandler() { matrix.Update(); } +bool onSetNext(const HomieRange& range, const String& value) { + switch (effect) + { + case 0: + matrix.None(); + strip.Scanner(strip.Color(255, 0, 0), 40, true, true); + break; + case 1: + matrix.None(); + strip.Scanner(strip.Color(255, 0, 0)); + break; + case 2: + matrix.None(); + strip.Scanner(strip.Color(255, 0, 0), 40, true); + break; + case 3: + matrix.None(); + strip.Scanner(strip.Color(255, 0, 0), 40, true, true); + break; + case 4: + matrix.None(); + strip.RainbowCycle(50); + break; + case 5: + matrix.None(); + strip.TheaterChase(strip.Color(255, 0, 0), strip.Color(0, 0, 255), 100); + break; + case 6: + matrix.None(); + strip.Fade(strip.Color(255, 0, 0), strip.Color(0, 0, 255), 200, 100); + break; + case 7: + matrix.None(); + strip.RandomFade(); + break; + case 8: + matrix.None(); + strip.Smooth(16, 80, 50, 40); + break; + case 9: + matrix.None(); + strip.Plasma(); + break; + case 10: + strip.None(); + matrix.ScrollText("CTDO"); + break; + } + effect++; + if (effect>10) { effect=0; } + homieNode.setProperty("next").send(value); +} + void setup() { Serial.begin(115200); @@ -264,6 +318,7 @@ void setup() { homieNode.advertise("clear").settable(onSetClear); homieNode.advertise("length").settable(onSetLength); homieNode.advertise("icon").settable(onSetIcon); + homieNode.advertise("next").settable(onSetNext); homieNode.advertiseRange("pixels", 0, (NUMPIXELS - 1) * 7).settable(onSetPixels); @@ -275,6 +330,7 @@ void setup() { strip.show(); stopAfterCompletion = false; // Default strip.Plasma(); // Default effect + effect = 0; Homie.setup();