diff --git a/src/main.cpp b/src/main.cpp index 76366d8..f9be8cf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -133,6 +133,10 @@ uint8_t laststate = SMODEINITIAL; static unsigned long tsPolling = 0; uint8_t retries = 0; +// Multicore +TaskHandle_t TaskNeopixel; + + /** * Helper @@ -471,6 +475,16 @@ void statemachine() { } +/** + * Multicore + */ +void neopixelTask(void * parameter) { + for (;;) { + ws2812fx.service(); + } +} + + /** * Main functions */ @@ -518,6 +532,17 @@ void setup() DBG_PRINTLN("SPIFFS Mount Failed"); return; } + + // Pin neopixel logic to core 0 + xTaskCreatePinnedToCore( + neopixelTask, + "Neopixels", + 1000, + NULL, + 1, + &TaskNeopixel, + 0); + } void loop() @@ -525,7 +550,5 @@ void loop() // iotWebConf - doLoop should be called as frequently as possible. iotWebConf.doLoop(); - ws2812fx.service(); - statemachine(); }