Browse Source

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

main
Hendrik Langer 6 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) {
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();

1
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 */

Loading…
Cancel
Save