Browse Source

FastLED still not fixed -> Update only if not steady color

main
Hendrik Langer 7 years ago
parent
commit
b5c507d070
  1. 7
      software/src/led.cpp
  2. 1
      software/src/led.h

7
software/src/led.cpp

@ -10,6 +10,7 @@ using namespace std;
Led::Led(void) { Led::Led(void) {
index = 0; index = 0;
duration = 0; duration = 0;
change = true;
} }
void Led::loop_rainbow(void) { void Led::loop_rainbow(void) {
@ -44,6 +45,7 @@ void Led::loop_steady(void) {
} }
void Led::changeAnimation(uint8_t num, uint16_t duration) { void Led::changeAnimation(uint8_t num, uint16_t duration) {
change = true;
if (duration == 0) this->duration = UINT16_MAX; if (duration == 0) this->duration = UINT16_MAX;
else this->duration = duration; else this->duration = duration;
if (num == 0) refresh = &Led::loop_steady; if (num == 0) refresh = &Led::loop_steady;
@ -64,7 +66,7 @@ void Led::setup(void) {
xTaskCreate( xTaskCreate(
&cTaskWrapper, /* Task function. */ &cTaskWrapper, /* Task function. */
"ledAnimationTask", /* String with name of task. */ "ledAnimationTask", /* String with name of task. */
2048, /* Stack size in words. */ 4096, /* Stack size in words. */
this, /* Parameter passed as input of the task */ this, /* Parameter passed as input of the task */
1, /* Priority of the task. */ 1, /* Priority of the task. */
&ledTaskHandle); /* Task handle. */ &ledTaskHandle); /* Task handle. */
@ -75,7 +77,8 @@ void Led::animationTask(void* parameters) {
if (refresh != nullptr) { if (refresh != nullptr) {
(*this.*refresh)(); (*this.*refresh)();
try { try {
FastLED.show(); if (refresh != (&Led::loop_steady) || change == true) FastLED.show();
change = false;
} catch(...) { } catch(...) {
Serial.println("FastLED error"); Serial.println("FastLED error");
this->setup(); this->setup();

1
software/src/led.h

@ -25,6 +25,7 @@ class Led {
void loop_dispense(void); void loop_dispense(void);
uint16_t duration; uint16_t duration;
uint8_t index; uint8_t index;
bool change;
}; };
#endif /* _LED_H */ #endif /* _LED_H */

Loading…
Cancel
Save