logo

qmk_firmware

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

is31fl3236.md (7770B)


  1. # IS31FL3236 Driver {#is31fl3236-driver}
  2. I²C LED driver by Lumissil. Supports a maximum of four drivers, each controlling up to 36 single-color LEDs, or 12 RGB LEDs.
  3. [IS31FL3236 Datasheet](https://www.lumissil.com/assets/pdf/core/IS31FL3236_DS.pdf)
  4. ## Usage {#usage}
  5. The IS31FL3236 driver code is automatically included if you are using the [LED Matrix](../features/led_matrix) or [RGB Matrix](../features/rgb_matrix) feature with the `is31fl3236` 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 += is31fl3236-mono.c # For single-color
  10. SRC += is31fl3236.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. |`IS31FL3236_SDB_PIN` |*Not defined*|The GPIO pin connected to the drivers' shutdown pins|
  18. |`IS31FL3236_I2C_TIMEOUT` |`100` |The I²C timeout in milliseconds |
  19. |`IS31FL3236_I2C_PERSISTENCE`|`0` |The number of times to retry I²C transmissions |
  20. |`IS31FL3236_I2C_ADDRESS_1` |*Not defined*|The I²C address of driver 0 |
  21. |`IS31FL3236_I2C_ADDRESS_2` |*Not defined*|The I²C address of driver 1 |
  22. |`IS31FL3236_I2C_ADDRESS_3` |*Not defined*|The I²C address of driver 2 |
  23. |`IS31FL3236_I2C_ADDRESS_4` |*Not defined*|The I²C address of driver 3 |
  24. ### I²C Addressing {#i2c-addressing}
  25. The IS31FL3236 has four possible 7-bit I²C addresses, depending on how the `AD` pin is connected.
  26. To configure this, set the `IS31FL3236_I2C_ADDRESS_n` defines to one of the following in your `config.h`, where *n* denotes the driver index:
  27. |Define |Value |
  28. |----------------------------|------|
  29. |`IS31FL3236_I2C_ADDRESS_GND`|`0x3C`|
  30. |`IS31FL3236_I2C_ADDRESS_SCL`|`0x3D`|
  31. |`IS31FL3236_I2C_ADDRESS_SDA`|`0x3E`|
  32. |`IS31FL3236_I2C_ADDRESS_VCC`|`0x3F`|
  33. ## ARM/ChibiOS Configuration {#arm-configuration}
  34. Depending on the ChibiOS board configuration, you may need to [enable and configure I²C](i2c#arm-configuration) at the keyboard level.
  35. ## LED Mapping {#led-mapping}
  36. In order to use this driver, each output must be mapped to an LED index, by adding the following to your `<keyboard>.c`:
  37. ```c
  38. const is31fl3236_led_t PROGMEM g_is31fl3236_leds[IS31FL3236_LED_COUNT] = {
  39. /* Driver
  40. | R G B */
  41. {0, OUT1, OUT2, OUT3},
  42. // etc...
  43. };
  44. ```
  45. In this example, the red, green and blue channels for the first LED index on driver 0 all have their anodes connected to `VCC`, and their cathodes on the `OUT1`, `OUT2` and `OUT3` pins respectively.
  46. For the single-color driver, the principle is the same, but there is only one channel:
  47. ```c
  48. const is31fl3236_led_t PROGMEM g_is31fl3236_leds[IS31FL3236_LED_COUNT] = {
  49. /* Driver
  50. | V */
  51. {0, OUT1},
  52. // etc...
  53. };
  54. ```
  55. ## API {#api}
  56. ### `struct is31fl3236_led_t` {#api-is31fl3236-led-t}
  57. Contains the PWM register addresses for a single RGB LED.
  58. #### Members {#api-is31fl3236-led-t-members}
  59. - `uint8_t driver`
  60. The driver index of the LED, from 0 to 3.
  61. - `uint8_t r`
  62. The output PWM register address for the LED's red channel (RGB driver only).
  63. - `uint8_t g`
  64. The output PWM register address for the LED's green channel (RGB driver only).
  65. - `uint8_t b`
  66. The output PWM register address for the LED's blue channel (RGB driver only).
  67. - `uint8_t v`
  68. The output PWM register address for the LED (single-color driver only).
  69. ---
  70. ### `void is31fl3236_init(uint8_t index)` {#api-is31fl3236-init}
  71. Initialize the LED driver. This function should be called first.
  72. #### Arguments {#api-is31fl3236-init-arguments}
  73. - `uint8_t index`
  74. The driver index.
  75. ---
  76. ### `void is31fl3236_write_register(uint8_t index, uint8_t reg, uint8_t data)` {#api-is31fl3236-write-register}
  77. Set the value of the given register.
  78. #### Arguments {#api-is31fl3236-write-register-arguments}
  79. - `uint8_t index`
  80. The driver index.
  81. - `uint8_t reg`
  82. The register address.
  83. - `uint8_t data`
  84. The value to set.
  85. ---
  86. ### `void is31fl3236_set_color(int index, uint8_t red, uint8_t green, uint8_t blue)` {#api-is31fl3236-set-color}
  87. Set the color of a single LED (RGB driver only). This function does not immediately update the LEDs; call `is31fl3236_update_pwm_buffers()` after you are finished.
  88. #### Arguments {#api-is31fl3236-set-color-arguments}
  89. - `int index`
  90. The LED index (ie. the index into the `g_is31fl3236_leds` array).
  91. - `uint8_t red`
  92. The red value to set.
  93. - `uint8_t green`
  94. The green value to set.
  95. - `uint8_t blue`
  96. The blue value to set.
  97. ---
  98. ### `void is31fl3236_set_color_all(uint8_t red, uint8_t green, uint8_t blue)` {#api-is31fl3236-set-color-all}
  99. Set the color of all LEDs (RGB driver only).
  100. #### Arguments {#api-is31fl3236-set-color-all-arguments}
  101. - `uint8_t red`
  102. The red value to set.
  103. - `uint8_t green`
  104. The green value to set.
  105. - `uint8_t blue`
  106. The blue value to set.
  107. ---
  108. ### `void is31fl3236_set_value(int index, uint8_t value)` {#api-is31fl3236-set-value}
  109. Set the brightness of a single LED (single-color driver only). This function does not immediately update the LEDs; call `is31fl3236_update_pwm_buffers()` after you are finished.
  110. #### Arguments {#api-is31fl3236-set-value-arguments}
  111. - `int index`
  112. The LED index (ie. the index into the `g_is31fl3236_leds` array).
  113. - `uint8_t value`
  114. The brightness value to set.
  115. ---
  116. ### `void is31fl3236_set_value_all(uint8_t value)` {#api-is31fl3236-set-value-all}
  117. Set the brightness of all LEDs (single-color driver only).
  118. #### Arguments {#api-is31fl3236-set-value-all-arguments}
  119. - `uint8_t value`
  120. The brightness value to set.
  121. ---
  122. ### `void is31fl3236_set_led_control_register(uint8_t index, bool red, bool green, bool blue)` {#api-is31fl3236-set-led-control-register-rgb}
  123. Configure the LED control registers for a single LED (RGB driver only). This function does not immediately update the LEDs; call `is31fl3236_update_led_control_registers()` after you are finished.
  124. #### Arguments {#api-is31fl3236-set-led-control-register-rgb-arguments}
  125. - `uint8_t index`
  126. The LED index (ie. the index into the `g_is31fl3236_leds` array).
  127. - `bool red`
  128. Enable or disable the red channel.
  129. - `bool green`
  130. Enable or disable the green channel.
  131. - `bool blue`
  132. Enable or disable the blue channel.
  133. ---
  134. ### `void is31fl3236_set_led_control_register(uint8_t index, bool value)` {#api-is31fl3236-set-led-control-register-mono}
  135. Configure the LED control registers for a single LED (single-color driver only). This function does not immediately update the LEDs; call `is31fl3236_update_led_control_registers()` after you are finished.
  136. #### Arguments {#api-is31fl3236-set-led-control-register-mono-arguments}
  137. - `uint8_t index`
  138. The LED index (ie. the index into the `g_is31fl3236_leds` array).
  139. - `bool value`
  140. Enable or disable the LED.
  141. ---
  142. ### `void is31fl3236_update_pwm_buffers(uint8_t index)` {#api-is31fl3236-update-pwm-buffers}
  143. Flush the PWM values to the LED driver.
  144. #### Arguments {#api-is31fl3236-update-pwm-buffers-arguments}
  145. - `uint8_t index`
  146. The driver index.
  147. ---
  148. ### `void is31fl3236_update_led_control_registers(uint8_t index)` {#api-is31fl3236-update-led-control-registers}
  149. Flush the LED control register values to the LED driver.
  150. #### Arguments {#api-is31fl3236-update-led-control-registers-arguments}
  151. - `uint8_t index`
  152. The driver index.