Skip to content

Commit 0501326

Browse files
committed
feat(led_strip): discontinue esp-idf v4 and bump major version 🚀
1 parent 9a664de commit 0501326

20 files changed

+230
-384
lines changed

led_strip/CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
## 2.6.0
1+
## 3.0.0
2+
3+
- Discontinued support for ESP-IDF v4.x
4+
- Added configuration for user-defined color component order
25

3-
- Add pixel order configuration to support user-defined pixel order.
4-
56
## 2.5.5
67

78
- Simplified the led_strip component dependency, the time of full build with ESP-IDF v5.3 can now be shorter.

led_strip/CMakeLists.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@ include($ENV{IDF_PATH}/tools/cmake/version.cmake)
33
set(srcs "src/led_strip_api.c" "src/led_strip_common.c")
44
set(public_requires)
55

6-
# Starting from esp-idf v5.x, the RMT driver is rewritten
7-
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.0")
8-
if(CONFIG_SOC_RMT_SUPPORTED)
9-
list(APPEND srcs "src/led_strip_rmt_dev.c" "src/led_strip_rmt_encoder.c")
10-
endif()
11-
else()
12-
list(APPEND srcs "src/led_strip_rmt_dev_idf4.c")
6+
if(CONFIG_SOC_RMT_SUPPORTED)
7+
list(APPEND srcs "src/led_strip_rmt_dev.c" "src/led_strip_rmt_encoder.c")
138
endif()
149

1510
# the SPI backend driver relies on some feature that was available in IDF 5.1

