10
10
#include "esp_log.h"
11
11
#include "esp_err.h"
12
12
13
- // GPIO assignment
14
- #define LED_STRIP_GPIO_PIN 2
13
+ // Set to 1 to use DMA for driving the LED strip, 0 otherwise
14
+ // Please note the RMT DMA feature is only available on chips e.g. ESP32-S3/P4
15
+ #define LED_STRIP_USE_DMA 0
16
+
17
+ #if LED_STRIP_USE_DMA
18
+ // Numbers of the LED in the strip
19
+ #define LED_STRIP_LED_COUNT 256
20
+ #define LED_STRIP_MEMORY_BLOCK_WORDS 1024 // this determines the DMA block size
21
+ #else
15
22
// Numbers of the LED in the strip
16
23
#define LED_STRIP_LED_COUNT 24
24
+ #define LED_STRIP_MEMORY_BLOCK_WORDS 0 // let the driver choose a proper memory block size automatically
25
+ #endif // LED_STRIP_USE_DMA
26
+
27
+ // GPIO assignment
28
+ #define LED_STRIP_GPIO_PIN 2
29
+
17
30
// 10MHz resolution, 1 tick = 0.1us (led strip needs a high resolution)
18
31
#define LED_STRIP_RMT_RES_HZ (10 * 1000 * 1000)
19
32
@@ -36,9 +49,9 @@ led_strip_handle_t configure_led(void)
36
49
led_strip_rmt_config_t rmt_config = {
37
50
.clk_src = RMT_CLK_SRC_DEFAULT , // different clock source can lead to different power consumption
38
51
.resolution_hz = LED_STRIP_RMT_RES_HZ , // RMT counter clock frequency
39
- .mem_block_symbols = 0 , // the memory size of each RMT channel, 0 lets the driver decide.
52
+ .mem_block_symbols = LED_STRIP_MEMORY_BLOCK_WORDS , // the memory block size used by the RMT channel
40
53
.flags = {
41
- .with_dma = false, // DMA feature is available on chips like ESP32-S3/P4
54
+ .with_dma = LED_STRIP_USE_DMA , // Using DMA can improve performance when driving more LEDs
42
55
}
43
56
};
44
57
0 commit comments