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:
|
case PLASMA:
|
||||||
PlasmaUpdate();
|
PlasmaUpdate();
|
||||||
break;
|
break;
|
||||||
|
case FILL:
|
||||||
|
break;
|
||||||
|
case RANDOM:
|
||||||
|
break;
|
||||||
case NONE:
|
case NONE:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
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) {
|
if (ActivePattern != NONE) {
|
||||||
clear();
|
clear();
|
||||||
show();
|
show();
|
||||||
|
@ -290,6 +297,7 @@ void NeoPatterns::RandomBuffer()
|
||||||
void NeoPatterns::Random()
|
void NeoPatterns::Random()
|
||||||
{
|
{
|
||||||
None(); // Stop all other effects
|
None(); // Stop all other effects
|
||||||
|
ActivePattern = RANDOM;
|
||||||
for (int i = 0; i < numPixels(); i++) {
|
for (int i = 0; i < numPixels(); i++) {
|
||||||
setPixelColor(i, Wheel(random(0, 256)));
|
setPixelColor(i, Wheel(random(0, 256)));
|
||||||
}
|
}
|
||||||
|
@ -413,6 +421,9 @@ void NeoPatterns::Icon(uint8_t fontchar, String iconcolor, uint8_t interval)
|
||||||
SavedIndex = Index;
|
SavedIndex = Index;
|
||||||
SavedColor1 = Color1;
|
SavedColor1 = Color1;
|
||||||
SavedDirection = Direction;
|
SavedDirection = Direction;
|
||||||
|
SavedPlasmaPhase = PlasmaPhase;
|
||||||
|
SavedPlasmaPhaseIncrement = PlasmaPhaseIncrement;
|
||||||
|
SavedPlasmaColorStretch = PlasmaColorStretch;
|
||||||
ActivePattern = ICON;
|
ActivePattern = ICON;
|
||||||
Interval = interval;
|
Interval = interval;
|
||||||
TotalSteps = 80;
|
TotalSteps = 80;
|
||||||
|
@ -450,6 +461,9 @@ void NeoPatterns::IconComplete()
|
||||||
Index = SavedIndex;
|
Index = SavedIndex;
|
||||||
Color1 = SavedColor1;
|
Color1 = SavedColor1;
|
||||||
Direction = SavedDirection;
|
Direction = SavedDirection;
|
||||||
|
PlasmaPhase = SavedPlasmaPhase;
|
||||||
|
PlasmaPhaseIncrement = SavedPlasmaPhaseIncrement;
|
||||||
|
PlasmaColorStretch = SavedPlasmaColorStretch;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Based upon https://github.com/johncarl81/neopixelplasma
|
// Based upon https://github.com/johncarl81/neopixelplasma
|
||||||
|
@ -516,6 +530,7 @@ void NeoPatterns::PlasmaUpdate()
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************** Helper functions ******************/
|
/****************** Helper functions ******************/
|
||||||
|
|
||||||
void NeoPatterns::SetColor1(uint32_t color) {
|
void NeoPatterns::SetColor1(uint32_t color) {
|
||||||
|
@ -546,6 +561,7 @@ void NeoPatterns::ColorSet(uint32_t color)
|
||||||
void NeoPatterns::ColorSetParameters(String parameters)
|
void NeoPatterns::ColorSetParameters(String parameters)
|
||||||
{
|
{
|
||||||
None();
|
None();
|
||||||
|
ActivePattern = FILL;
|
||||||
ColorSet(parseColor(parameters));
|
ColorSet(parseColor(parameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
|
|
||||||
// Pattern types supported:
|
// 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:
|
// Patern directions supported:
|
||||||
enum direction { FORWARD, REVERSE };
|
enum direction { FORWARD, REVERSE };
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ class NeoPatterns : public Adafruit_NeoPixel
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
void Reverse();
|
void Reverse();
|
||||||
void None();
|
void None(uint8_t interval = 40);
|
||||||
void RainbowCycle(uint8_t interval, direction dir = FORWARD);
|
void RainbowCycle(uint8_t interval, direction dir = FORWARD);
|
||||||
void RainbowCycleUpdate();
|
void RainbowCycleUpdate();
|
||||||
void TheaterChase(uint32_t color1, uint32_t color2, uint8_t interval, direction dir = FORWARD);
|
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;
|
uint8_t FontChar;
|
||||||
|
|
||||||
float PlasmaPhase;
|
float PlasmaPhase;
|
||||||
|
float SavedPlasmaPhase;
|
||||||
float PlasmaPhaseIncrement;
|
float PlasmaPhaseIncrement;
|
||||||
|
float SavedPlasmaPhaseIncrement;
|
||||||
float PlasmaColorStretch;
|
float PlasmaColorStretch;
|
||||||
|
float SavedPlasmaColorStretch;
|
||||||
|
|
||||||
|
|
||||||
uint32_t DimColor(uint32_t color);
|
uint32_t DimColor(uint32_t color);
|
||||||
void Increment();
|
void Increment();
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <avr/power.h>
|
#include <avr/power.h>
|
||||||
#endif
|
#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
|
#define NUMPIXELS 64
|
||||||
|
|
||||||
NeoPatterns strip = NeoPatterns(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800, &StripComplete);
|
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") {
|
else if (effect == "plasma") {
|
||||||
strip.Plasma();
|
strip.Plasma();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// Test whether command with parameters was sent
|
// Test whether command with parameters was sent
|
||||||
int sep = value.indexOf("|");
|
int sep = value.indexOf("|");
|
||||||
String command = value.substring(0, sep);
|
String command = value.substring(0, sep);
|
||||||
|
|
Loading…
Reference in New Issue