led_strip/README.md

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,30 @@ This is the most economical way to drive the LEDs because it only consumes one R
1515
```c
1616
#define BLINK_GPIO 0
1717

18-
led_strip_handle_t led_strip;
19-
20-
/* LED strip initialization with the GPIO and pixels number*/
18+
/// LED strip common configuration
2119
led_strip_config_t strip_config = {
22-
.strip_gpio_num = BLINK_GPIO, // The GPIO that connected to the LED strip's data line
23-
.max_leds = 1, // The number of LEDs in the strip,
24-
.bytes_per_pixel = 3, // 3 bytes per pixel of the LED strip
20+
.strip_gpio_num = BLINK_GPIO, // The GPIO that connected to the LED strip's data line
21+
.max_leds = 1, // The number of LEDs in the strip,
2522
.led_model = LED_MODEL_WS2812, // LED strip model
26-
.flags.invert_out = false, // whether to invert the output signal (useful when your hardware has a level inverter)
27-
.pixel_order = LED_STRIP_SET_RGB_ORDER(1, 0, 2), /* The order of the pixel color. Not set or set to 0 if the default order is used.
28-
Here set to the default GRB order to demonstrate usage */
23+
.num_color_components = 3, // Each pixel has 3 color components: R,G,B
24+
.color_component_order = LED_STRIP_SET_RGB_ORDER(1, 0, 2), // Component order: G,R,B
25+
.flags = {
26+
.invert_out = false, // don't invert the output signal
27+
}
2928
};
3029

30+
/// RMT backend specific configuration
3131
led_strip_rmt_config_t rmt_config = {
32-
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
33-
.rmt_channel = 0,
34-
#else
35-
.clk_src = RMT_CLK_SRC_DEFAULT, // different clock source can lead to different power consumption
36-
.resolution_hz = 10 * 1000 * 1000, // 10MHz
37-
.flags.with_dma = false, // whether to enable the DMA feature
38-
#endif
32+
.clk_src = RMT_CLK_SRC_DEFAULT, // different clock source can lead to different power consumption
33+
.resolution_hz = 10 * 1000 * 1000, // RMT counter clock frequency: 10MHz
34+
.mem_block_symbols = 64, // the memory size of each RMT channel, in words (4 bytes)
35+
.flags = {
36+
.with_dma = false, // DMA feature is available on chips like ESP32-S3/P4
37+
}
3938
};
39+
40+
/// Create the LED strip object
41+
led_strip_handle_t led_strip;
4042
ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip));
4143
```
4244
@@ -53,24 +55,29 @@ Please note, the SPI backend has a dependency of **ESP-IDF >= 5.1**
5355
```c
5456
#define BLINK_GPIO 0
5557
56-
led_strip_handle_t led_strip;
57-
58-
/* LED strip initialization with the GPIO and pixels number*/
58+
/// LED strip common configuration
5959
led_strip_config_t strip_config = {
60-
.strip_gpio_num = BLINK_GPIO, // The GPIO that connected to the LED strip's data line
61-
.max_leds = 1, // The number of LEDs in the strip,
62-
.bytes_per_pixel = 3, // 3 bytes per pixel of the LED strip
60+
.strip_gpio_num = BLINK_GPIO, // The GPIO that connected to the LED strip's data line
61+
.max_leds = 1, // The number of LEDs in the strip,
6362
.led_model = LED_MODEL_WS2812, // LED strip model
64-
.flags.invert_out = false, // whether to invert the output signal (useful when your hardware has a level inverter)
65-
.pixel_order = LED_STRIP_SET_RGB_ORDER(1, 0, 2), /* The order of the pixel color. Not set or set to 0 if the default order is used.
66-
Here set to the default GRB order to demonstrate usage */
63+
.num_color_components = 3, // Each pixel has 3 color components: R,G,B
64+
.color_component_order = LED_STRIP_SET_RGB_ORDER(1, 0, 2), // Component order: G,R,B
65+
.flags = {
66+
.invert_out = false, // don't invert the output signal
67+
}
6768
};
6869
70+
/// SPI backend specific configuration
6971
led_strip_spi_config_t spi_config = {
7072
.clk_src = SPI_CLK_SRC_DEFAULT, // different clock source can lead to different power consumption
71-
.flags.with_dma = true, // Using DMA can improve performance and help drive more LEDs
72-
.spi_bus = SPI2_HOST, // SPI bus ID
73+
.spi_bus = SPI2_HOST, // SPI bus ID
74+
.flags = {
75+
.with_dma = true, // Using DMA can improve performance and help drive more LEDs
76+
}
7377
};
78+
79+
/// Create the LED strip object
80+
led_strip_handle_t led_strip;
7481
ESP_ERROR_CHECK(led_strip_new_spi_device(&strip_config, &spi_config, &led_strip));
7582
```
7683

led_strip/api.md

