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.

782 lines
42 KiB

2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
  1. # RGB Matrix Lighting :id=rgb-matrix-lighting
  2. This feature allows you to use RGB LED matrices driven by external drivers. It hooks into the RGBLIGHT system so you can use the same keycodes as RGBLIGHT to control it.
  3. If you want to use single color LED's you should use the [LED Matrix Subsystem](feature_led_matrix.md) instead.
  4. ## Driver configuration :id=driver-configuration
  5. ---
  6. ### IS31FL3731 :id=is31fl3731
  7. There is basic support for addressable RGB matrix lighting with the I2C IS31FL3731 RGB controller. To enable it, add this to your `rules.mk`:
  8. ```makefile
  9. RGB_MATRIX_ENABLE = yes
  10. RGB_MATRIX_DRIVER = IS31FL3731
  11. ```
  12. You can use between 1 and 4 IS31FL3731 IC's. Do not specify `DRIVER_ADDR_<N>` defines for IC's that are not present on your keyboard. You can define the following items in `config.h`:
  13. | Variable | Description | Default |
  14. |----------|-------------|---------|
  15. | `ISSI_TIMEOUT` | (Optional) How long to wait for i2c messages, in milliseconds | 100 |
  16. | `ISSI_PERSISTENCE` | (Optional) Retry failed messages this many times | 0 |
  17. | `DRIVER_COUNT` | (Required) How many RGB driver IC's are present | |
  18. | `DRIVER_LED_TOTAL` | (Required) How many RGB lights are present across all drivers | |
  19. | `DRIVER_ADDR_1` | (Required) Address for the first RGB driver | |
  20. | `DRIVER_ADDR_2` | (Optional) Address for the second RGB driver | |
  21. | `DRIVER_ADDR_3` | (Optional) Address for the third RGB driver | |
  22. | `DRIVER_ADDR_4` | (Optional) Address for the fourth RGB driver | |
  23. Here is an example using 2 drivers.
  24. ```c
  25. // This is a 7-bit address, that gets left-shifted and bit 0
  26. // set to 0 for write, 1 for read (as per I2C protocol)
  27. // The address will vary depending on your wiring:
  28. // 0b1110100 AD <-> GND
  29. // 0b1110111 AD <-> VCC
  30. // 0b1110101 AD <-> SCL
  31. // 0b1110110 AD <-> SDA
  32. #define DRIVER_ADDR_1 0b1110100
  33. #define DRIVER_ADDR_2 0b1110110
  34. #define DRIVER_COUNT 2
  35. #define DRIVER_1_LED_TOTAL 25
  36. #define DRIVER_2_LED_TOTAL 24
  37. #define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
  38. ```
  39. !> Note the parentheses, this is so when `DRIVER_LED_TOTAL` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`.
  40. Define these arrays listing all the LEDs in your `<keyboard>.c`:
  41. ```c
  42. const is31_led __flash g_is31_leds[DRIVER_LED_TOTAL] = {
  43. /* Refer to IS31 manual for these locations
  44. * driver
  45. * | R location
  46. * | | G location
  47. * | | | B location
  48. * | | | | */
  49. {0, C1_3, C2_3, C3_3},
  50. ....
  51. }
  52. ```
  53. Where `Cx_y` is the location of the LED in the matrix defined by [the datasheet](https://www.issi.com/WW/pdf/31FL3731.pdf) and the header file `drivers/led/issi/is31fl3731.h`. The `driver` is the index of the driver you defined in your `config.h` (`0`, `1`, `2`, or `3`).
  54. ---
  55. ### IS31FL3733 :id=is31fl3733
  56. There is basic support for addressable RGB matrix lighting with the I2C IS31FL3733 RGB controller. To enable it, add this to your `rules.mk`:
  57. ```makefile
  58. RGB_MATRIX_ENABLE = yes
  59. RGB_MATRIX_DRIVER = IS31FL3733
  60. ```
  61. You can use between 1 and 4 IS31FL3733 IC's. Do not specify `DRIVER_ADDR_<N>` defines for IC's that are not present on your keyboard. You can define the following items in `config.h`:
  62. | Variable | Description | Default |
  63. |----------|-------------|---------|
  64. | `ISSI_TIMEOUT` | (Optional) How long to wait for i2c messages, in milliseconds | 100 |
  65. | `ISSI_PERSISTENCE` | (Optional) Retry failed messages this many times | 0 |
  66. | `DRIVER_COUNT` | (Required) How many RGB driver IC's are present | |
  67. | `DRIVER_LED_TOTAL` | (Required) How many RGB lights are present across all drivers | |
  68. | `DRIVER_ADDR_1` | (Required) Address for the first RGB driver | |
  69. | `DRIVER_ADDR_2` | (Optional) Address for the second RGB driver | |
  70. | `DRIVER_ADDR_3` | (Optional) Address for the third RGB driver | |
  71. | `DRIVER_ADDR_4` | (Optional) Address for the fourth RGB driver | |
  72. | `DRIVER_SYNC_1` | (Optional) Sync configuration for the first RGB driver | 0 |
  73. | `DRIVER_SYNC_2` | (Optional) Sync configuration for the second RGB driver | 0 |
  74. | `DRIVER_SYNC_3` | (Optional) Sync configuration for the third RGB driver | 0 |
  75. | `DRIVER_SYNC_4` | (Optional) Sync configuration for the fourth RGB driver | 0 |
  76. Here is an example using 2 drivers.
  77. ```c
  78. // This is a 7-bit address, that gets left-shifted and bit 0
  79. // set to 0 for write, 1 for read (as per I2C protocol)
  80. // The address will vary depending on your wiring:
  81. // 00 <-> GND
  82. // 01 <-> SCL
  83. // 10 <-> SDA
  84. // 11 <-> VCC
  85. // ADDR1 represents A1:A0 of the 7-bit address.
  86. // ADDR2 represents A3:A2 of the 7-bit address.
  87. // The result is: 0b101(ADDR2)(ADDR1)
  88. #define DRIVER_ADDR_1 0b1010000
  89. #define DRIVER_ADDR_2 0b1010011
  90. #define DRIVER_COUNT 2
  91. #define DRIVER_1_LED_TOTAL 58
  92. #define DRIVER_2_LED_TOTAL 10
  93. #define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
  94. ```
  95. !> Note the parentheses, this is so when `DRIVER_LED_TOTAL` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`.
  96. Currently only 4 drivers are supported, but it would be trivial to support all 8 combinations.
  97. Define these arrays listing all the LEDs in your `<keyboard>.c`:
  98. ```c
  99. const is31_led __flash g_is31_leds[DRIVER_LED_TOTAL] = {
  100. /* Refer to IS31 manual for these locations
  101. * driver
  102. * | R location
  103. * | | G location
  104. * | | | B location
  105. * | | | | */
  106. {0, B_1, A_1, C_1},
  107. ....
  108. }
  109. ```
  110. Where `X_Y` is the location of the LED in the matrix defined by [the datasheet](https://www.issi.com/WW/pdf/31FL3733.pdf) and the header file `drivers/led/issi/is31fl3733.h`. The `driver` is the index of the driver you defined in your `config.h` (`0`, `1`, `2`, or `3` for now).
  111. ---
  112. ### IS31FL3737 :id=is31fl3737
  113. There is basic support for addressable RGB matrix lighting with the I2C IS31FL3737 RGB controller. To enable it, add this to your `rules.mk`:
  114. ```makefile
  115. RGB_MATRIX_ENABLE = yes
  116. RGB_MATRIX_DRIVER = IS31FL3737
  117. ```
  118. You can use between 1 and 2 IS31FL3737 IC's. Do not specify `DRIVER_ADDR_2` define for second IC if not present on your keyboard.
  119. Configure the hardware via your `config.h`:
  120. | Variable | Description | Default |
  121. |----------|-------------|---------|
  122. | `ISSI_TIMEOUT` | (Optional) How long to wait for i2c messages, in milliseconds | 100 |
  123. | `ISSI_PERSISTENCE` | (Optional) Retry failed messages this many times | 0 |
  124. | `DRIVER_COUNT` | (Required) How many RGB driver IC's are present | |
  125. | `DRIVER_LED_TOTAL` | (Required) How many RGB lights are present across all drivers | |
  126. | `DRIVER_ADDR_1` | (Required) Address for the first RGB driver | |
  127. | `DRIVER_ADDR_2` | (Optional) Address for the second RGB driver | |
  128. Here is an example using 2 drivers.
  129. ```c
  130. // This is a 7-bit address, that gets left-shifted and bit 0
  131. // set to 0 for write, 1 for read (as per I2C protocol)
  132. // The address will vary depending on your wiring:
  133. // 0000 <-> GND
  134. // 0101 <-> SCL
  135. // 1010 <-> SDA
  136. // 1111 <-> VCC
  137. // ADDR represents A3:A0 of the 7-bit address.
  138. // The result is: 0b101(ADDR)
  139. #define DRIVER_ADDR_1 0b1010000
  140. #define DRIVER_ADDR_2 0b1010001
  141. #define DRIVER_COUNT 2
  142. #define DRIVER_1_LED_TOTAL 30
  143. #define DRIVER_2_LED_TOTAL 36
  144. #define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
  145. ```
  146. !> Note the parentheses, this is so when `DRIVER_LED_TOTAL` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`.
  147. Currently only 2 drivers are supported, but it would be trivial to support all 4 combinations.
  148. Define these arrays listing all the LEDs in your `<keyboard>.c`:
  149. ```c
  150. const is31_led __flash g_is31_leds[DRIVER_LED_TOTAL] = {
  151. /* Refer to IS31 manual for these locations
  152. * driver
  153. * | R location
  154. * | | G location
  155. * | | | B location
  156. * | | | | */
  157. {0, B_1, A_1, C_1},
  158. ....
  159. }
  160. ```
  161. Where `X_Y` is the location of the LED in the matrix defined by [the datasheet](https://www.issi.com/WW/pdf/31FL3737.pdf) and the header file `drivers/led/issi/is31fl3737.h`. The `driver` is the index of the driver you defined in your `config.h` (Only `0`, `1` for now).
  162. ---
  163. ### WS2812 :id=ws2812
  164. There is basic support for addressable RGB matrix lighting with a WS2811/WS2812{a,b,c} addressable LED strand. To enable it, add this to your `rules.mk`:
  165. ```makefile
  166. RGB_MATRIX_ENABLE = yes
  167. RGB_MATRIX_DRIVER = WS2812
  168. ```
  169. Configure the hardware via your `config.h`:
  170. ```c
  171. // The pin connected to the data pin of the LEDs
  172. #define RGB_DI_PIN D7
  173. // The number of LEDs connected
  174. #define DRIVER_LED_TOTAL 70
  175. ```
  176. ---
  177. ### APA102 :id=apa102
  178. There is basic support for APA102 based addressable LED strands. To enable it, add this to your `rules.mk`:
  179. ```makefile
  180. RGB_MATRIX_ENABLE = yes
  181. RGB_MATRIX_DRIVER = APA102
  182. ```
  183. Configure the hardware via your `config.h`:
  184. ```c
  185. // The pin connected to the data pin of the LEDs
  186. #define RGB_DI_PIN D7
  187. // The pin connected to the clock pin of the LEDs
  188. #define RGB_CI_PIN D6
  189. // The number of LEDs connected
  190. #define DRIVER_LED_TOTAL 70
  191. ```
  192. ---
  193. ### AW20216 :id=aw20216
  194. There is basic support for addressable RGB matrix lighting with the SPI AW20216 RGB controller. To enable it, add this to your `rules.mk`:
  195. ```makefile
  196. RGB_MATRIX_ENABLE = yes
  197. RGB_MATRIX_DRIVER = AW20216
  198. ```
  199. You can use up to 2 AW20216 IC's. Do not specify `DRIVER_<N>_xxx` defines for IC's that are not present on your keyboard. You can define the following items in `config.h`:
  200. | Variable | Description | Default |
  201. |----------|-------------|---------|
  202. | `DRIVER_1_CS` | (Required) MCU pin connected to first RGB driver chip select line | B13 |
  203. | `DRIVER_2_CS` | (Optional) MCU pin connected to second RGB driver chip select line | |
  204. | `DRIVER_1_EN` | (Required) MCU pin connected to first RGB driver hardware enable line | C13 |
  205. | `DRIVER_2_EN` | (Optional) MCU pin connected to second RGB driver hardware enable line | |
  206. | `DRIVER_1_LED_TOTAL` | (Required) How many RGB lights are connected to first RGB driver | |
  207. | `DRIVER_2_LED_TOTAL` | (Optional) How many RGB lights are connected to second RGB driver | |
  208. | `DRIVER_COUNT` | (Required) How many RGB driver IC's are present | |
  209. | `DRIVER_LED_TOTAL` | (Required) How many RGB lights are present across all drivers | |
  210. | `AW_SCALING_MAX` | (Optional) LED current scaling value (0-255, higher values mean LED is brighter at full PWM) | 150 |
  211. | `AW_GLOBAL_CURRENT_MAX` | (Optional) Driver global current limit (0-255, higher values means the driver may consume more power) | 150 |
  212. | `AW_SPI_DIVISOR` | (Optional) Clock divisor for SPI communication (powers of 2, smaller numbers means faster communication, should not be less than 4) | 4 |
  213. Here is an example using 2 drivers.
  214. ```c
  215. #define DRIVER_1_CS B13
  216. #define DRIVER_2_CS B14
  217. // Hardware enable lines may be connected to the same pin
  218. #define DRIVER_1_EN C13
  219. #define DRIVER_2_EN C13
  220. #define DRIVER_COUNT 2
  221. #define DRIVER_1_LED_TOTAL 66
  222. #define DRIVER_2_LED_TOTAL 32
  223. #define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
  224. ```
  225. !> Note the parentheses, this is so when `DRIVER_LED_TOTAL` is used in code and expanded, the values are added together before any additional math is applied to them. As an example, `rand() % (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)` will give very different results than `rand() % DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL`.
  226. Define these arrays listing all the LEDs in your `<keyboard>.c`:
  227. ```c
  228. const aw_led __flash g_aw_leds[DRIVER_LED_TOTAL] = {
  229. /* Each AW20216 channel is controlled by a register at some offset between 0x00
  230. * and 0xD7 inclusive.
  231. * See drivers/awinic/aw20216.h for the mapping between register offsets and
  232. * driver pin locations.
  233. * driver
  234. * | R location
  235. * | | G location
  236. * | | | B location
  237. * | | | | */
  238. { 0, CS1_SW1, CS2_SW1, CS3_SW1 },
  239. { 0, CS4_SW1, CS5_SW1, CS6_SW1 },
  240. { 0, CS7_SW1, CS8_SW1, CS9_SW1 },
  241. { 0, CS10_SW1, CS11_SW1, CS12_SW1 },
  242. { 0, CS13_SW1, CS14_SW1, CS15_SW1 },
  243. ...
  244. { 1, CS1_SW1, CS2_SW1, CS3_SW1 },
  245. { 1, CS13_SW1, CS14_SW1, CS15_SW1 },
  246. { 1, CS16_SW1, CS17_SW1, CS18_SW1 },
  247. { 1, CS4_SW2, CS5_SW2, CS6_SW2 },
  248. ...
  249. };
  250. ```
  251. ---
  252. ## Common Configuration :id=common-configuration
  253. From this point forward the configuration is the same for all the drivers. The `led_config_t` struct provides a key electrical matrix to led index lookup table, what the physical position of each LED is on the board, and what type of key or usage the LED if the LED represents. Here is a brief example:
  254. ```c
  255. led_config_t g_led_config = { {
  256. // Key Matrix to LED Index
  257. { 5, NO_LED, NO_LED, 0 },
  258. { NO_LED, NO_LED, NO_LED, NO_LED },
  259. { 4, NO_LED, NO_LED, 1 },
  260. { 3, NO_LED, NO_LED, 2 }
  261. }, {
  262. // LED Index to Physical Position
  263. { 188, 16 }, { 187, 48 }, { 149, 64 }, { 112, 64 }, { 37, 48 }, { 38, 16 }
  264. }, {
  265. // LED Index to Flag
  266. 1, 4, 4, 4, 4, 1
  267. } };
  268. ```
  269. The first part, `// Key Matrix to LED Index`, tells the system what key this LED represents by using the key's electrical matrix row & col. The second part, `// LED Index to Physical Position` represents the LED's physical `{ x, y }` position on the keyboard. The default expected range of values for `{ x, y }` is the inclusive range `{ 0..224, 0..64 }`. This default expected range is due to effects that calculate the center of the keyboard for their animations. The easiest way to calculate these positions is imagine your keyboard is a grid, and the top left of the keyboard represents `{ x, y }` coordinate `{ 0, 0 }` and the bottom right of your keyboard represents `{ 224, 64 }`. Using this as a basis, you can use the following formula to calculate the physical position:
  270. ```c
  271. x = 224 / (NUMBER_OF_COLS - 1) * COL_POSITION
  272. y = 64 / (NUMBER_OF_ROWS - 1) * ROW_POSITION
  273. ```
  274. Where NUMBER_OF_COLS, NUMBER_OF_ROWS, COL_POSITION, & ROW_POSITION are all based on the physical layout of your keyboard, not the electrical layout.
  275. As mentioned earlier, the center of the keyboard by default is expected to be `{ 112, 32 }`, but this can be changed if you want to more accurately calculate the LED's physical `{ x, y }` positions. Keyboard designers can implement `#define RGB_MATRIX_CENTER { 112, 32 }` in their config.h file with the new center point of the keyboard, or where they want it to be allowing more possibilities for the `{ x, y }` values. Do note that the maximum value for x or y is 255, and the recommended maximum is 224 as this gives animations runoff room before they reset.
  276. `// LED Index to Flag` is a bitmask, whether or not a certain LEDs is of a certain type. It is recommended that LEDs are set to only 1 type.
  277. ## Flags :id=flags
  278. |Define |Value |Description |
  279. |----------------------------|------|-------------------------------------------------|
  280. |`HAS_FLAGS(bits, flags)` |*n/a* |Evaluates to `true` if `bits` has all `flags` set|
  281. |`HAS_ANY_FLAGS(bits, flags)`|*n/a* |Evaluates to `true` if `bits` has any `flags` set|
  282. |`LED_FLAG_NONE` |`0x00`|If this LED has no flags |
  283. |`LED_FLAG_ALL` |`0xFF`|If this LED has all flags |
  284. |`LED_FLAG_MODIFIER` |`0x01`|If the LED is on a modifier key |
  285. |`LED_FLAG_UNDERGLOW` |`0x02`|If the LED is for underglow |
  286. |`LED_FLAG_KEYLIGHT` |`0x04`|If the LED is for key backlight |
  287. |`LED_FLAG_INDICATOR` |`0x08`|If the LED is for keyboard state indication |
  288. ## Keycodes :id=keycodes
  289. All RGB keycodes are currently shared with the RGBLIGHT system:
  290. |Key |Aliases |Description |
  291. |-------------------|----------|--------------------------------------------------------------------------------------|
  292. |`RGB_TOG` | |Toggle RGB lighting on or off |
  293. |`RGB_MODE_FORWARD` |`RGB_MOD` |Cycle through modes, reverse direction when Shift is held |
  294. |`RGB_MODE_REVERSE` |`RGB_RMOD`|Cycle through modes in reverse, forward direction when Shift is held |
  295. |`RGB_HUI` | |Increase hue, decrease hue when Shift is held |
  296. |`RGB_HUD` | |Decrease hue, increase hue when Shift is held |
  297. |`RGB_SAI` | |Increase saturation, decrease saturation when Shift is held |
  298. |`RGB_SAD` | |Decrease saturation, increase saturation when Shift is held |
  299. |`RGB_VAI` | |Increase value (brightness), decrease value when Shift is held |
  300. |`RGB_VAD` | |Decrease value (brightness), increase value when Shift is held |
  301. |`RGB_SPI` | |Increase effect speed (does not support eeprom yet), decrease speed when Shift is held|
  302. |`RGB_SPD` | |Decrease effect speed (does not support eeprom yet), increase speed when Shift is held|
  303. |`RGB_MODE_PLAIN` |`RGB_M_P `|Static (no animation) mode |
  304. |`RGB_MODE_BREATHE` |`RGB_M_B` |Breathing animation mode |
  305. |`RGB_MODE_RAINBOW` |`RGB_M_R` |Full gradient scrolling left to right (uses the `RGB_MATRIX_CYCLE_LEFT_RIGHT` mode) |
  306. |`RGB_MODE_SWIRL` |`RGB_M_SW`|Full gradient spinning pinwheel around center of keyboard (uses `RGB_MATRIX_CYCLE_PINWHEEL` mode) |
  307. * `RGB_MODE_*` keycodes will generally work, but not all of the modes are currently mapped to the correct effects for the RGB Matrix system.
  308. `RGB_MODE_PLAIN`, `RGB_MODE_BREATHE`, `RGB_MODE_RAINBOW`, and `RGB_MATRIX_SWIRL` are the only ones that are mapped properly. The rest don't have a direct equivalent, and are not mapped.
  309. !> By default, if you have both the [RGB Light](feature_rgblight.md) and the RGB Matrix feature enabled, these keycodes will work for both features, at the same time. You can disable the keycode functionality by defining the `*_DISABLE_KEYCODES` option for the specific feature.
  310. ## RGB Matrix Effects :id=rgb-matrix-effects
  311. All effects have been configured to support current configuration values (Hue, Saturation, Value, & Speed) unless otherwise noted below. These are the effects that are currently available:
  312. ```c
  313. enum rgb_matrix_effects {
  314. RGB_MATRIX_NONE = 0,
  315. RGB_MATRIX_SOLID_COLOR = 1, // Static single hue, no speed support
  316. RGB_MATRIX_ALPHAS_MODS, // Static dual hue, speed is hue for secondary hue
  317. RGB_MATRIX_GRADIENT_UP_DOWN, // Static gradient top to bottom, speed controls how much gradient changes
  318. RGB_MATRIX_GRADIENT_LEFT_RIGHT, // Static gradient left to right, speed controls how much gradient changes
  319. RGB_MATRIX_BREATHING, // Single hue brightness cycling animation
  320. RGB_MATRIX_BAND_SAT, // Single hue band fading saturation scrolling left to right
  321. RGB_MATRIX_BAND_VAL, // Single hue band fading brightness scrolling left to right
  322. RGB_MATRIX_BAND_PINWHEEL_SAT, // Single hue 3 blade spinning pinwheel fades saturation
  323. RGB_MATRIX_BAND_PINWHEEL_VAL, // Single hue 3 blade spinning pinwheel fades brightness
  324. RGB_MATRIX_BAND_SPIRAL_SAT, // Single hue spinning spiral fades saturation
  325. RGB_MATRIX_BAND_SPIRAL_VAL, // Single hue spinning spiral fades brightness
  326. RGB_MATRIX_CYCLE_ALL, // Full keyboard solid hue cycling through full gradient
  327. RGB_MATRIX_CYCLE_LEFT_RIGHT, // Full gradient scrolling left to right
  328. RGB_MATRIX_CYCLE_UP_DOWN, // Full gradient scrolling top to bottom
  329. RGB_MATRIX_CYCLE_OUT_IN, // Full gradient scrolling out to in
  330. RGB_MATRIX_CYCLE_OUT_IN_DUAL, // Full dual gradients scrolling out to in
  331. RGB_MATRIX_RAINBOW_MOVING_CHEVRON, // Full gradent Chevron shapped scrolling left to right
  332. RGB_MATRIX_CYCLE_PINWHEEL, // Full gradient spinning pinwheel around center of keyboard
  333. RGB_MATRIX_CYCLE_SPIRAL, // Full gradient spinning spiral around center of keyboard
  334. RGB_MATRIX_DUAL_BEACON, // Full gradient spinning around center of keyboard
  335. RGB_MATRIX_RAINBOW_BEACON, // Full tighter gradient spinning around center of keyboard
  336. RGB_MATRIX_RAINBOW_PINWHEELS, // Full dual gradients spinning two halfs of keyboard
  337. RGB_MATRIX_RAINDROPS, // Randomly changes a single key's hue
  338. RGB_MATRIX_JELLYBEAN_RAINDROPS, // Randomly changes a single key's hue and saturation
  339. RGB_MATRIX_HUE_BREATHING, // Hue shifts up a slight ammount at the same time, then shifts back
  340. RGB_MATRIX_HUE_PENDULUM, // Hue shifts up a slight ammount in a wave to the right, then back to the left
  341. RGB_MATRIX_HUE_WAVE, // Hue shifts up a slight ammount and then back down in a wave to the right
  342. #if define(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
  343. RGB_MATRIX_TYPING_HEATMAP, // How hot is your WPM!
  344. RGB_MATRIX_DIGITAL_RAIN, // That famous computer simulation
  345. #endif
  346. #if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES)
  347. RGB_MATRIX_SOLID_REACTIVE_SIMPLE, // Pulses keys hit to hue & value then fades value out
  348. RGB_MATRIX_SOLID_REACTIVE, // Static single hue, pulses keys hit to shifted hue then fades to current hue
  349. RGB_MATRIX_SOLID_REACTIVE_WIDE // Hue & value pulse near a single key hit then fades value out
  350. RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE // Hue & value pulse near multiple key hits then fades value out
  351. RGB_MATRIX_SOLID_REACTIVE_CROSS // Hue & value pulse the same column and row of a single key hit then fades value out
  352. RGB_MATRIX_SOLID_REACTIVE_MULTICROSS // Hue & value pulse the same column and row of multiple key hits then fades value out
  353. RGB_MATRIX_SOLID_REACTIVE_NEXUS // Hue & value pulse away on the same column and row of a single key hit then fades value out
  354. RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS // Hue & value pulse away on the same column and row of multiple key hits then fades value out
  355. RGB_MATRIX_SPLASH, // Full gradient & value pulse away from a single key hit then fades value out
  356. RGB_MATRIX_MULTISPLASH, // Full gradient & value pulse away from multiple key hits then fades value out
  357. RGB_MATRIX_SOLID_SPLASH, // Hue & value pulse away from a single key hit then fades value out
  358. RGB_MATRIX_SOLID_MULTISPLASH, // Hue & value pulse away from multiple key hits then fades value out
  359. #endif
  360. RGB_MATRIX_EFFECT_MAX
  361. };
  362. ```
  363. You can disable a single effect by defining `DISABLE_[EFFECT_NAME]` in your `config.h`:
  364. |Define |Description |
  365. |-------------------------------------------------------|-----------------------------------------------|
  366. |`#define DISABLE_RGB_MATRIX_ALPHAS_MODS` |Disables `RGB_MATRIX_ALPHAS_MODS` |
  367. |`#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN` |Disables `RGB_MATRIX_GRADIENT_UP_DOWN` |
  368. |`#define DISABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT` |Disables `MATRIX_GRADIENT_LEFT_RIGHT` |
  369. |`#define DISABLE_RGB_MATRIX_BREATHING` |Disables `RGB_MATRIX_BREATHING` |
  370. |`#define DISABLE_RGB_MATRIX_BAND_SAT` |Disables `RGB_MATRIX_BAND_SAT` |
  371. |`#define DISABLE_RGB_MATRIX_BAND_VAL` |Disables `RGB_MATRIX_BAND_VAL` |
  372. |`#define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT` |Disables `RGB_MATRIX_BAND_PINWHEEL_SAT` |
  373. |`#define DISABLE_RGB_MATRIX_BAND_PINWHEEL_VAL` |Disables `RGB_MATRIX_BAND_PINWHEEL_VAL` |
  374. |`#define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT` |Disables `RGB_MATRIX_BAND_SPIRAL_SAT` |
  375. |`#define DISABLE_RGB_MATRIX_BAND_SPIRAL_VAL` |Disables `RGB_MATRIX_BAND_SPIRAL_VAL` |
  376. |`#define DISABLE_RGB_MATRIX_CYCLE_ALL` |Disables `RGB_MATRIX_CYCLE_ALL` |
  377. |`#define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT` |Disables `RGB_MATRIX_CYCLE_LEFT_RIGHT` |
  378. |`#define DISABLE_RGB_MATRIX_CYCLE_UP_DOWN` |Disables `RGB_MATRIX_CYCLE_UP_DOWN` |
  379. |`#define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON` |Disables `RGB_MATRIX_RAINBOW_MOVING_CHEVRON` |
  380. |`#define DISABLE_RGB_MATRIX_CYCLE_OUT_IN` |Disables `RGB_MATRIX_CYCLE_OUT_IN` |
  381. |`#define DISABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL` |Disables `RGB_MATRIX_CYCLE_OUT_IN_DUAL` |
  382. |`#define DISABLE_RGB_MATRIX_CYCLE_PINWHEEL` |Disables `RGB_MATRIX_CYCLE_PINWHEEL` |
  383. |`#define DISABLE_RGB_MATRIX_CYCLE_SPIRAL` |Disables `RGB_MATRIX_CYCLE_SPIRAL` |
  384. |`#define DISABLE_RGB_MATRIX_DUAL_BEACON` |Disables `RGB_MATRIX_DUAL_BEACON` |
  385. |`#define DISABLE_RGB_MATRIX_RAINBOW_BEACON` |Disables `RGB_MATRIX_RAINBOW_BEACON` |
  386. |`#define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS` |Disables `RGB_MATRIX_RAINBOW_PINWHEELS` |
  387. |`#define DISABLE_RGB_MATRIX_RAINDROPS` |Disables `RGB_MATRIX_RAINDROPS` |
  388. |`#define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS` |Disables `RGB_MATRIX_JELLYBEAN_RAINDROPS` |
  389. |`#define DISABLE_RGB_MATRIX_HUE_BREATHING` |Disables `RGB_MATRIX_HUE_BREATHING` |
  390. |`#define DISABLE_RGB_MATRIX_HUE_PENDULUM` |Disables `RGB_MATRIX_HUE_PENDULUM` |
  391. |`#define DISABLE_RGB_MATRIX_HUE_WAVE ` |Disables `RGB_MATRIX_HUE_WAVE ` |
  392. |`#define DISABLE_RGB_MATRIX_TYPING_HEATMAP` |Disables `RGB_MATRIX_TYPING_HEATMAP` |
  393. |`#define DISABLE_RGB_MATRIX_DIGITAL_RAIN` |Disables `RGB_MATRIX_DIGITAL_RAIN` |
  394. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE` |Disables `RGB_MATRIX_SOLID_REACTIVE_SIMPLE` |
  395. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE` |Disables `RGB_MATRIX_SOLID_REACTIVE` |
  396. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE` |Disables `RGB_MATRIX_SOLID_REACTIVE_WIDE` |
  397. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE` |Disables `RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE` |
  398. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS` |Disables `RGB_MATRIX_SOLID_REACTIVE_CROSS` |
  399. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS` |Disables `RGB_MATRIX_SOLID_REACTIVE_MULTICROSS`|
  400. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS` |Disables `RGB_MATRIX_SOLID_REACTIVE_NEXUS` |
  401. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS` |Disables `RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS`|
  402. |`#define DISABLE_RGB_MATRIX_SPLASH` |Disables `RGB_MATRIX_SPLASH` |
  403. |`#define DISABLE_RGB_MATRIX_MULTISPLASH` |Disables `RGB_MATRIX_MULTISPLASH` |
  404. |`#define DISABLE_RGB_MATRIX_SOLID_SPLASH` |Disables `RGB_MATRIX_SOLID_SPLASH` |
  405. |`#define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH` |Disables `RGB_MATRIX_SOLID_MULTISPLASH` |
  406. ### RGB Matrix Effect Typing Heatmap :id=rgb-matrix-effect-typing-heatmap
  407. This effect will color the RGB matrix according to a heatmap of recently pressed
  408. keys. Whenever a key is pressed its "temperature" increases as well as that of
  409. its neighboring keys. The temperature of each key is then decreased
  410. automatically every 25 milliseconds by default.
  411. In order to change the delay of temperature decrease define
  412. `RGB_MATRIX_TYPING_HEATMAP_DECREASE_DELAY_MS`:
  413. ```c
  414. #define RGB_MATRIX_TYPING_HEATMAP_DECREASE_DELAY_MS 50
  415. ```
  416. ## Custom RGB Matrix Effects :id=custom-rgb-matrix-effects
  417. By setting `RGB_MATRIX_CUSTOM_USER` (and/or `RGB_MATRIX_CUSTOM_KB`) in `rules.mk`, new effects can be defined directly from userspace, without having to edit any QMK core files.
  418. To declare new effects, create a new `rgb_matrix_user/kb.inc` that looks something like this:
  419. `rgb_matrix_user.inc` should go in the root of the keymap directory.
  420. `rgb_matrix_kb.inc` should go in the root of the keyboard directory.
  421. To use custom effects in your code, simply prepend `RGB_MATRIX_CUSTOM_` to the effect name specified in `RGB_MATRIX_EFFECT()`. For example, an effect declared as `RGB_MATRIX_EFFECT(my_cool_effect)` would be referenced with:
  422. ```c
  423. rgb_matrix_mode(RGB_MATRIX_CUSTOM_my_cool_effect);
  424. ```
  425. ```c
  426. // !!! DO NOT ADD #pragma once !!! //
  427. // Step 1.
  428. // Declare custom effects using the RGB_MATRIX_EFFECT macro
  429. // (note the lack of semicolon after the macro!)
  430. RGB_MATRIX_EFFECT(my_cool_effect)
  431. RGB_MATRIX_EFFECT(my_cool_effect2)
  432. // Step 2.
  433. // Define effects inside the `RGB_MATRIX_CUSTOM_EFFECT_IMPLS` ifdef block
  434. #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
  435. // e.g: A simple effect, self-contained within a single method
  436. static bool my_cool_effect(effect_params_t* params) {
  437. RGB_MATRIX_USE_LIMITS(led_min, led_max);
  438. for (uint8_t i = led_min; i < led_max; i++) {
  439. rgb_matrix_set_color(i, 0xff, 0xff, 0x00);
  440. }
  441. return led_max < DRIVER_LED_TOTAL;
  442. }
  443. // e.g: A more complex effect, relying on external methods and state, with
  444. // dedicated init and run methods
  445. static uint8_t some_global_state;
  446. static void my_cool_effect2_complex_init(effect_params_t* params) {
  447. some_global_state = 1;
  448. }
  449. static bool my_cool_effect2_complex_run(effect_params_t* params) {
  450. RGB_MATRIX_USE_LIMITS(led_min, led_max);
  451. for (uint8_t i = led_min; i < led_max; i++) {
  452. rgb_matrix_set_color(i, 0xff, some_global_state++, 0xff);
  453. }
  454. return led_max < DRIVER_LED_TOTAL;
  455. }
  456. static bool my_cool_effect2(effect_params_t* params) {
  457. if (params->init) my_cool_effect2_complex_init(params);
  458. return my_cool_effect2_complex_run(params);
  459. }
  460. #endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
  461. ```
  462. For inspiration and examples, check out the built-in effects under `quantum/rgb_matrix/animations/`.
  463. ## Colors :id=colors
  464. These are shorthands to popular colors. The `RGB` ones can be passed to the `setrgb` functions, while the `HSV` ones to the `sethsv` functions.
  465. |RGB |HSV |
  466. |---------------------|---------------------|
  467. |`RGB_AZURE` |`HSV_AZURE` |
  468. |`RGB_BLACK`/`RGB_OFF`|`HSV_BLACK`/`HSV_OFF`|
  469. |`RGB_BLUE` |`HSV_BLUE` |
  470. |`RGB_CHARTREUSE` |`HSV_CHARTREUSE` |
  471. |`RGB_CORAL` |`HSV_CORAL` |
  472. |`RGB_CYAN` |`HSV_CYAN` |
  473. |`RGB_GOLD` |`HSV_GOLD` |
  474. |`RGB_GOLDENROD` |`HSV_GOLDENROD` |
  475. |`RGB_GREEN` |`HSV_GREEN` |
  476. |`RGB_MAGENTA` |`HSV_MAGENTA` |
  477. |`RGB_ORANGE` |`HSV_ORANGE` |
  478. |`RGB_PINK` |`HSV_PINK` |
  479. |`RGB_PURPLE` |`HSV_PURPLE` |
  480. |`RGB_RED` |`HSV_RED` |
  481. |`RGB_SPRINGGREEN` |`HSV_SPRINGGREEN` |
  482. |`RGB_TEAL` |`HSV_TEAL` |
  483. |`RGB_TURQUOISE` |`HSV_TURQUOISE` |
  484. |`RGB_WHITE` |`HSV_WHITE` |
  485. |`RGB_YELLOW` |`HSV_YELLOW` |
  486. These are defined in [`color.h`](https://github.com/qmk/qmk_firmware/blob/master/quantum/color.h). Feel free to add to this list!
  487. ## Additional `config.h` Options :id=additional-configh-options
  488. ```c
  489. #define RGB_MATRIX_KEYPRESSES // reacts to keypresses
  490. #define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
  491. #define RGB_MATRIX_FRAMEBUFFER_EFFECTS // enable framebuffer effects
  492. #define RGB_DISABLE_TIMEOUT 0 // number of milliseconds to wait until rgb automatically turns off
  493. #define RGB_DISABLE_AFTER_TIMEOUT 0 // OBSOLETE: number of ticks to wait until disabling effects
  494. #define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
  495. #define RGB_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5 // limits the number of LEDs to process in an animation per task run (increases keyboard responsiveness)
  496. #define RGB_MATRIX_LED_FLUSH_LIMIT 16 // limits in milliseconds how frequently an animation will update the LEDs. 16 (16ms) is equivalent to limiting to 60fps (increases keyboard responsiveness)
  497. #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255
  498. #define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT // Sets the default mode, if none has been set
  499. #define RGB_MATRIX_STARTUP_HUE 0 // Sets the default hue value, if none has been set
  500. #define RGB_MATRIX_STARTUP_SAT 255 // Sets the default saturation value, if none has been set
  501. #define RGB_MATRIX_STARTUP_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS // Sets the default brightness value, if none has been set
  502. #define RGB_MATRIX_STARTUP_SPD 127 // Sets the default animation speed, if none has been set
  503. #define RGB_MATRIX_DISABLE_KEYCODES // disables control of rgb matrix by keycodes (must use code functions to control the feature)
  504. #define RGB_MATRIX_SPLIT { X, Y } // (Optional) For split keyboards, the number of LEDs connected on each half. X = left, Y = Right.
  505. // If RGB_MATRIX_KEYPRESSES or RGB_MATRIX_KEYRELEASES is enabled, you also will want to enable SPLIT_TRANSPORT_MIRROR
  506. ```
  507. ## EEPROM storage :id=eeprom-storage
  508. The EEPROM for it is currently shared with the LED Matrix system (it's generally assumed only one feature would be used at a time), but could be configured to use its own 32bit address with:
  509. ```c
  510. #define EECONFIG_RGB_MATRIX (uint32_t *)28
  511. ```
  512. Where `28` is an unused index from `eeconfig.h`.
  513. ## Functions :id=functions
  514. ### Direct Operation :id=direct-operation
  515. |Function |Description |
  516. |--------------------------------------------|-------------|
  517. |`rgb_matrix_set_color_all(r, g, b)` |Set all of the LEDs to the given RGB value, where `r`/`g`/`b` are between 0 and 255 (not written to EEPROM) |
  518. |`rgb_matrix_set_color(index, r, g, b)` |Set a single LED to the given RGB value, where `r`/`g`/`b` are between 0 and 255, and `index` is between 0 and `DRIVER_LED_TOTAL` (not written to EEPROM) |
  519. ### Disable/Enable Effects :id=disable-enable-effects
  520. |Function |Description |
  521. |--------------------------------------------|-------------|
  522. |`rgb_matrix_toggle()` |Toggle effect range LEDs between on and off |
  523. |`rgb_matrix_toggle_noeeprom()` |Toggle effect range LEDs between on and off (not written to EEPROM) |
  524. |`rgb_matrix_enable()` |Turn effect range LEDs on, based on their previous state |
  525. |`rgb_matrix_enable_noeeprom()` |Turn effect range LEDs on, based on their previous state (not written to EEPROM) |
  526. |`rgb_matrix_disable()` |Turn effect range LEDs off, based on their previous state |
  527. |`rgb_matrix_disable_noeeprom()` |Turn effect range LEDs off, based on their previous state (not written to EEPROM) |
  528. ### Change Effect Mode :id=change-effect-mode
  529. |Function |Description |
  530. |--------------------------------------------|-------------|
  531. |`rgb_matrix_mode(mode)` |Set the mode, if RGB animations are enabled |
  532. |`rgb_matrix_mode_noeeprom(mode)` |Set the mode, if RGB animations are enabled (not written to EEPROM) |
  533. |`rgb_matrix_step()` |Change the mode to the next RGB animation in the list of enabled RGB animations |
  534. |`rgb_matrix_step_noeeprom()` |Change the mode to the next RGB animation in the list of enabled RGB animations (not written to EEPROM) |
  535. |`rgb_matrix_step_reverse()` |Change the mode to the previous RGB animation in the list of enabled RGB animations |
  536. |`rgb_matrix_step_reverse_noeeprom()` |Change the mode to the previous RGB animation in the list of enabled RGB animations (not written to EEPROM) |
  537. |`rgb_matrix_increase_speed()` |Increase the speed of the animations |
  538. |`rgb_matrix_increase_speed_noeeprom()` |Increase the speed of the animations (not written to EEPROM) |
  539. |`rgb_matrix_decrease_speed()` |Decrease the speed of the animations |
  540. |`rgb_matrix_decrease_speed_noeeprom()` |Decrease the speed of the animations (not written to EEPROM) |
  541. |`rgb_matrix_set_speed(speed)` |Set the speed of the animations to the given value where `speed` is between 0 and 255 |
  542. |`rgb_matrix_set_speed_noeeprom(speed)` |Set the speed of the animations to the given value where `speed` is between 0 and 255 (not written to EEPROM) |
  543. ### Change Color :id=change-color
  544. |Function |Description |
  545. |--------------------------------------------|-------------|
  546. |`rgb_matrix_increase_hue()` |Increase the hue for effect range LEDs. This wraps around at maximum hue |
  547. |`rgb_matrix_increase_hue_noeeprom()` |Increase the hue for effect range LEDs. This wraps around at maximum hue (not written to EEPROM) |
  548. |`rgb_matrix_decrease_hue()` |Decrease the hue for effect range LEDs. This wraps around at minimum hue |
  549. |`rgb_matrix_decrease_hue_noeeprom()` |Decrease the hue for effect range LEDs. This wraps around at minimum hue (not written to EEPROM) |
  550. |`rgb_matrix_increase_sat()` |Increase the saturation for effect range LEDs. This wraps around at maximum saturation |
  551. |`rgb_matrix_increase_sat_noeeprom()` |Increase the saturation for effect range LEDs. This wraps around at maximum saturation (not written to EEPROM) |
  552. |`rgb_matrix_decrease_sat()` |Decrease the saturation for effect range LEDs. This wraps around at minimum saturation |
  553. |`rgb_matrix_decrease_sat_noeeprom()` |Decrease the saturation for effect range LEDs. This wraps around at minimum saturation (not written to EEPROM) |
  554. |`rgb_matrix_increase_val()` |Increase the value for effect range LEDs. This wraps around at maximum value |
  555. |`rgb_matrix_increase_val_noeeprom()` |Increase the value for effect range LEDs. This wraps around at maximum value (not written to EEPROM) |
  556. |`rgb_matrix_decrease_val()` |Decrease the value for effect range LEDs. This wraps around at minimum value |
  557. |`rgb_matrix_decrease_val_noeeprom()` |Decrease the value for effect range LEDs. This wraps around at minimum value (not written to EEPROM) |
  558. |`rgb_matrix_sethsv(h, s, v)` |Set LEDs to the given HSV value where `h`/`s`/`v` are between 0 and 255 |
  559. |`rgb_matrix_sethsv_noeeprom(h, s, v)` |Set LEDs to the given HSV value where `h`/`s`/`v` are between 0 and 255 (not written to EEPROM) |
  560. ### Query Current Status :id=query-current-status
  561. |Function |Description |
  562. |---------------------------------|---------------------------|
  563. |`rgb_matrix_is_enabled()` |Gets current on/off status |
  564. |`rgb_matrix_get_mode()` |Gets current mode |
  565. |`rgb_matrix_get_hue()` |Gets current hue |
  566. |`rgb_matrix_get_sat()` |Gets current sat |
  567. |`rgb_matrix_get_val()` |Gets current val |
  568. |`rgb_matrix_get_hsv()` |Gets hue, sat, and val and returns a [`HSV` structure](https://github.com/qmk/qmk_firmware/blob/7ba6456c0b2e041bb9f97dbed265c5b8b4b12192/quantum/color.h#L56-L61)|
  569. |`rgb_matrix_get_speed()` |Gets current speed |
  570. |`rgb_matrix_get_suspend_state()` |Gets current suspend state |
  571. ## Callbacks :id=callbacks
  572. ### Indicators :id=indicators
  573. If you want to set custom indicators, such as an LED for Caps Lock, or layer indication, you can use the `rgb_matrix_indicators_kb` or `rgb_matrix_indicators_user` function for that:
  574. ```c
  575. void rgb_matrix_indicators_kb(void) {
  576. rgb_matrix_set_color(index, red, green, blue);
  577. }
  578. ```
  579. In addition, there are the advanced indicator functions. These are aimed at those with heavily customized displays, where rendering every LED per cycle is expensive. Such as some of the "drashna" layouts. This includes a special macro to help make this easier to use: `RGB_MATRIX_INDICATOR_SET_COLOR(i, r, g, b)`.
  580. ```c
  581. void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
  582. RGB_MATRIX_INDICATOR_SET_COLOR(index, red, green, blue);
  583. }
  584. ```
  585. ### Indicator Examples :id=indicator-examples
  586. Caps Lock indicator on alphanumeric flagged keys:
  587. ```c
  588. void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
  589. if (host_keyboard_led_state().caps_lock) {
  590. for (uint8_t i = led_min; i <= led_max; i++) {
  591. if (g_led_config.flags[i] & LED_FLAG_KEYLIGHT) {
  592. rgb_matrix_set_color(i, RGB_RED);
  593. }
  594. }
  595. }
  596. }
  597. ```
  598. Layer indicator on all flagged keys:
  599. ```c
  600. void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
  601. for (uint8_t i = led_min; i <= led_max; i++) {
  602. switch(get_highest_layer(layer_state|default_layer_state)) {
  603. case RAISE:
  604. rgb_matrix_set_color(i, RGB_BLUE);
  605. break;
  606. case LOWER:
  607. rgb_matrix_set_color(i, RGB_YELLOW);
  608. break;
  609. default:
  610. break;
  611. }
  612. }
  613. }
  614. ```
  615. #### Examples :id=indicator-examples
  616. This example sets the modifiers to be a specific color based on the layer state. You can use a switch case here, instead, if you would like. This uses HSV and then converts to RGB, because this allows the brightness to be limited (important when using the WS2812 driver).
  617. ```c
  618. void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
  619. HSV hsv = {0, 255, 255};
  620. if (layer_state_is(layer_state, 2)) {
  621. hsv = {130, 255, 255};
  622. } else {
  623. hsv = {30, 255, 255};
  624. }
  625. if (hsv.v > rgb_matrix_get_val()) {
  626. hsv.v = rgb_matrix_get_val();
  627. }
  628. RGB rgb = hsv_to_rgb(hsv);
  629. for (uint8_t i = led_min; i <= led_max; i++) {
  630. if (HAS_FLAGS(g_led_config.flags[i], 0x01)) { // 0x01 == LED_FLAG_MODIFIER
  631. rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
  632. }
  633. }
  634. }
  635. ```
  636. If you want to indicate a Host LED status (caps lock, num lock, etc), you can use something like this to light up the caps lock key:
  637. ```c
  638. void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
  639. if (host_keyboard_led_state().caps_lock) {
  640. RGB_MATRIX_INDICATOR_SET_COLOR(5, 255, 255, 255); // assuming caps lock is at led #5
  641. } else {
  642. RGB_MATRIX_INDICATOR_SET_COLOR(5, 0, 0, 0);
  643. }
  644. }
  645. ```