You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.8 KiB

  1. # WS2812 Driver
  2. This driver powers the [RGB Lighting](feature_rgblight.md) and [RGB Matrix](feature_rgb_matrix.md) features.
  3. Currently QMK supports the following addressable LEDs (however, the white LED in RGBW variants is not supported):
  4. WS2811, WS2812, WS2812B, WS2812C, etc.
  5. SK6812, SK6812MINI, SK6805
  6. These LEDs are called "addressable" because instead of using a wire per color, each LED contains a small microchip that understands a special protocol sent over a single wire. The chip passes on the remaining data to the next LED, allowing them to be chained together. In this way, you can easily control the color of the individual LEDs.
  7. ## Supported Driver Types
  8. | | AVR | ARM |
  9. |----------|--------------------|--------------------|
  10. | bit bang | :heavy_check_mark: | :heavy_check_mark: |
  11. | I2C | :heavy_check_mark: | |
  12. | SPI | | :heavy_check_mark: |
  13. | PWM | | Soon™ |
  14. ## Driver configuration
  15. ### Bitbang
  16. Default driver, the absence of configuration assumes this driver. To configure it, add this to your rules.mk:
  17. ```make
  18. WS2812_DRIVER = bitbang
  19. ```
  20. !> This driver is not hardware accelerated and may not be performant on heavily loaded systems.
  21. ### I2C
  22. Targeting boards where WS2812 support is offloaded to a 2nd MCU. Currently the driver is limited to AVR given the known consumers are ps2avrGB/BMC. To configure it, add this to your rules.mk:
  23. ```make
  24. WS2812_DRIVER = i2c
  25. ```
  26. Configure the hardware via your config.h:
  27. ```c
  28. #define WS2812_ADDRESS 0xb0 // default: 0xb0
  29. #define WS2812_TIMEOUT 100 // default: 100
  30. ```
  31. ### SPI
  32. Targeting STM32 boards where WS2812 support is offloaded to an SPI hardware device. The advantage is that the use of DMA offloads processing of the WS2812 protocol from the MCU. `RGB_DI_PIN` for this driver is the configured SPI MOSI pin. Due to the nature of repurposing SPI to drive the LEDs, the other SPI pins, MISO and SCK, **must** remain unused. To configure it, add this to your rules.mk:
  33. ```make
  34. WS2812_DRIVER = spi
  35. ```
  36. Configure the hardware via your config.h:
  37. ```c
  38. #define WS2812_SPI SPID1 // default: SPID1
  39. #define WS2812_SPI_MOSI_PAL_MODE 5 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 5
  40. ```
  41. You must also turn on the SPI feature in your halconf.h and mcuconf.h
  42. #### Testing Notes
  43. While not an exhaustive list, the following table provides the scenarios that have been partially validated:
  44. | | SPI1 | SPI2 | SPI3 |
  45. |-|-|-|-|
  46. | f072 | ? | B15 :heavy_check_mark: | N/A |
  47. | f103 | A7 :heavy_check_mark: | B15 :heavy_check_mark: | N/A |
  48. | f303 | A7 :heavy_check_mark: B5 :heavy_check_mark: | B15 :heavy_check_mark: | B5 :heavy_check_mark: |
  49. *Other supported ChibiOS boards and/or pins may function, it will be highly chip and configuration dependent.*