mirror of
https://github.com/Makuna/NeoPixelBus.git
synced 2025-08-05 20:04:26 +02:00
Page:
ESP32 and RTOS Tasks
Pages
A method for resolving this
API Reference
Advanced Topics Tutorials
Color objects
Concentric Rings Support
DotStar Features
DotStar Methods
ESP32 DotStar Methods
ESP32 NeoMethods
ESP32 and RTOS Tasks
ESP8266 NeoMethods
Examples
FAQ #0
FAQ #1
FAQ #10
FAQ #11
FAQ #12
FAQ #2
FAQ #3
FAQ #4
FAQ #42
FAQ #5
FAQ #6
FAQ #7
FAQ #8
FAQ #9
FAQ
Home
HsbColor object API
HslColor object API
HtmlColor object API
Layout objects
LedSegment enum
Library Comercial Use
Library Comparisons
Matrix Panels Support
Nano 33 BLE NeoMethods
Neo Features
Neo Methods
NeoBitmapFile object API
NeoBitmapFile object
NeoBuffer object API
NeoBuffer object
NeoGamma object
NeoHueBlend objects
NeoMosaic object
NeoPixelAnimator object API
NeoPixelAnimator object
NeoPixelBrightnessBus object API
NeoPixelBrightnessBus object
NeoPixelBus object API
NeoPixelBus object
NeoPixelBusLg object API
NeoPixelBusLg object
NeoPixelSegmentBus object API
NeoPixelSegmentBus object
NeoTiles object
NeoTopology object
NeoVerticalSpriteSheet object API
NeoVerticalSpriteSheet object
Project References
Quick Start Guide
Quick Start Using One Wire LEDs
Quick Start Using Two Wire LEDs
Raster Image Support
Rgb16Color object API
Rgb48Color object API
RgbColor object API
Rgbw64Color object API
RgbwColor object API
RgbwwColor object API
SevenSegDigit object API
Smaller Code
Spiral Topography
T_COLOR_FEATURE
T_GAMMA
T_METHOD
Wiki Work List
enum AlarmAddError
enum AlarmPeriod
Clone
1
ESP32 and RTOS Tasks
Drzony edited this page 2021-08-06 22:49:57 +02:00
On ESP32, when the CPU is loaded, asynchronous WiFi libraries (like ESPAsyncWebServer or async-mqtt-client) may interfere with interrupts used to control the LEDs (I2S mode is less affected by this), which causes flickering of LEDs.
One way to solve that is to create a high priority task that will take care of showing the LEDs.
The following code is an example of this approach:
xSemaphoreHandle semaphore = NULL;
TaskHandle_t commit_task;
NeoPixelBus<NeoGrbFeature, NeoEsp32RmtNWs2811Method> pixel_bus;
void commitTaskProcedure(void *arg)
{
while (true)
{
while (ulTaskNotifyTake(pdTRUE, portMAX_DELAY) != 1)
;
pixel_bus.Show();
while (!pixel_bus.CanShow())
;
xSemaphoreGive(semaphore);
}
}
void commit()
{
xTaskNotifyGive(commit_task);
while (xSemaphoreTake(semaphore, portMAX_DELAY) != pdTRUE)
;
}
void init_task()
{
commit_task = NULL;
semaphore = xSemaphoreCreateBinary();
xTaskCreatePinnedToCore(
commitTaskProcedure, /* Task function. */
"ShowRunnerTask", /* name of task. */
10000, /* Stack size of task */
NULL, /* parameter of the task */
4, /* priority of the task */
&commit_task, /* Task handle to keep track of created task */
1); /* pin task to core core_id */
}
void setup()
{
pixel_bus.begin();
init_task();
}
void loop()
{
commit();
delay(10);
}