Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/led_strip/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
idf_component_register(
INCLUDE_DIRS "include"
SRC_DIRS "src"
REQUIRES "base_component" "color"
REQUIRES "heap" "base_component" "color"
)
10 changes: 10 additions & 0 deletions components/led_strip/README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ You can use it directly with an SPI driver to talk to APA102 LED strips, or you
can use it with a RMT driver (such as the `Rmt` component) to talk to WS2812,
WS2811, WS2813, SK6812, etc. LED strips.

## Usage

The Config struct accepts `std::span<const uint8_t>` for start and end frames,
allowing efficient use of memory. For backwards compatibility, you can:

- Use empty frames: `.start_frame = {}`
- Use the predefined `LedStrip::APA102_START_FRAME` vector (auto-converts to span)
- Use `std::array` with CTAD: `.start_frame = std::array{0x00, 0x00, 0x00, 0x00}`
- Pass any existing vector or array that will be converted to a span

## Example

The [example](./example) shows the use of the `LedStrip` class to control a 5x5
Expand Down
10 changes: 8 additions & 2 deletions components/led_strip/example/main/led_strip_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,14 @@ extern "C" void app_main(void) {
});

//! [led strip ex1]
// create the rmt object
// create the rmt object with DMA enabled for better performance
espp::Rmt rmt(espp::Rmt::Config{
.gpio_num = NEO_BFF_IO,
.clock_src = RMT_CLK_SRC_DEFAULT,
.dma_enabled = true,
.block_size = 1024,
.resolution_hz = SK6805_FREQ_HZ,
.transaction_queue_depth = 2,
.log_level = espp::Logger::Verbosity::INFO,
});

Expand All @@ -138,14 +142,16 @@ extern "C" void app_main(void) {
rmt.transmit(data, len);
};

// now create the LedStrip object
// now create the LedStrip object with DMA support
espp::LedStrip led_strip(espp::LedStrip::Config{
.num_leds = NEO_BFF_NUM_LEDS,
.write = neopixel_write,
.send_brightness = false,
.byte_order = espp::LedStrip::ByteOrder::GRB,
.start_frame = {},
.end_frame = {},
.use_dma = true,
.dma_allocation_flags = MALLOC_CAP_DMA,
.log_level = espp::Logger::Verbosity::INFO,
});

Expand Down
Loading