From 02679f4e804a40e4762dd9ed7f1213ac0ed199f7 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Sun, 7 Jan 2018 16:04:09 +0100 Subject: [PATCH] fix FastLED crashing due to stack size being to small --- software/platformio.ini | 9 +++++---- software/src/led.cpp | 12 +++++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/software/platformio.ini b/software/platformio.ini index ebc3f77..0f82361 100644 --- a/software/platformio.ini +++ b/software/platformio.ini @@ -9,19 +9,20 @@ ; http://docs.platformio.org/page/projectconf.html [env:esp32dev] -;platform = https://github.com/platformio/platform-espressif32.git#feature/stage -platform = espressif32 +platform = https://github.com/platformio/platform-espressif32.git#feature/stage +;platform = espressif32 board = esp32dev framework = arduino ;build_flags = -DASYNC_TCP_SSL_ENABLED=1 +build_flags = -fexceptions lib_deps = https://github.com/me-no-dev/ESPAsyncWebServer.git https://github.com/me-no-dev/AsyncTCP.git ; ESP Async WebServer ; AsyncTCP FS - FastLED -; https://github.com/samguyer/FastLED.git +; FastLED + https://github.com/samguyer/FastLED.git ; AsyncMqttClient https://github.com/marvinroger/async-mqtt-client.git lib_ignore = ESPAsyncTCP diff --git a/software/src/led.cpp b/software/src/led.cpp index 57d3453..86f1672 100644 --- a/software/src/led.cpp +++ b/software/src/led.cpp @@ -53,9 +53,10 @@ void Led::changeAnimation(uint8_t num, uint16_t duration) { } void Led::setup(void) { + pinMode(LED_PIN, OUTPUT); FastLED.addLeds(leds, NUM_LEDS); FastLED.setBrightness(96); - FastLED.setCorrection(TypicalLEDStrip); + FastLED.setCorrection(0xFF60C0); fill_solid(leds, NUM_LEDS, CRGB::White); FastLED.show(); @@ -63,7 +64,7 @@ void Led::setup(void) { xTaskCreate( &cTaskWrapper, /* Task function. */ "ledAnimationTask", /* String with name of task. */ - 1024, /* Stack size in words. */ + 2048, /* Stack size in words. */ this, /* Parameter passed as input of the task */ 1, /* Priority of the task. */ &ledTaskHandle); /* Task handle. */ @@ -73,7 +74,12 @@ void Led::animationTask(void* parameters) { while(true) { if (refresh != nullptr) { (*this.*refresh)(); - FastLED.show(); + try { + FastLED.show(); + } catch(...) { + Serial.println("FastLED error"); + this->setup(); + } // EVERY_N_MILLISECONDS ( 20) { index++; } index++; if (duration == 0) {