Expand description
§Led Dma Buffers
Used for creating a PWM waveform using the DMA to control RGB LEDs such as WS2812, WS2812B, SK6812, SK6812-RGBW. Based on Phil’s Lab’s RGB Led video
§Example
const led_array: [RGB; 3] = [RGB::new(255,0,0), RGB::new(0,0,255), RGB::new(0,0,255)];
// Calculate the dma buffer's length at compile time
const DMA_BUFFER_LEN: usize = calc_dma_buffer_length(RGB::BIT_COUNT, led_array.len(), RESET_LENGTH);
// Initialize a new DMA buffer
let mut dma_buffer = LedDmaBuffer::<DMA_BUFFER_LEN>::new(t1h, t0h, LedDataComposition::GRB);
// Set the DMA buffer
dma_buffer.set_dma_buffer(&led_array, None).unwrap();
// Create a pwm waveform using the dma buffer
let mut dma1_ch2 = p.DMA1_CH2.into_ref();
pwm.waveform_ch1(&mut dma1_ch2, dma_buffer.get_dma_buffer()).await;Full examples can be found in the examples folder.
Structs§
- LedDma
Buffer - A generic DMA Buffer
- RGB
- Represents a RGB LED
- RGBW
- Represents a RGBW LED
Enums§
- LedData
Composition - The order of colors of the data sent to the LED
- LedDma
Error - Error Types
Traits§
- RgbLed
Color - Implemented by RGB & RGBW
Functions§
- calc_
dma_ buffer_ length - Calculates the required DMA buffer length for a LedDmaBuffer at compile time.