Alle Pixel koennen ueber einen Befehl mit einer Farbe gezielt versehen
This commit is contained in:
parent
135486035f
commit
79e6189857
|
@ -104,6 +104,11 @@ void NeoPatterns::Reverse() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NeoPatterns::Stop(uint8_t interval) {
|
||||||
|
Interval = interval;
|
||||||
|
ActivePattern = NONE;
|
||||||
|
}
|
||||||
|
|
||||||
void NeoPatterns::None(uint8_t interval) {
|
void NeoPatterns::None(uint8_t interval) {
|
||||||
Interval = interval;
|
Interval = interval;
|
||||||
if (ActivePattern != NONE) {
|
if (ActivePattern != NONE) {
|
||||||
|
@ -183,7 +188,6 @@ void NeoPatterns::Scanner(uint32_t color1, uint8_t interval, bool colorful, bool
|
||||||
Interval = interval;
|
Interval = interval;
|
||||||
TotalSteps = (numPixels() - 1) * 2;
|
TotalSteps = (numPixels() - 1) * 2;
|
||||||
Color1 = color1;
|
Color1 = color1;
|
||||||
Color2 = color1;
|
|
||||||
Index = 0;
|
Index = 0;
|
||||||
wPos = 0;
|
wPos = 0;
|
||||||
this->colorful = colorful;
|
this->colorful = colorful;
|
||||||
|
|
|
@ -12,9 +12,9 @@ class NeoPatterns : public Adafruit_NeoPixel
|
||||||
NeoPatterns(uint16_t pixels, uint8_t pin, uint8_t type, void (*callback)());
|
NeoPatterns(uint16_t pixels, uint8_t pin, uint8_t type, void (*callback)());
|
||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
void Reverse();
|
void Reverse();
|
||||||
void None(uint8_t interval = 40);
|
void None(uint8_t interval = 40);
|
||||||
|
void Stop(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);
|
||||||
|
|
|
@ -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 D2 //data pin for ws2812 (pixelprojektor @ ctdo: PIN 2) // Für pixelpad: Pin2
|
||||||
#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);
|
||||||
|
@ -65,6 +65,34 @@ bool onSetBrightness(const HomieRange& range, const String& value) {
|
||||||
homieNode.setProperty("brightness").send(value);
|
homieNode.setProperty("brightness").send(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool onSetPixels(const HomieRange& range, const String& value) {
|
||||||
|
|
||||||
|
String remaining = value;
|
||||||
|
int i = 0;
|
||||||
|
// Kein Effekt
|
||||||
|
strip.Stop();
|
||||||
|
do {
|
||||||
|
String current = remaining.substring(0, 7);
|
||||||
|
Homie.getLogger() << i << ":" << current << endl;
|
||||||
|
uint32_t currentcolor = strip.parseColor(current);
|
||||||
|
|
||||||
|
strip.setPixelColor(strip.numToPos(i), currentcolor);
|
||||||
|
i++;
|
||||||
|
|
||||||
|
remaining = remaining.substring(7);
|
||||||
|
|
||||||
|
} while (remaining.length() > 2 && (i < strip.numPixels()));
|
||||||
|
Homie.getLogger() << " filling rest with black" << endl;
|
||||||
|
while (i < strip.numPixels()) {
|
||||||
|
strip.setPixelColor(strip.numToPos(i), strip.Color(0, 0, 0));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
strip.show();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool onSetEffect(const HomieRange& range, const String& value) {
|
bool onSetEffect(const HomieRange& range, const String& value) {
|
||||||
stopAfterCompletion = false;
|
stopAfterCompletion = false;
|
||||||
String effect = value;
|
String effect = value;
|
||||||
|
@ -116,11 +144,10 @@ bool onSetEffect(const HomieRange& range, const String& value) {
|
||||||
strip.RandomFadeSingle(p1);
|
strip.RandomFadeSingle(p1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
effect = "none";
|
|
||||||
strip.None();
|
strip.None();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
homieNode.setProperty("effect").send(effect);
|
homieNode.setProperty("effect").send(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool onSetIcon(const HomieRange& range, const String& value) {
|
bool onSetIcon(const HomieRange& range, const String& value) {
|
||||||
|
@ -170,15 +197,18 @@ void setup() {
|
||||||
homieNode.advertise("clear").settable(onSetClear);
|
homieNode.advertise("clear").settable(onSetClear);
|
||||||
homieNode.advertise("length").settable(onSetLength);
|
homieNode.advertise("length").settable(onSetLength);
|
||||||
homieNode.advertise("icon").settable(onSetIcon);
|
homieNode.advertise("icon").settable(onSetIcon);
|
||||||
|
homieNode.advertiseRange("pixels", 0, (NUMPIXELS - 1)*7).settable(onSetPixels);
|
||||||
|
|
||||||
Homie.setup();
|
Homie.setup();
|
||||||
|
|
||||||
strip.begin();
|
strip.begin();
|
||||||
strip.clear();
|
strip.clear();
|
||||||
// strip.setBrightness(64);
|
// strip.setBrightness(64);
|
||||||
strip.setBrightness(255); // HEEELLLLLLL :)
|
// strip.setBrightness(255); // HEEELLLLLLL :)
|
||||||
|
strip.setBrightness(10); // DEBUG!
|
||||||
strip.show();
|
strip.show();
|
||||||
stopAfterCompletion = false; // Default
|
stopAfterCompletion = false; // Default
|
||||||
|
// strip.Plasma(); // Default effect
|
||||||
|
|
||||||
ArduinoOTA.setHostname("pixelprojektor");
|
ArduinoOTA.setHostname("pixelprojektor");
|
||||||
ArduinoOTA.onStart([]() {
|
ArduinoOTA.onStart([]() {
|
||||||
|
|
Loading…
Reference in New Issue