reorder fnc calls

This commit is contained in:
2018-11-05 15:34:14 +01:00
parent 299f7dae65
commit a940903bd3
2 changed files with 5 additions and 15 deletions

View File

@@ -30,13 +30,12 @@ class IlluCat : public Sprocket {
OtaConfig otaConfig;
WebServerConfig webConfig;
SprocketMessage currentMessage;
IlluCat(SprocketConfig cfg, OtaConfig otaCfg, WebServerConfig webCfg) : Sprocket(cfg) {
sprocketConfig = cfg;
otaConfig = otaCfg;
webConfig = webCfg;
server = new AsyncWebServer(80);
server->serveStatic(PIXEL_CONFIG_FILE, SPIFFS, "pixelConfig.json");
}
void setup(){
@@ -44,16 +43,6 @@ class IlluCat : public Sprocket {
addPlugin(new WebServerPlugin(webConfig, server));
addPlugin(new WebConfigPlugin(server));
addPlugin(new WebApi(server, 1));
server->serveStatic(PIXEL_CONFIG_FILE, SPIFFS, "pixelConfig.json");
}
// TODO move to Sprocket
virtual void dispatch( uint32_t from, String &msg ) {
currentMessage.fromJsonString(msg);
if(currentMessage.valid){
currentMessage.from = from;
publish(currentMessage.topic, currentMessage.payload);
}
}
};

View File

@@ -42,6 +42,10 @@ void PixelPlugin::defaultAnimation() {
void PixelPlugin::activate(Scheduler *userScheduler, Network *network)
{
animation.set(TASK_MILLISECOND * pixelConfig.updateInterval, TASK_FOREVER, bind(&PixelPlugin::animate, this));
userScheduler->addTask(animation);
animation.enable();
subscribe("pixels/colorWheel", bind(&PixelPlugin::colorWheel, this, _1));
subscribe("pixels/color", bind(&PixelPlugin::setColor, this, _1));
subscribe("pixels/color2", bind(&PixelPlugin::setColor2, this, _1));
@@ -50,9 +54,6 @@ void PixelPlugin::activate(Scheduler *userScheduler, Network *network)
subscribe("pixels/brightness", bind(&PixelPlugin::setBrightness, this, _1));
subscribe("pixels/state", bind(&PixelPlugin::setState, 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");
}