Add length Property, fix bug with effect and setPixel
This commit is contained in:
parent
13abfe7afd
commit
6667365739
|
@ -5,7 +5,7 @@
|
|||
#include <Adafruit_NeoPixel.h>
|
||||
|
||||
#define PIN D1
|
||||
#define NUMPIXELS 30
|
||||
#define NUMPIXELS 144
|
||||
|
||||
uint16_t i=0,j=0,wait = 50;
|
||||
unsigned long lastCall = 0;
|
||||
|
@ -41,10 +41,10 @@ bool onSetPixel(const HomieRange& range, const String& value){
|
|||
stripNode.setProperty("pixel").send(value);
|
||||
return true;
|
||||
}
|
||||
if (range.index < 0 || range.index > NUMPIXELS-1) {
|
||||
if (range.index < 0 || range.index > pixels.numPixels()-1) {
|
||||
return false;
|
||||
}
|
||||
effect == "none";
|
||||
effect = "none";
|
||||
pixels.setPixelColor(range.index, value.toInt());
|
||||
pixels.show();
|
||||
stripNode.setProperty("pixel_" + String(range.index)).send(value);
|
||||
|
@ -74,6 +74,17 @@ bool onSetClear(const HomieRange& range, const String& value){
|
|||
stripNode.setProperty("clear").send(value);
|
||||
}
|
||||
|
||||
bool onSetLength(const HomieRange& range, const String& value){
|
||||
effect = "none";
|
||||
pixels.clear();
|
||||
pixels.show();
|
||||
int newLength = value.toInt();
|
||||
if(newLength > 0){
|
||||
pixels.updateLength(newLength);
|
||||
}
|
||||
stripNode.setProperty("length").send(value);
|
||||
}
|
||||
|
||||
|
||||
void loopHandler() {
|
||||
if (effect == "none"){
|
||||
|
@ -170,6 +181,7 @@ void setup() {
|
|||
stripNode.advertise("brightness").settable(onSetBrightness);
|
||||
stripNode.advertise("effect").settable(onSetEffect);
|
||||
stripNode.advertise("clear").settable(onSetClear);
|
||||
stripNode.advertise("length").settable(onSetLength);
|
||||
|
||||
pixels.begin();
|
||||
pixels.clear();
|
||||
|
|
Loading…
Reference in New Issue