Skip to content

These module docs are in beta and may be incomplete.

modm:driver:ws2812: WS2812 Driver

Drives any number of chained WS2812 LEDs using a 3-bit SPI encoding (0 -> 100, 1 -> 110) running at 3 MHz. Thus, writing one LED takes 24µs and 9 bytes of memory.

There are several caveats:

  1. This only provides a blocking write API, due to technical limitations.
  2. Atomicity is not enforced, this should be done externally if required.
  3. The memory footprint is 3x as large, due to the bit stuffing for SPI.
  4. There is no enforced reset period of at least 50µs after the write is finished, it is up to the user to not trigger another write too early.

This driver directly accesses the STM32 HAL to keep the transmit register full, due to a lack of DMA capability in modm, thus this driver is STM32-only for now.


// Class
class modm::Ws2812b< class SpiMaster , class Output , size_t LEDs >;


modm:driver:ws2812 modm_driver_ws2812 modm: driver: ws2812 modm_architecture_spi modm: architecture: spi modm_driver_ws2812->modm_architecture_spi modm_driver modm: driver modm_driver_ws2812->modm_driver modm_math_units modm: math: units modm_driver_ws2812->modm_math_units modm_ui_color modm: ui: color modm_driver_ws2812->modm_ui_color