|
@ -52,7 +52,6 @@ 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 +63,6 @@ void Led::changeAnimation(uint8_t num, uint16_t duration) { |
|
|
|
|
|
|
|
|
void Led::changeColor(uint8_t r, uint8_t g, uint8_t b) { |
|
|
void Led::changeColor(uint8_t r, uint8_t g, uint8_t b) { |
|
|
color = CRGB(r, g, b); |
|
|
color = CRGB(r, g, b); |
|
|
change = true; |
|
|
|
|
|
} |
|
|
} |
|
|
void Led::changeBrightness(uint8_t brightness) { |
|
|
void Led::changeBrightness(uint8_t brightness) { |
|
|
if (brightness > 254) { // don't set first byte to 255 on tm1829
|
|
|
if (brightness > 254) { // don't set first byte to 255 on tm1829
|
|
@ -72,7 +70,6 @@ void Led::changeBrightness(uint8_t brightness) { |
|
|
} else { |
|
|
} else { |
|
|
FastLED.setBrightness(brightness); |
|
|
FastLED.setBrightness(brightness); |
|
|
} |
|
|
} |
|
|
change = true; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void Led::setup(void) { |
|
|
void Led::setup(void) { |
|
@ -82,9 +79,8 @@ void Led::setup(void) { |
|
|
FastLED.setCorrection(0xFF5050); |
|
|
FastLED.setCorrection(0xFF5050); |
|
|
fill_solid(leds, NUM_LEDS, CRGB::White); |
|
|
fill_solid(leds, NUM_LEDS, CRGB::White); |
|
|
color = CRGB::Orange; |
|
|
color = CRGB::Orange; |
|
|
change = true; |
|
|
|
|
|
|
|
|
|
|
|
refresh = &Led::loop_steady; |
|
|
refresh = &Led::loop_rainbow; |
|
|
delay(100); |
|
|
delay(100); |
|
|
xTaskCreate( |
|
|
xTaskCreate( |
|
|
&cTaskWrapper, /* Task function. */ |
|
|
&cTaskWrapper, /* Task function. */ |
|
@ -99,21 +95,19 @@ void Led::animationTask(void* parameters) { |
|
|
while(true) { |
|
|
while(true) { |
|
|
if (refresh != nullptr) { |
|
|
if (refresh != nullptr) { |
|
|
(*this.*refresh)(); |
|
|
(*this.*refresh)(); |
|
|
if (refresh != (&Led::loop_steady) || change == true) FastLED.show(); |
|
|
FastLED.show(); |
|
|
change = false; |
|
|
|
|
|
// EVERY_N_MILLISECONDS ( 20) { index++; }
|
|
|
// EVERY_N_MILLISECONDS ( 20) { index++; }
|
|
|
index++; |
|
|
index++; |
|
|
if (duration == 0) { |
|
|
if (duration == 0) { |
|
|
refresh = &Led::loop_steady; |
|
|
refresh = &Led::loop_rainbow; |
|
|
change = true; |
|
|
|
|
|
} else if (duration == UINT16_MAX) { |
|
|
} else if (duration == UINT16_MAX) { |
|
|
} else { |
|
|
} else { |
|
|
duration--; |
|
|
duration--; |
|
|
} |
|
|
} |
|
|
EVERY_N_SECONDS(300) { |
|
|
EVERY_N_SECONDS(30) { |
|
|
// FastLED.clear();
|
|
|
// FastLED.clear();
|
|
|
// delay(200);
|
|
|
// delay(200);
|
|
|
changeAnimation(3, 400); |
|
|
changeAnimation(2, 2000); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
vTaskDelay(50 / portTICK_PERIOD_MS); |
|
|
vTaskDelay(50 / portTICK_PERIOD_MS); |
|
|