Lines changed: 80 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@
2121
| esp\_err\_t | [**led\_strip\_set\_pixel\_hsv**](#function-led_strip_set_pixel_hsv) ([**led\_strip\_handle\_t**](#typedef-led_strip_handle_t) strip, uint32\_t index, uint16\_t hue, uint8\_t saturation, uint8\_t value) <br>_Set HSV for a specific pixel._ |
2222
| esp\_err\_t | [**led\_strip\_set\_pixel\_rgbw**](#function-led_strip_set_pixel_rgbw) ([**led\_strip\_handle\_t**](#typedef-led_strip_handle_t) strip, uint32\_t index, uint32\_t red, uint32\_t green, uint32\_t blue, uint32\_t white) <br>_Set RGBW for a specific pixel._ |
2323

24-
## Macros
25-
26-
| Type | Name |
27-
| ---: | :--- |
28-
| define | [**LED\_STRIP\_SET\_RGBW\_ORDER**](#define-led_strip_set_rgbw_order) (R, G, B, W) (R &lt;&lt; 0 \| G &lt;&lt; 2 \| B &lt;&lt; 4 \| W &lt;&lt; 6)<br>_Help macro to set pixel RGBW color order The default order of the four-color LED strips is GRBW. If you have a different order, you can use the macro to set_ `pixel_order`_in_[_**led\_strip\_config\_t**_](#struct-led_strip_config_t)_. The positions are counted from the least significant bit (LSB)._ |
29-
| define | [**LED\_STRIP\_SET\_RGB\_ORDER**](#define-led_strip_set_rgb_order) (R, G, B) (R &lt;&lt; 0 \| G &lt;&lt; 2 \| B &lt;&lt; 4)<br>_Help macro to set pixel RGB color order The default order of the three-color LED strips is GRB. If you have a different order, you can use the macro to set_ `pixel_order`_in_[_**led\_strip\_config\_t**_](#struct-led_strip_config_t)_. The positions are counted from the least significant bit (LSB)._ |
30-
3124
## Functions Documentation
3225

3326
### function `led_strip_clear`
@@ -185,52 +178,14 @@ Also see `led_strip_set_pixel` if you only want to specify the RGB part of the c
185178
- ESP\_ERR\_INVALID\_ARG: Set RGBW color for a specific pixel failed because of an invalid argument
186179
- ESP\_FAIL: Set RGBW color for a specific pixel failed because other error occurred
187180

188-
## Macros Documentation
189-
190-
### define `LED_STRIP_SET_RGBW_ORDER`
191-
192-
_Help macro to set pixel RGBW color order The default order of the four-color LED strips is GRBW. If you have a different order, you can use the macro to set_ `pixel_order`_in_[_**led\_strip\_config\_t**_](#struct-led_strip_config_t)_. The positions are counted from the least significant bit (LSB)._
193-
194-
```c
195-
#define LED_STRIP_SET_RGBW_ORDER (R, G, B, W) (R << 0 | G << 2 | B << 4 | W << 6)
196-
```
197-
198-
**Parameters:**
199-
200-
- `R` The position of the red channel in the color order.
201-
- `G` The position of the green channel in the color order.
202-
- `B` The position of the blue channel in the color order.
203-
- `W` The position of the white channel in the color order.
204-
205-
**Note:**
206-
207-
The order starts from 0. And the user needs to make sure that all the numbers appear exactly once and are all less than the number of colors per pixel.
208-
209-
### define `LED_STRIP_SET_RGB_ORDER`
210-
211-
_Help macro to set pixel RGB color order The default order of the three-color LED strips is GRB. If you have a different order, you can use the macro to set_ `pixel_order`_in_[_**led\_strip\_config\_t**_](#struct-led_strip_config_t)_. The positions are counted from the least significant bit (LSB)._
212-
213-
```c
214-
#define LED_STRIP_SET_RGB_ORDER (R, G, B) (R << 0 | G << 2 | B << 4)
215-
```
216-
217-
**Parameters:**
218-
219-
- `R` The position of the red channel in the color order.
220-
- `G` The position of the green channel in the color order.
221-
- `B` The position of the blue channel in the color order.
222-
223-
**Note:**
224-
225-
The order starts from 0. And the user needs to make sure that all the numbers appear exactly once and are all less than the number of colors per pixel.
226-
227181
## File include/led_strip_rmt.h
228182

229183
## Structures and Types
230184

231185
| Type | Name |
232186
| ---: | :--- |
233187
| struct | [**led\_strip\_rmt\_config\_t**](#struct-led_strip_rmt_config_t) <br>_LED Strip RMT specific configuration._ |
188+
| struct | [**led\_strip\_rmt\_extra\_config**](#struct-led_strip_rmt_config_tled_strip_rmt_extra_config) <br> |
234189

235190
## Functions
236191

@@ -248,12 +203,16 @@ Variables:
248203

249204
- rmt\_clock\_source\_t clk_src <br>RMT clock source
250205

251-
- struct led\_strip\_rmt\_config\_t::@0 flags <br>Extra driver flags
206+
- struct [**led\_strip\_rmt\_config\_t::led\_strip\_rmt\_extra\_config**](#struct-led_strip_rmt_config_tled_strip_rmt_extra_config) flags <br>Extra driver flags
252207

253-
- size\_t mem_block_symbols <br>How many RMT symbols can one RMT channel hold at one time. Set to 0 will fallback to use the default size.
208+
- size\_t mem_block_symbols <br>How many RMT symbols can one RMT channel hold at one time. Set to 0 will fallback to use the default size. Extra RMT specific driver flags
254209

255210
- uint32\_t resolution_hz <br>RMT tick resolution, if set to zero, a default resolution (10MHz) will be applied
256211

212+
### struct `led_strip_rmt_config_t::led_strip_rmt_extra_config`
213+
214+
Variables:
215+
257216
- uint32\_t with_dma <br>Use DMA to transmit data
258217

259218
## Functions Documentation
@@ -307,7 +266,7 @@ Variables:
307266

308267
- spi\_clock\_source\_t clk_src <br>SPI clock source
309268

310-
- struct led\_strip\_spi\_config\_t::@1 flags <br>Extra driver flags
269+
- struct [**led\_strip\_spi\_config\_t**](#struct-led_strip_spi_config_t) flags <br>Extra driver flags
311270

312271
- spi\_host\_device\_t spi_bus <br>SPI bus ID. Which buses are available depends on the specific chip
313272

@@ -352,8 +311,16 @@ Although only the MOSI line is used for generating the signal, the whole SPI bus
352311
| Type | Name |
353312
| ---: | :--- |
354313
| enum | [**led\_model\_t**](#enum-led_model_t) <br>_LED strip model._ |
355-
| struct | [**led\_strip\_config\_t**](#struct-led_strip_config_t) <br>_LED Strip Configuration._ |
356-
| typedef struct [**led\_strip\_t**](#struct-led_strip_t) \* | [**led\_strip\_handle\_t**](#typedef-led_strip_handle_t) <br>_LED strip handle._ |
314+
| struct | [**led\_strip\_config\_t**](#struct-led_strip_config_t) <br>_LED Strip common configurations The common configurations are not specific to any backend peripheral._ |
315+
| struct | [**led\_strip\_extra\_flags**](#struct-led_strip_config_tled_strip_extra_flags) <br> |
316+
| typedef struct [**led\_strip\_t**](#struct-led_strip_t) \* | [**led\_strip\_handle\_t**](#typedef-led_strip_handle_t) <br>_Type of LED strip handle._ |
317+
318+
## Macros
319+
320+
| Type | Name |
321+
| ---: | :--- |
322+
| define | [**LED\_STRIP\_SET\_RGBW\_ORDER**](#define-led_strip_set_rgbw_order) (R, G, B, W) (R &lt;&lt; 0 | G &lt;&lt; 2 | B &lt;&lt; 4 | W &lt;&lt; 6)<br>_Help macro to set pixel RGBW color order The default order of the four-color LED strips is GRBW. If you have a different order, you can use the macro to set_ `pixel_order`_in_[_**led\_strip\_config\_t**_](#struct-led_strip_config_t)_. The positions are counted from the least significant bit (LSB)._ |
323+
| define | [**LED\_STRIP\_SET\_RGB\_ORDER**](#define-led_strip_set_rgb_order) (R, G, B) (R &lt;&lt; 0 | G &lt;&lt; 2 | B &lt;&lt; 4)<br>_Help macro to set pixel RGB color order The default order of the three-color LED strips is GRB. If you have a different order, you can use the macro to set_ `pixel_order`_in_[_**led\_strip\_config\_t**_](#struct-led_strip_config_t)_. The positions are counted from the least significant bit (LSB)._ |
357324

358325
## Structures and Types Documentation
359326

@@ -375,40 +342,92 @@ Different led model may have different timing parameters, so we need to distingu
375342

376343
### struct `led_strip_config_t`
377344

378-
_LED Strip Configuration._
345+
_LED Strip common configurations The common configurations are not specific to any backend peripheral._
379346

380347
Variables:
381348

382-
- uint8\_t bytes_per_pixel <br>bytes per LED pixel. Should be 3 or 4
349+
- uint8\_t color_component_order <br>Specifies the order of color components in each pixel. Use helper macros LED\_STRIP\_SET\_RGB\_ORDER or LED\_STRIP\_SET\_RGBW\_ORDER to set the order. Set to 0 to use the default order. LED strip extra driver flags
383350

384-
- struct led\_strip\_config\_t::@2 flags <br>The order of the pixel color. Use help macro LED\_STRIP\_SET\_RGB\_ORDER or LED\_STRIP\_SET\_RGBW\_ORDER to set. Not set or set to 0 if the default order is used. Extra driver flags
351+
- struct [**led\_strip\_config\_t::led\_strip\_extra\_flags**](#struct-led_strip_config_tled_strip_extra_flags) flags <br>Extra driver flags
385352

386-
- uint32\_t invert_out <br>Invert output signal
387-
388-
- [**led\_model\_t**](#enum-led_model_t) led_model <br>LED model
353+
- [**led\_model\_t**](#enum-led_model_t) led_model <br>Specifies the LED strip model (e.g., WS2812, SK6812)
389354

390-
- uint32\_t max_leds <br>Maximum LEDs in a single strip
355+
- uint32\_t max_leds <br>Maximum number of LEDs that can be controlled in a single strip
391356

392-
- uint8\_t pixel_order
357+
- uint8\_t num_color_components <br>Number of color components per LED pixel. Use 3 for RGB (Red, Green, Blue) or 4 for RGBW (Red, Green, Blue, White). If set to 0, the driver will default to 3 (RGB).
393358

394359
- int strip_gpio_num <br>GPIO number that used by LED strip
395360

361+
### struct `led_strip_config_t::led_strip_extra_flags`
362+
363+
Variables:
364+
365+
- uint32\_t invert_out <br>Invert output signal
366+
396367
### typedef `led_strip_handle_t`
397368

398-
_LED strip handle._
369+
_Type of LED strip handle._
399370

400371
```c
401372
typedef struct led_strip_t* led_strip_handle_t;
402373
```
403374

375+
## Macros Documentation
376+
377+
### define `LED_STRIP_SET_RGBW_ORDER`
378+
379+
_Help macro to set pixel RGBW color order The default order of the four-color LED strips is GRBW. If you have a different order, you can use the macro to set_ `pixel_order`_in_[_**led\_strip\_config\_t**_](#struct-led_strip_config_t)_. The positions are counted from the least significant bit (LSB)._
380+
381+
```c
382+
#define LED_STRIP_SET_RGBW_ORDER (
383+
R,
384+
G,
385+
B,
386+
W
387+
) (R << 0 | G << 2 | B << 4 | W << 6)
388+
```
389+
390+
**Parameters:**
391+
392+
- `R` The position of the red channel in the color order.
393+
- `G` The position of the green channel in the color order.
394+
- `B` The position of the blue channel in the color order.
395+
- `W` The position of the white channel in the color order.
396+
397+
**Note:**
398+
399+
The order starts from 0. And the user needs to make sure that all the numbers appear exactly once and are all less than the number of colors per pixel.
400+
401+
### define `LED_STRIP_SET_RGB_ORDER`
402+
403+
_Help macro to set pixel RGB color order The default order of the three-color LED strips is GRB. If you have a different order, you can use the macro to set_ `pixel_order`_in_[_**led\_strip\_config\_t**_](#struct-led_strip_config_t)_. The positions are counted from the least significant bit (LSB)._
404+
405+
```c
406+
#define LED_STRIP_SET_RGB_ORDER (
407+
R,
408+
G,
409+
B
410+
) (R << 0 | G << 2 | B << 4)
411+
```
412+
413+
**Parameters:**
414+
415+
- `R` The position of the red channel in the color order.
416+
- `G` The position of the green channel in the color order.
417+
- `B` The position of the blue channel in the color order.
418+
419+
**Note:**
420+
421+
The order starts from 0. And the user needs to make sure that all the numbers appear exactly once and are all less than the number of colors per pixel.
422+
404423
## File interface/led_strip_interface.h
405424

406425
## Structures and Types
407426

408427
| Type | Name |
409428
| ---: | :--- |
410429
| struct | [**led\_strip\_t**](#struct-led_strip_t) <br>_LED strip interface definition._ |
411-
| typedef struct [**led\_strip\_t**](#struct-led_strip_t) | [**led\_strip\_t**](#typedef-led_strip_t) <br> |
430+
| typedef struct led\_strip\_t | [**led\_strip\_t**](#typedef-led_strip_t) <br> |
412431

413432
## Structures and Types Documentation
414433

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
# For more information about build system see
2-
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
3-
# The following five lines of boilerplate have to be in your project's
4-
# CMakeLists in this exact order for cmake to work correctly
51
cmake_minimum_required(VERSION 3.16)
62

3+
set(COMPONENTS main)
4+
75
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
86
project(led_strip_rmt_ws2812)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## IDF Component Manager Manifest File
22
dependencies:
33
espressif/led_strip:
4-
version: '^2'
4+
version: '^3'
55
override_path: '../../../'

led_strip/examples/led_strip_rmt_ws2812/main/led_strip_rmt_ws2812_main.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ led_strip_handle_t configure_led(void)
2323
{
2424
// LED strip general initialization, according to your led board design
2525
led_strip_config_t strip_config = {
26-
.strip_gpio_num = LED_STRIP_GPIO_PIN, // The GPIO that connected to the LED strip's data line
27-
.max_leds = LED_STRIP_LED_COUNT, // The number of LEDs in the strip,
28-
.bytes_per_pixel = 3, // 3 bytes per pixel of the LED strip
29-
.led_model = LED_MODEL_WS2812, // LED strip model
30-
.flags.invert_out = false, // whether to invert the output signal
31-
.pixel_order = LED_STRIP_SET_RGB_ORDER(1, 0, 2), /* The order of the pixel color. Not set or set to 0 if the default order is used.
32-
Here set to the default GRB order to demonstrate usage */
26+
.strip_gpio_num = LED_STRIP_GPIO_PIN, // The GPIO that connected to the LED strip's data line
27+
.max_leds = LED_STRIP_LED_COUNT, // The number of LEDs in the strip,
28+
.led_model = LED_MODEL_WS2812, // LED strip model
29+
.num_color_components = 3, // Each pixel has 3 color components: R,G,B
30+
.color_component_order = LED_STRIP_SET_RGB_ORDER(1, 0, 2), // Component order: G,R,B
31+
.flags = {
32+
.invert_out = false, // don't invert the output signal
33+
}
3334
};
3435

3536
// LED strip backend configuration: RMT
3637
led_strip_rmt_config_t rmt_config = {
37-
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
38-
.rmt_channel = 0,
39-
#else
4038
.clk_src = RMT_CLK_SRC_DEFAULT, // different clock source can lead to different power consumption
4139
.resolution_hz = LED_STRIP_RMT_RES_HZ, // RMT counter clock frequency
42-
.flags.with_dma = false, // DMA feature is available on ESP target like ESP32-S3
43-
#endif
40+
.mem_block_symbols = 64, // the memory size of each RMT channel, in words (4 bytes)
41+
.flags = {
42+
.with_dma = false, // DMA feature is available on chips like ESP32-S3/P4
43+
}
4444
};
4545

4646
// LED Strip object handle
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
# For more information about build system see
2-
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
3-
# The following five lines of boilerplate have to be in your project's
4-
# CMakeLists in this exact order for cmake to work correctly
51
cmake_minimum_required(VERSION 3.16)
62

3+
set(COMPONENTS main)
4+
75
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
86
project(led_strip_spi_ws2812)

0 commit comments

Comments
 (0)