logo

qmk_firmware

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

is31fl3731.md (8604B)


  1. # IS31FL3731 Driver {#is31fl3731-driver}
  2. I²C Charlieplexed 16x9 LED matrix driver by Lumissil. Supports a maximum of four drivers, each controlling up to 144 single-color LEDs, or 48 RGB LEDs.
  3. [IS31FL3731 Datasheet](https://www.lumissil.com/assets/pdf/core/IS31FL3731_DS.pdf)
  4. ## Usage {#usage}
  5. The IS31FL3731 driver code is automatically included if you are using the [LED Matrix](../features/led_matrix) or [RGB Matrix](../features/rgb_matrix) feature with the `is31fl3731` 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 += is31fl3731-mono.c # For single-color
  10. SRC += is31fl3731.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. |`IS31FL3731_SDB_PIN` |*Not defined*|The GPIO pin connected to the drivers' shutdown pins|
  18. |`IS31FL3731_I2C_TIMEOUT` |`100` |The I²C timeout in milliseconds |
  19. |`IS31FL3731_I2C_PERSISTENCE`|`0` |The number of times to retry I²C transmissions |
  20. |`IS31FL3731_I2C_ADDRESS_1` |*Not defined*|The I²C address of driver 0 |
  21. |`IS31FL3731_I2C_ADDRESS_2` |*Not defined*|The I²C address of driver 1 |
  22. |`IS31FL3731_I2C_ADDRESS_3` |*Not defined*|The I²C address of driver 2 |
  23. |`IS31FL3731_I2C_ADDRESS_4` |*Not defined*|The I²C address of driver 3 |
  24. |`IS31FL3731_DEGHOST` |*Not defined*|Enable ghost image prevention |
  25. ### I²C Addressing {#i2c-addressing}
  26. The IS31FL3731 has four possible 7-bit I²C addresses, depending on how the `AD` pin is connected.
  27. To configure this, set the `IS31FL3731_I2C_ADDRESS_n` defines to one of the following in your `config.h`, where *n* denotes the driver index:
  28. |Define |Value |
  29. |----------------------------|------|
  30. |`IS31FL3731_I2C_ADDRESS_GND`|`0x74`|
  31. |`IS31FL3731_I2C_ADDRESS_SCL`|`0x75`|
  32. |`IS31FL3731_I2C_ADDRESS_SDA`|`0x76`|
  33. |`IS31FL3731_I2C_ADDRESS_VCC`|`0x77`|
  34. ### De-Ghosting {#de-ghosting}
  35. This setting enables the de-ghosting feature on the IS31FL3731. See this [Application Note](https://www.lumissil.com/assets/pdf/core/IS31FL3731_AN.pdf) (p. 15) for more information.
  36. To enable, add the following to your `config.h`:
  37. ```c
  38. #define IS31FL3731_DEGHOST
  39. ```
  40. ## ARM/ChibiOS Configuration {#arm-configuration}
  41. Depending on the ChibiOS board configuration, you may need to [enable and configure I²C](i2c#arm-configuration) at the keyboard level.
  42. ## LED Mapping {#led-mapping}
  43. In order to use this driver, each output must be mapped to an LED index, by adding the following to your `<keyboard>.c`:
  44. ```c
  45. const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = {
  46. /* Driver
  47. * | R G B */
  48. {0, C1_1, C1_2, C1_3},
  49. // etc...
  50. };
  51. ```
  52. In this example, the red, green and blue channels for the first LED index on driver 0 all have their cathodes connected to the `CA1` pin, and their anodes on the `CA2`, `CA3` and `CA4` pins respectively.
  53. For the single-color driver, the principle is the same, but there is only one channel:
  54. ```c
  55. const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = {
  56. /* Driver
  57. * | V */
  58. {0, C1_1},
  59. // etc...
  60. };
  61. ```
  62. These values correspond to the register indices as shown in the datasheet on page 11, figure 8.
  63. ## API {#api}
  64. ### `struct is31fl3731_led_t` {#api-is31fl3731-led-t}
  65. Contains the PWM register addresses for a single RGB LED.
  66. #### Members {#api-is31fl3731-led-t-members}
  67. - `uint8_t driver`
  68. The driver index of the LED, from 0 to 3.
  69. - `uint8_t r`
  70. The output PWM register address for the LED's red channel (RGB driver only).
  71. - `uint8_t g`
  72. The output PWM register address for the LED's green channel (RGB driver only).
  73. - `uint8_t b`
  74. The output PWM register address for the LED's blue channel (RGB driver only).
  75. - `uint8_t v`
  76. The output PWM register address for the LED (single-color driver only).
  77. ---
  78. ### `void is31fl3731_init(uint8_t index)` {#api-is31fl3731-init}
  79. Initialize the LED driver. This function should be called first.
  80. #### Arguments {#api-is31fl3731-init-arguments}
  81. - `uint8_t index`
  82. The driver index.
  83. ---
  84. ### `void is31fl3731_write_register(uint8_t index, uint8_t reg, uint8_t data)` {#api-is31fl3731-write-register}
  85. Set the value of the given register.
  86. #### Arguments {#api-is31fl3731-write-register-arguments}
  87. - `uint8_t index`
  88. The driver index.
  89. - `uint8_t reg`
  90. The register address.
  91. - `uint8_t data`
  92. The value to set.
  93. ---
  94. ### `void is31fl3731_select_page(uint8_t index, uint8_t page)` {#api-is31fl3731-select-page}
  95. Change the current page for configuring the LED driver.
  96. #### Arguments {#api-is31fl3731-select-page-arguments}
  97. - `uint8_t index`
  98. The driver index.
  99. - `uint8_t page`
  100. The page number to select.
  101. ---
  102. ### `void is31fl3731_set_color(int index, uint8_t red, uint8_t green, uint8_t blue)` {#api-is31fl3731-set-color}
  103. Set the color of a single LED (RGB driver only). This function does not immediately update the LEDs; call `is31fl3731_update_pwm_buffers()` after you are finished.
  104. #### Arguments {#api-is31fl3731-set-color-arguments}
  105. - `int index`
  106. The LED index (ie. the index into the `g_is31fl3731_leds` array).
  107. - `uint8_t red`
  108. The red value to set.
  109. - `uint8_t green`
  110. The green value to set.
  111. - `uint8_t blue`
  112. The blue value to set.
  113. ---
  114. ### `void is31fl3731_set_color_all(uint8_t red, uint8_t green, uint8_t blue)` {#api-is31fl3731-set-color-all}
  115. Set the color of all LEDs (RGB driver only).
  116. #### Arguments {#api-is31fl3731-set-color-all-arguments}
  117. - `uint8_t red`
  118. The red value to set.
  119. - `uint8_t green`
  120. The green value to set.
  121. - `uint8_t blue`
  122. The blue value to set.
  123. ---
  124. ### `void is31fl3731_set_value(int index, uint8_t value)` {#api-is31fl3731-set-value}
  125. Set the brightness of a single LED (single-color driver only). This function does not immediately update the LEDs; call `is31fl3731_update_pwm_buffers()` after you are finished.
  126. #### Arguments {#api-is31fl3731-set-value-arguments}
  127. - `int index`
  128. The LED index (ie. the index into the `g_is31fl3731_leds` array).
  129. - `uint8_t value`
  130. The brightness value to set.
  131. ---
  132. ### `void is31fl3731_set_value_all(uint8_t value)` {#api-is31fl3731-set-value-all}
  133. Set the brightness of all LEDs (single-color driver only).
  134. #### Arguments {#api-is31fl3731-set-value-all-arguments}
  135. - `uint8_t value`
  136. The brightness value to set.
  137. ---
  138. ### `void is31fl3731_set_led_control_register(uint8_t index, bool red, bool green, bool blue)` {#api-is31fl3731-set-led-control-register-rgb}
  139. Configure the LED control registers for a single LED (RGB driver only). This function does not immediately update the LEDs; call `is31fl3731_update_led_control_registers()` after you are finished.
  140. #### Arguments {#api-is31fl3731-set-led-control-register-rgb-arguments}
  141. - `uint8_t index`
  142. The LED index (ie. the index into the `g_is31fl3731_leds` array).
  143. - `bool red`
  144. Enable or disable the red channel.
  145. - `bool green`
  146. Enable or disable the green channel.
  147. - `bool blue`
  148. Enable or disable the blue channel.
  149. ---
  150. ### `void is31fl3731_set_led_control_register(uint8_t index, bool value)` {#api-is31fl3731-set-led-control-register-mono}
  151. Configure the LED control registers for a single LED (single-color driver only). This function does not immediately update the LEDs; call `is31fl3731_update_led_control_registers()` after you are finished.
  152. #### Arguments {#api-is31fl3731-set-led-control-register-mono-arguments}
  153. - `uint8_t index`
  154. The LED index (ie. the index into the `g_is31fl3731_leds` array).
  155. - `bool value`
  156. Enable or disable the LED.
  157. ---
  158. ### `void is31fl3731_update_pwm_buffers(uint8_t index)` {#api-is31fl3731-update-pwm-buffers}
  159. Flush the PWM values to the LED driver.
  160. #### Arguments {#api-is31fl3731-update-pwm-buffers-arguments}
  161. - `uint8_t index`
  162. The driver index.
  163. ---
  164. ### `void is31fl3731_update_led_control_registers(uint8_t index)` {#api-is31fl3731-update-led-control-registers}
  165. Flush the LED control register values to the LED driver.
  166. #### Arguments {#api-is31fl3731-update-led-control-registers-arguments}
  167. - `uint8_t index`
  168. The driver index.