Effekt RANDOM, Effekt FILL sauber hinzugefügt, werden auch korrekt abgeschaltet. Energieverbrauch gesenkt.
This commit is contained in:
parent
519e2d6a6d
commit
9fb6b1c089
|
@ -49,11 +49,17 @@ void NeoPatterns::Update() {
|
|||
case PLASMA:
|
||||
PlasmaUpdate();
|
||||
break;
|
||||
case FILL:
|
||||
break;
|
||||
case RANDOM:
|
||||
break;
|
||||
case NONE:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,7 +104,8 @@ void NeoPatterns::Reverse() {
|
|||
}
|
||||
}
|
||||
|
||||
void NeoPatterns::None() {
|
||||
void NeoPatterns::None(uint8_t interval) {
|
||||
Interval = interval;
|
||||
if (ActivePattern != NONE) {
|
||||
clear();
|
||||
show();
|
||||
|
@ -290,6 +297,7 @@ void NeoPatterns::RandomBuffer()
|
|||
void NeoPatterns::Random()
|
||||
{
|
||||
None(); // Stop all other effects
|
||||
ActivePattern = RANDOM;
|
||||
for (int i = 0; i < numPixels(); i++) {
|
||||
setPixelColor(i, Wheel(random(0, 256)));
|
||||
}
|
||||
|
@ -413,6 +421,9 @@ void NeoPatterns::Icon(uint8_t fontchar, String iconcolor, uint8_t interval)
|
|||
SavedIndex = Index;
|
||||
SavedColor1 = Color1;
|
||||
SavedDirection = Direction;
|
||||
SavedPlasmaPhase = PlasmaPhase;
|
||||
SavedPlasmaPhaseIncrement = PlasmaPhaseIncrement;
|
||||
SavedPlasmaColorStretch = PlasmaColorStretch;
|
||||
ActivePattern = ICON;
|
||||
Interval = interval;
|
||||
TotalSteps = 80;
|
||||
|
@ -450,6 +461,9 @@ void NeoPatterns::IconComplete()
|
|||
Index = SavedIndex;
|
||||
Color1 = SavedColor1;
|
||||
Direction = SavedDirection;
|
||||
PlasmaPhase = SavedPlasmaPhase;
|
||||
PlasmaPhaseIncrement = SavedPlasmaPhaseIncrement;
|
||||
PlasmaColorStretch = SavedPlasmaColorStretch;
|
||||
}
|
||||
|
||||
// Based upon https://github.com/johncarl81/neopixelplasma
|
||||
|
@ -516,6 +530,7 @@ void NeoPatterns::PlasmaUpdate()
|
|||
show();
|
||||
}
|
||||
|
||||
|
||||
/****************** Helper functions ******************/
|
||||
|
||||
void NeoPatterns::SetColor1(uint32_t color) {
|
||||
|
@ -546,6 +561,7 @@ void NeoPatterns::ColorSet(uint32_t color)
|
|||
void NeoPatterns::ColorSetParameters(String parameters)
|
||||
{
|
||||
None();
|
||||
ActivePattern = FILL;
|
||||
ColorSet(parseColor(parameters));
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "font.h"
|
||||
|
||||
// Pattern types supported:
|
||||
enum pattern { NONE, RAINBOW_CYCLE, THEATER_CHASE, COLOR_WIPE, SCANNER, FADE, RANDOM_FADE, SMOOTH, ICON, RANDOM_FADE_SINGLE, PLASMA };
|
||||
enum pattern { NONE, RAINBOW_CYCLE, THEATER_CHASE, COLOR_WIPE, SCANNER, FADE, RANDOM_FADE, SMOOTH, ICON, RANDOM_FADE_SINGLE, PLASMA, FILL, RANDOM };
|
||||
// Patern directions supported:
|
||||
enum direction { FORWARD, REVERSE };
|
||||
|
||||
|
@ -14,7 +14,7 @@ class NeoPatterns : public Adafruit_NeoPixel
|
|||
void Update();
|
||||
|
||||
void Reverse();
|
||||
void None();
|
||||
void None(uint8_t interval = 40);
|
||||
void RainbowCycle(uint8_t interval, direction dir = FORWARD);
|
||||
void RainbowCycleUpdate();
|
||||
void TheaterChase(uint32_t color1, uint32_t color2, uint8_t interval, direction dir = FORWARD);
|
||||
|
@ -92,8 +92,12 @@ class NeoPatterns : public Adafruit_NeoPixel
|
|||
uint8_t FontChar;
|
||||
|
||||
float PlasmaPhase;
|
||||
float SavedPlasmaPhase;
|
||||
float PlasmaPhaseIncrement;
|
||||
float SavedPlasmaPhaseIncrement;
|
||||
float PlasmaColorStretch;
|
||||
float SavedPlasmaColorStretch;
|
||||
|
||||
|
||||
uint32_t DimColor(uint32_t color);
|
||||
void Increment();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <avr/power.h>
|
||||
#endif
|
||||
|
||||
#define PIN 2 //data pin for ws2812 (pixelprojektor @ ctdo: PIN 2)
|
||||
#define PIN D1 //data pin for ws2812 (pixelprojektor @ ctdo: PIN 2)
|
||||
#define NUMPIXELS 64
|
||||
|
||||
NeoPatterns strip = NeoPatterns(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800, &StripComplete);
|
||||
|
@ -98,7 +98,8 @@ bool onSetEffect(const HomieRange& range, const String& value) {
|
|||
}
|
||||
else if (effect == "plasma") {
|
||||
strip.Plasma();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Test whether command with parameters was sent
|
||||
int sep = value.indexOf("|");
|
||||
String command = value.substring(0, sep);
|
||||
|
|
Loading…
Reference in New Issue