Module ws2812b

Source
Expand description

Contains driver for RGB LED Provides a driver for controlling WS2812B RGB LEDs via SPI on Linux.

This module serves as a high-level wrapper around the ws2818-rgb-led-spi-driver crate, simplifying the process of controlling a strip of WS2812B LEDs. It is specifically designed for hardware interaction and is only compiled when the target_os is “linux” and the target_hw feature is enabled.

§Key Features

  • Simple API: Offers a straightforward new() constructor and a set_color() method to control the entire LED strip.
  • Configuration Driven: Uses a Ws2812BConfig struct, deserialized from a configuration file, to specify the SPI device and the number of LEDs.
  • Correct Color Encoding: Automatically handles the common Green-Red-Blue (GRB) byte order expected by WS2812B LEDs.
  • Error Handling: Provides a dedicated Ws2812BError enum for clear and actionable error reporting during setup or operation.