moar topics

This commit is contained in:
2018-09-17 15:34:24 +02:00
parent 939f167dad
commit ad8ba61986
7 changed files with 91 additions and 12 deletions

View File

@@ -26,11 +26,38 @@ class PixelPlugin : public Plugin {
pixels->setBrightness(pixelConfig.brightness);
}
void activate(Scheduler* userScheduler, Network* network){
subscribe("pixels/color", bind(&PixelPlugin::setColor, this, _1));
subscribe("pixels/color2", bind(&PixelPlugin::setColor2, this, _1));
subscribe("pixels/pattern", bind(&PixelPlugin::setPattern, this, _1));
subscribe("pixels/totalSteps", bind(&PixelPlugin::setTotalSteps, this, _1));
subscribe("pixels/brightness", bind(&PixelPlugin::setBrightness, this, _1));
animation.set(TASK_MILLISECOND * pixelConfig.updateInterval, TASK_FOREVER, bind(&PixelPlugin::animate, this));
userScheduler->addTask(animation);
animation.enable();
Serial.println("NeoPixels activated");
}
void setTotalSteps(String msg){
pixels->TotalSteps = atoi(msg.c_str());
}
void setBrightness(String msg){
int inVal = atoi(msg.c_str());
pixels->setBrightness(inVal);
pixels->show();
}
void setColor(String msg){
pixels->Color1 = atoi(msg.c_str());
if(pixels->ActivePattern == NONE){
pixels->ColorSet(pixels->Color1);
}
}
void setColor2(String msg){
pixels->Color2 = atoi(msg.c_str());
}
void setPattern(String msg){
pixels->Index = 0;
pixels->ActivePattern = (pattern)atoi(msg.c_str());
}
void animate(){
pixels->Update();
}