|
@ -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(); |
|
|