Need support? support@freenove.com
117
118
119
120
121
122
123
124
125
break;
}
}
void task_RGBLeds(void *pvParameters) {
while (1) {
task_showRGBLeds(NULL);
}
}
Apply for a colored light control object and configure this object.
Freenove_ESP32_WS2812 strip = Freenove_ESP32_WS2812(LEDS_COUNT, LEDS_PIN, CHANNEL, TYPE_GRB);
Initialize the RGB LEDs, and set their brightness to the maximum value. Start a thread and set task_RGBLeds()
as the callback function of the thread.
void setupRGBLED() {
strip.begin();
strip.setBrightness(255);
xTaskCreateUniversal(task_RGBLeds, "task_RGBLeds", 4096, NULL, 1, NULL, 1);
}
RGB LEDs configuration function. Call this function to set the colored light mode and the red, green, and blue
color values of the LEDs.
void setRGBLED(uint8_t mode, uint8_t r, uint8_t g, uint8_t b) {
ledConfig_t.mode = mode;
ledConfig_t.r = r;
ledConfig_t.g = g;
ledConfig_t.b = b;
}
LED display function. The thread will control the RGB LEDs to emit different colors and phenomena according
to the configuration information of ledConfig_t.
32
33
34
…
42
43
…
51
52
…
59
60
…
77
78
…
void task_showRGBLeds(void *pvParameters) {
switch (ledConfig_t.mode) {
case LED_MODE_OFF:
……
break;
case LED_MODE_RGB:
……
break;
case LED_MODE_FOLLOWING:
……
break;
case LED_MODE_BLINK:
……
break;
case LED_MODE_BREATHING:
……