logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

apa102.md (2587B)


  1. # APA102 Driver {#apa102-driver}
  2. This driver provides support for APA102 addressable RGB LEDs. They are similar to the [WS2812](ws2812) LEDs, but have increased data and refresh rates.
  3. ## Usage {#usage}
  4. In most cases, the APA102 driver code is automatically included if you are using either the [RGBLight](../features/rgblight) or [RGB Matrix](../features/rgb_matrix) feature with the `apa102` driver set, and you would use those APIs instead.
  5. However, if you need to use the driver standalone, add the following to your `rules.mk`:
  6. ```make
  7. APA102_DRIVER_REQUIRED = yes
  8. ```
  9. You can then call the APA102 API by including `apa102.h` in your code.
  10. ## Basic Configuration {#basic-configuration}
  11. Add the following to your `config.h`:
  12. |Define |Default |Description |
  13. |---------------------------|-------------|------------------------------------------------------------------|
  14. |`APA102_DI_PIN` |*Not defined*|The GPIO pin connected to the DI pin of the first LED in the chain|
  15. |`APA102_CI_PIN` |*Not defined*|The GPIO pin connected to the CI pin of the first LED in the chain|
  16. |`APA102_DEFAULT_BRIGHTNESS`|`31` |The default global brightness level of the LEDs, from 0 to 31 |
  17. ## API {#api}
  18. ### `void apa102_init(void)` {#api-apa102-init}
  19. Initialize the LED driver. This function should be called first.
  20. ---
  21. ### `void apa102_set_color(uint16_t index, uint8_t red, uint8_t green, uint8_t blue)` {#api-apa102-set-color}
  22. Set the color of a single LED. This function does not immediately update the LEDs; call `apa102_flush()` after you are finished.
  23. #### Arguments {#api-apa102-set-color-arguments}
  24. - `uint16_t index`
  25. The LED index in the APA102 chain.
  26. - `uint8_t red`
  27. The red value to set.
  28. - `uint8_t green`
  29. The green value to set.
  30. - `uint8_t blue`
  31. The blue value to set.
  32. ---
  33. ### `void apa102_set_color_all(uint8_t red, uint8_t green, uint8_t blue)` {#api-apa102-set-color-all}
  34. Set the color of all LEDs.
  35. #### Arguments {#api-apa102-set-color-all-arguments}
  36. - `uint8_t red`
  37. The red value to set.
  38. - `uint8_t green`
  39. The green value to set.
  40. - `uint8_t blue`
  41. The blue value to set.
  42. ---
  43. ### `void apa102_flush(void)` {#api-apa102-flush}
  44. Flush the PWM values to the LED chain.
  45. ---
  46. ### `void apa102_set_brightness(uint8_t brightness)` {#api-apa102-set-brightness}
  47. Set the global brightness.
  48. #### Arguments {#api-apa102-set-brightness-arguments}
  49. - `uint8_t brightness`
  50. The brightness level to set, from 0 to 31.