fix completion, add moar events

This commit is contained in:
2018-09-30 14:30:21 +02:00
parent 5fca37bbc3
commit 4cf0f0cc4d
8 changed files with 132 additions and 18 deletions

View File

@@ -34,13 +34,18 @@ class PixelPlugin : public Plugin {
subscribe("pixels/totalSteps", bind(&PixelPlugin::setTotalSteps, this, _1));
subscribe("pixels/brightness", bind(&PixelPlugin::setBrightness, this, _1));
subscribe("pixels/state", bind(&PixelPlugin::setState, this, _1));
subscribe("pixels/stream", bind(&PixelPlugin::stream, this, _1));
animation.set(TASK_MILLISECOND * pixelConfig.updateInterval, TASK_FOREVER, bind(&PixelPlugin::animate, this));
userScheduler->addTask(animation);
animation.enable();
PRINT_MSG(Serial, SPROCKET_TYPE, "NeoPixels activated");
}
void stream(String msg){
// TODO handle LED byte array stream
}
void setState(String msg) {
PRINT_MSG(Serial, SPROCKET_TYPE, msg.c_str());
state.fromJsonString(msg);
pixels->setBrightness(state.brightness);
pixels->ColorSet(state.color);
@@ -49,6 +54,7 @@ class PixelPlugin : public Plugin {
pixels->Color2 = state.color2;
pixels->TotalSteps = state.totalSteps;
pixels->ActivePattern = (pattern) state.pattern;
pixels->Direction = FORWARD;
}
void colorWheel(String msg){
int color = atoi(msg.c_str());