|
@ -10,6 +10,7 @@ using namespace std; |
|
|
Led::Led(void) { |
|
|
Led::Led(void) { |
|
|
index = 0; |
|
|
index = 0; |
|
|
duration = 0; |
|
|
duration = 0; |
|
|
|
|
|
wakeupIndex = 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void Led::loop_rainbow(void) { |
|
|
void Led::loop_rainbow(void) { |
|
@ -35,6 +36,22 @@ void Led::loop_steady(void) { |
|
|
fill_solid(leds, NUM_LEDS, color); |
|
|
fill_solid(leds, NUM_LEDS, color); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Led::loop_off(void) { |
|
|
|
|
|
if (wakeupIndex == 0) { |
|
|
|
|
|
fill_solid(leds, NUM_LEDS, CRGB::Black); |
|
|
|
|
|
} else { |
|
|
|
|
|
fill_solid(leds, NUM_LEDS, CRGB::White); |
|
|
|
|
|
FastLED.setBrightness(wakeupIndex); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Led::wakeUpLight(uint8_t i) { |
|
|
|
|
|
fill_solid(leds, NUM_LEDS, CRGB::White); |
|
|
|
|
|
FastLED.setBrightness(i); |
|
|
|
|
|
Serial.printf("wakeuplight(%d)\n", i); |
|
|
|
|
|
wakeupIndex = i; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void Led::changeAnimation(uint8_t num, uint16_t duration) { |
|
|
void Led::changeAnimation(uint8_t num, uint16_t duration) { |
|
|
if (duration == 0) this->duration = UINT16_MAX; |
|
|
if (duration == 0) this->duration = UINT16_MAX; |
|
|
else this->duration = duration; |
|
|
else this->duration = duration; |
|
@ -42,6 +59,7 @@ void Led::changeAnimation(uint8_t num, uint16_t duration) { |
|
|
else if (num == 1) refresh = &Led::loop_sweep; |
|
|
else if (num == 1) refresh = &Led::loop_sweep; |
|
|
else if (num == 2) refresh = &Led::loop_confetti; |
|
|
else if (num == 2) refresh = &Led::loop_confetti; |
|
|
else if (num == 3) refresh = &Led::loop_rainbow; |
|
|
else if (num == 3) refresh = &Led::loop_rainbow; |
|
|
|
|
|
else if (num == 255) refresh = &Led::loop_off; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void Led::changeColor(uint8_t r, uint8_t g, uint8_t b) { |
|
|
void Led::changeColor(uint8_t r, uint8_t g, uint8_t b) { |
|
@ -68,10 +86,10 @@ void Led::setup(void) { |
|
|
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS); |
|
|
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS); |
|
|
FastLED.setBrightness(96); |
|
|
FastLED.setBrightness(96); |
|
|
FastLED.setCorrection(0xFF5050); |
|
|
FastLED.setCorrection(0xFF5050); |
|
|
fill_solid(leds, NUM_LEDS, CRGB::White); |
|
|
fill_solid(leds, NUM_LEDS, CRGB::Black); |
|
|
color = CRGB::Orange; |
|
|
color = CRGB::Orange; |
|
|
|
|
|
|
|
|
refresh = &Led::loop_rainbow; |
|
|
refresh = &Led::loop_off; |
|
|
delay(100); |
|
|
delay(100); |
|
|
xTaskCreate( |
|
|
xTaskCreate( |
|
|
&cTaskWrapper, /* Task function. */ |
|
|
&cTaskWrapper, /* Task function. */ |
|
@ -91,16 +109,16 @@ void Led::animationTask(void* parameters) { |
|
|
// EVERY_N_MILLISECONDS ( 20) { index++; }
|
|
|
// EVERY_N_MILLISECONDS ( 20) { index++; }
|
|
|
index++; |
|
|
index++; |
|
|
if (duration == 0) { |
|
|
if (duration == 0) { |
|
|
refresh = &Led::loop_rainbow; |
|
|
refresh = &Led::loop_off; |
|
|
} else if (duration == UINT16_MAX) { |
|
|
} else if (duration == UINT16_MAX) { |
|
|
} else { |
|
|
} else { |
|
|
duration--; |
|
|
duration--; |
|
|
} |
|
|
} |
|
|
EVERY_N_SECONDS(30) { |
|
|
// EVERY_N_SECONDS(30) {
|
|
|
// FastLED.clear();
|
|
|
// FastLED.clear();
|
|
|
// delay(200);
|
|
|
// delay(200);
|
|
|
changeAnimation(2, 2000); |
|
|
// changeAnimation(2, 2000);
|
|
|
} |
|
|
// }
|
|
|
} |
|
|
} |
|
|
vTaskDelay(50 / portTICK_PERIOD_MS); |
|
|
vTaskDelay(50 / portTICK_PERIOD_MS); |
|
|
} |
|
|
} |
|
|