logo

qmk_firmware

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

is31fl3218.md (6430B)


  1. # IS31FL3218 Driver {#is31fl3218-driver}
  2. I²C LED driver by Lumissil. Supports up to 18 single-color LEDs, or 6 RGB LEDs.
  3. [IS31FL3218 Datasheet](https://www.lumissil.com/assets/pdf/core/IS31FL3218_DS.pdf)
  4. ## Usage {#usage}
  5. The IS31FL3218 driver code is automatically included if you are using the [LED Matrix](../features/led_matrix) or [RGB Matrix](../features/rgb_matrix) feature with the `is31fl3218` driver set, and you would use those APIs instead.
  6. However, if you need to use the driver standalone, add this to your `rules.mk`:
  7. ```make
  8. COMMON_VPATH += $(DRIVER_PATH)/led/issi
  9. SRC += is31fl3218-mono.c # For single-color
  10. SRC += is31fl3218.c # For RGB
  11. I2C_DRIVER_REQUIRED = yes
  12. ```
  13. ## Basic Configuration {#basic-configuration}
  14. Add the following to your `config.h`:
  15. |Define |Default |Description |
  16. |----------------------------|-------------|---------------------------------------------------|
  17. |`IS31FL3218_SDB_PIN` |*Not defined*|The GPIO pin connected to the driver's shutdown pin|
  18. |`IS31FL3218_I2C_TIMEOUT` |`100` |The I²C timeout in milliseconds |
  19. |`IS31FL3218_I2C_PERSISTENCE`|`0` |The number of times to retry I²C transmissions |
  20. ### I²C Addressing {#i2c-addressing}
  21. The IS31FL3218's 7-bit I²C address is `0x54`, available as `IS31FL3218_I2C_ADDRESS`.
  22. ## ARM/ChibiOS Configuration {#arm-configuration}
  23. Depending on the ChibiOS board configuration, you may need to [enable and configure I²C](i2c#arm-configuration) at the keyboard level.
  24. ## LED Mapping {#led-mapping}
  25. In order to use this driver, each output must be mapped to an LED index, by adding the following to your `<keyboard>.c`:
  26. ```c
  27. const is31fl3218_led_t PROGMEM g_is31fl3218_leds[IS31FL3218_LED_COUNT] = {
  28. /* R G B */
  29. {OUT1, OUT2, OUT3},
  30. // etc...
  31. };
  32. ```
  33. In this example, the red, green and blue channels for the first LED index all have their anodes connected to `VCC`, and their cathodes on the `OUT1`, `OUT2` and `OUT3` pins respectively.
  34. For the single-color driver, the principle is the same, but there is only one channel:
  35. ```c
  36. const is31fl3218_led_t PROGMEM g_is31fl3218_leds[IS31FL3218_LED_COUNT] = {
  37. /* V */
  38. {OUT1},
  39. // etc...
  40. };
  41. ```
  42. ## API {#api}
  43. ### `struct is31fl3218_led_t` {#api-is31fl3218-led-t}
  44. Contains the PWM register addresses for a single RGB LED.
  45. #### Members {#api-is31fl3218-led-t-members}
  46. - `uint8_t r`
  47. The output PWM register address for the LED's red channel (RGB driver only).
  48. - `uint8_t g`
  49. The output PWM register address for the LED's green channel (RGB driver only).
  50. - `uint8_t b`
  51. The output PWM register address for the LED's blue channel (RGB driver only).
  52. - `uint8_t v`
  53. The output PWM register address for the LED (single-color driver only).
  54. ---
  55. ### `void is31fl3218_init(void)` {#api-is31fl3218-init}
  56. Initialize the LED driver. This function should be called first.
  57. ---
  58. ### `void is31fl3218_write_register(uint8_t reg, uint8_t data)` {#api-is31fl3218-write-register}
  59. Set the value of the given register.
  60. #### Arguments {#api-is31fl3218-write-register-arguments}
  61. - `uint8_t reg`
  62. The register address.
  63. - `uint8_t data`
  64. The value to set.
  65. ---
  66. ### `void is31fl3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue)` {#api-is31fl3218-set-color}
  67. Set the color of a single LED (RGB driver only). This function does not immediately update the LEDs; call `is31fl3218_update_pwm_buffers()` after you are finished.
  68. #### Arguments {#api-is31fl3218-set-color-arguments}
  69. - `int index`
  70. The LED index (ie. the index into the `g_is31fl3218_leds` array).
  71. - `uint8_t red`
  72. The red value to set.
  73. - `uint8_t green`
  74. The green value to set.
  75. - `uint8_t blue`
  76. The blue value to set.
  77. ---
  78. ### `void is31fl3218_set_color_all(uint8_t red, uint8_t green, uint8_t blue)` {#api-is31fl3218-set-color-all}
  79. Set the color of all LEDs (RGB driver only).
  80. #### Arguments {#api-is31fl3218-set-color-all-arguments}
  81. - `uint8_t red`
  82. The red value to set.
  83. - `uint8_t green`
  84. The green value to set.
  85. - `uint8_t blue`
  86. The blue value to set.
  87. ---
  88. ### `void is31fl3218_set_value(int index, uint8_t value)` {#api-is31fl3218-set-value}
  89. Set the brightness of a single LED (single-color driver only). This function does not immediately update the LEDs; call `is31fl3218_update_pwm_buffers()` after you are finished.
  90. #### Arguments {#api-is31fl3218-set-value-arguments}
  91. - `int index`
  92. The LED index (ie. the index into the `g_is31fl3218_leds` array).
  93. - `uint8_t value`
  94. The brightness value to set.
  95. ---
  96. ### `void is31fl3218_set_value_all(uint8_t value)` {#api-is31fl3218-set-value-all}
  97. Set the brightness of all LEDs (single-color driver only).
  98. #### Arguments {#api-is31fl3218-set-value-all-arguments}
  99. - `uint8_t value`
  100. The brightness value to set.
  101. ---
  102. ### `void is31fl3218_set_led_control_register(uint8_t index, bool red, bool green, bool blue)` {#api-is31fl3218-set-led-control-register-rgb}
  103. Configure the LED control registers for a single LED (RGB driver only). This function does not immediately update the LEDs; call `is31fl3218_update_led_control_registers()` after you are finished.
  104. #### Arguments {#api-is31fl3218-set-led-control-register-rgb-arguments}
  105. - `uint8_t index`
  106. The LED index (ie. the index into the `g_is31fl3218_leds` array).
  107. - `bool red`
  108. Enable or disable the red channel.
  109. - `bool green`
  110. Enable or disable the green channel.
  111. - `bool blue`
  112. Enable or disable the blue channel.
  113. ---
  114. ### `void is31fl3218_set_led_control_register(uint8_t index, bool value)` {#api-is31fl3218-set-led-control-register-mono}
  115. Configure the LED control registers for a single LED (single-color driver only). This function does not immediately update the LEDs; call `is31fl3218_update_led_control_registers()` after you are finished.
  116. #### Arguments {#api-is31fl3218-set-led-control-register-mono-arguments}
  117. - `uint8_t index`
  118. The LED index (ie. the index into the `g_is31fl3218_leds` array).
  119. - `bool value`
  120. Enable or disable the LED.
  121. ---
  122. ### `void is31fl3218_update_pwm_buffers(void)` {#api-is31fl3218-update-pwm-buffers}
  123. Flush the PWM values to the LED driver.
  124. ---
  125. ### `void is31fl3218_update_led_control_registers(void)` {#api-is31fl3218-update-led-control-registers}
  126. Flush the LED control register values to the LED driver.