diff --git a/src/IlluCat.h b/src/IlluCat.h index daa9c7d..39be7f8 100644 --- a/src/IlluCat.h +++ b/src/IlluCat.h @@ -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); - } } }; diff --git a/src/PixelPlugin.cpp b/src/PixelPlugin.cpp index f9dab05..d6ad2f0 100644 --- a/src/PixelPlugin.cpp +++ b/src/PixelPlugin.cpp @@ -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"); }