From b5c507d07047a13a95f89ea89be0ead187a389a2 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Sun, 7 Jan 2018 16:15:56 +0100 Subject: [PATCH] FastLED still not fixed -> Update only if not steady color --- software/src/led.cpp | 7 +++++-- software/src/led.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/software/src/led.cpp b/software/src/led.cpp index 86f1672..386be35 100644 --- a/software/src/led.cpp +++ b/software/src/led.cpp @@ -10,6 +10,7 @@ using namespace std; Led::Led(void) { index = 0; duration = 0; + change = true; } void Led::loop_rainbow(void) { @@ -44,6 +45,7 @@ void Led::loop_steady(void) { } void Led::changeAnimation(uint8_t num, uint16_t duration) { + change = true; if (duration == 0) this->duration = UINT16_MAX; else this->duration = duration; if (num == 0) refresh = &Led::loop_steady; @@ -64,7 +66,7 @@ void Led::setup(void) { xTaskCreate( &cTaskWrapper, /* Task function. */ "ledAnimationTask", /* String with name of task. */ - 2048, /* Stack size in words. */ + 4096, /* Stack size in words. */ this, /* Parameter passed as input of the task */ 1, /* Priority of the task. */ &ledTaskHandle); /* Task handle. */ @@ -75,7 +77,8 @@ void Led::animationTask(void* parameters) { if (refresh != nullptr) { (*this.*refresh)(); try { - FastLED.show(); + if (refresh != (&Led::loop_steady) || change == true) FastLED.show(); + change = false; } catch(...) { Serial.println("FastLED error"); this->setup(); diff --git a/software/src/led.h b/software/src/led.h index 56290b5..3089103 100644 --- a/software/src/led.h +++ b/software/src/led.h @@ -25,6 +25,7 @@ class Led { void loop_dispense(void); uint16_t duration; uint8_t index; + bool change; }; #endif /* _LED_H */