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.

722 lines
40 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 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/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 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/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. Configure the hardware via your `config.h`:
  119. ```c
  120. // This is a 7-bit address, that gets left-shifted and bit 0
  121. // set to 0 for write, 1 for read (as per I2C protocol)
  122. // The address will vary depending on your wiring:
  123. // 0000 <-> GND
  124. // 0101 <-> SCL
  125. // 1010 <-> SDA
  126. // 1111 <-> VCC
  127. // ADDR represents A3:A0 of the 7-bit address.
  128. // The result is: 0b101(ADDR)
  129. #define DRIVER_ADDR_1 0b1010000
  130. #define DRIVER_ADDR_2 0b1010000 // this is here for compliancy reasons.
  131. #define DRIVER_COUNT 2
  132. #define DRIVER_1_LED_TOTAL 64
  133. #define DRIVER_LED_TOTAL DRIVER_1_LED_TOTAL
  134. ```
  135. Currently only a single drivers is supported, but it would be trivial to support all 4 combinations. For now define `DRIVER_ADDR_2` as `DRIVER_ADDR_1`
  136. Define these arrays listing all the LEDs in your `<keyboard>.c`:
  137. ```c
  138. const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
  139. /* Refer to IS31 manual for these locations
  140. * driver
  141. * | R location
  142. * | | G location
  143. * | | | B location
  144. * | | | | */
  145. {0, B_1, A_1, C_1},
  146. ....
  147. }
  148. ```
  149. 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/issi/is31fl3737.h`. The `driver` is the index of the driver you defined in your `config.h` (Only `0` right now).
  150. ---
  151. ### WS2812 :id=ws2812
  152. 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`:
  153. ```makefile
  154. RGB_MATRIX_ENABLE = yes
  155. RGB_MATRIX_DRIVER = WS2812
  156. ```
  157. Configure the hardware via your `config.h`:
  158. ```c
  159. // The pin connected to the data pin of the LEDs
  160. #define RGB_DI_PIN D7
  161. // The number of LEDs connected
  162. #define DRIVER_LED_TOTAL 70
  163. ```
  164. ---
  165. ### APA102 :id=apa102
  166. There is basic support for APA102 based addressable LED strands. To enable it, add this to your `rules.mk`:
  167. ```makefile
  168. RGB_MATRIX_ENABLE = yes
  169. RGB_MATRIX_DRIVER = APA102
  170. ```
  171. Configure the hardware via your `config.h`:
  172. ```c
  173. // The pin connected to the data pin of the LEDs
  174. #define RGB_DI_PIN D7
  175. // The pin connected to the clock pin of the LEDs
  176. #define RGB_CI_PIN D6
  177. // The number of LEDs connected
  178. #define DRIVER_LED_TOTAL 70
  179. ```
  180. ---
  181. ### AW20216 :id=aw20216
  182. There is basic support for addressable RGB matrix lighting with the SPI AW20216 RGB controller. To enable it, add this to your `rules.mk`:
  183. ```makefile
  184. RGB_MATRIX_ENABLE = yes
  185. RGB_MATRIX_DRIVER = AW20216
  186. ```
  187. 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`:
  188. | Variable | Description | Default |
  189. |----------|-------------|---------|
  190. | `DRIVER_1_CS` | (Required) MCU pin connected to first RGB driver chip select line | B13 |
  191. | `DRIVER_2_CS` | (Optional) MCU pin connected to second RGB driver chip select line | |
  192. | `DRIVER_1_EN` | (Required) MCU pin connected to first RGB driver hardware enable line | C13 |
  193. | `DRIVER_2_EN` | (Optional) MCU pin connected to second RGB driver hardware enable line | |
  194. | `DRIVER_1_LED_TOTAL` | (Required) How many RGB lights are connected to first RGB driver | |
  195. | `DRIVER_2_LED_TOTAL` | (Optional) How many RGB lights are connected to second RGB driver | |
  196. | `DRIVER_COUNT` | (Required) How many RGB driver IC's are present | |
  197. | `DRIVER_LED_TOTAL` | (Required) How many RGB lights are present across all drivers | |
  198. | `AW_SCALING_MAX` | (Optional) LED current scaling value (0-255, higher values mean LED is brighter at full PWM) | 150 |
  199. | `AW_GLOBAL_CURRENT_MAX` | (Optional) Driver global current limit (0-255, higher values means the driver may consume more power) | 150 |
  200. | `AW_SPI_DIVISOR` | (Optional) Clock divisor for SPI communication (powers of 2, smaller numbers means faster communication, should not be less than 4) | 4 |
  201. Here is an example using 2 drivers.
  202. ```c
  203. #define DRIVER_1_CS B13
  204. #define DRIVER_2_CS B14
  205. // Hardware enable lines may be connected to the same pin
  206. #define DRIVER_1_EN C13
  207. #define DRIVER_2_EN C13
  208. #define DRIVER_COUNT 2
  209. #define DRIVER_1_LED_TOTAL 66
  210. #define DRIVER_2_LED_TOTAL 32
  211. #define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
  212. ```
  213. !> 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`.
  214. Define these arrays listing all the LEDs in your `<keyboard>.c`:
  215. ```c
  216. const aw_led g_aw_leds[DRIVER_LED_TOTAL] = {
  217. /* Each AW20216 channel is controlled by a register at some offset between 0x00
  218. * and 0xD7 inclusive.
  219. * See drivers/awinic/aw20216.h for the mapping between register offsets and
  220. * driver pin locations.
  221. * driver
  222. * | R location
  223. * | | G location
  224. * | | | B location
  225. * | | | | */
  226. { 0, CS1_SW1, CS2_SW1, CS3_SW1 },
  227. { 0, CS4_SW1, CS5_SW1, CS6_SW1 },
  228. { 0, CS7_SW1, CS8_SW1, CS9_SW1 },
  229. { 0, CS10_SW1, CS11_SW1, CS12_SW1 },
  230. { 0, CS13_SW1, CS14_SW1, CS15_SW1 },
  231. ...
  232. { 1, CS1_SW1, CS2_SW1, CS3_SW1 },
  233. { 1, CS13_SW1, CS14_SW1, CS15_SW1 },
  234. { 1, CS16_SW1, CS17_SW1, CS18_SW1 },
  235. { 1, CS4_SW2, CS5_SW2, CS6_SW2 },
  236. ...
  237. };
  238. ```
  239. ---
  240. ## Common Configuration :id=common-configuration
  241. 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:
  242. ```c
  243. led_config_t g_led_config = { {
  244. // Key Matrix to LED Index
  245. { 5, NO_LED, NO_LED, 0 },
  246. { NO_LED, NO_LED, NO_LED, NO_LED },
  247. { 4, NO_LED, NO_LED, 1 },
  248. { 3, NO_LED, NO_LED, 2 }
  249. }, {
  250. // LED Index to Physical Position
  251. { 188, 16 }, { 187, 48 }, { 149, 64 }, { 112, 64 }, { 37, 48 }, { 38, 16 }
  252. }, {
  253. // LED Index to Flag
  254. 1, 4, 4, 4, 4, 1
  255. } };
  256. ```
  257. 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:
  258. ```c
  259. x = 224 / (NUMBER_OF_COLS - 1) * COL_POSITION
  260. y = 64 / (NUMBER_OF_ROWS - 1) * ROW_POSITION
  261. ```
  262. 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.
  263. 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.
  264. `// 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.
  265. ## Flags :id=flags
  266. |Define |Value |Description |
  267. |----------------------------|------|-------------------------------------------------|
  268. |`HAS_FLAGS(bits, flags)` |*n/a* |Evaluates to `true` if `bits` has all `flags` set|
  269. |`HAS_ANY_FLAGS(bits, flags)`|*n/a* |Evaluates to `true` if `bits` has any `flags` set|
  270. |`LED_FLAG_NONE` |`0x00`|If this LED has no flags |
  271. |`LED_FLAG_ALL` |`0xFF`|If this LED has all flags |
  272. |`LED_FLAG_MODIFIER` |`0x01`|If the LED is on a modifier key |
  273. |`LED_FLAG_UNDERGLOW` |`0x02`|If the LED is for underglow |
  274. |`LED_FLAG_KEYLIGHT` |`0x04`|If the LED is for key backlight |
  275. |`LED_FLAG_INDICATOR` |`0x08`|If the LED is for keyboard state indication |
  276. ## Keycodes :id=keycodes
  277. All RGB keycodes are currently shared with the RGBLIGHT system:
  278. |Key |Aliases |Description |
  279. |-------------------|----------|--------------------------------------------------------------------------------------|
  280. |`RGB_TOG` | |Toggle RGB lighting on or off |
  281. |`RGB_MODE_FORWARD` |`RGB_MOD` |Cycle through modes, reverse direction when Shift is held |
  282. |`RGB_MODE_REVERSE` |`RGB_RMOD`|Cycle through modes in reverse, forward direction when Shift is held |
  283. |`RGB_HUI` | |Increase hue, decrease hue when Shift is held |
  284. |`RGB_HUD` | |Decrease hue, increase hue when Shift is held |
  285. |`RGB_SAI` | |Increase saturation, decrease saturation when Shift is held |
  286. |`RGB_SAD` | |Decrease saturation, increase saturation when Shift is held |
  287. |`RGB_VAI` | |Increase value (brightness), decrease value when Shift is held |
  288. |`RGB_VAD` | |Decrease value (brightness), increase value when Shift is held |
  289. |`RGB_SPI` | |Increase effect speed (does not support eeprom yet), decrease speed when Shift is held|
  290. |`RGB_SPD` | |Decrease effect speed (does not support eeprom yet), increase speed when Shift is held|
  291. |`RGB_MODE_PLAIN` |`RGB_M_P `|Static (no animation) mode |
  292. |`RGB_MODE_BREATHE` |`RGB_M_B` |Breathing animation mode |
  293. |`RGB_MODE_RAINBOW` |`RGB_M_R` |Full gradient scrolling left to right (uses the `RGB_MATRIX_CYCLE_LEFT_RIGHT` mode) |
  294. |`RGB_MODE_SWIRL` |`RGB_M_SW`|Full gradient spinning pinwheel around center of keyboard (uses `RGB_MATRIX_CYCLE_PINWHEEL` mode) |
  295. * `RGB_MODE_*` keycodes will generally work, but not all of the modes are currently mapped to the correct effects for the RGB Matrix system.
  296. `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.
  297. !> 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.
  298. ## RGB Matrix Effects :id=rgb-matrix-effects
  299. 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:
  300. ```c
  301. enum rgb_matrix_effects {
  302. RGB_MATRIX_NONE = 0,
  303. RGB_MATRIX_SOLID_COLOR = 1, // Static single hue, no speed support
  304. RGB_MATRIX_ALPHAS_MODS, // Static dual hue, speed is hue for secondary hue
  305. RGB_MATRIX_GRADIENT_UP_DOWN, // Static gradient top to bottom, speed controls how much gradient changes
  306. RGB_MATRIX_GRADIENT_LEFT_RIGHT, // Static gradient left to right, speed controls how much gradient changes
  307. RGB_MATRIX_BREATHING, // Single hue brightness cycling animation
  308. RGB_MATRIX_BAND_SAT, // Single hue band fading saturation scrolling left to right
  309. RGB_MATRIX_BAND_VAL, // Single hue band fading brightness scrolling left to right
  310. RGB_MATRIX_BAND_PINWHEEL_SAT, // Single hue 3 blade spinning pinwheel fades saturation
  311. RGB_MATRIX_BAND_PINWHEEL_VAL, // Single hue 3 blade spinning pinwheel fades brightness
  312. RGB_MATRIX_BAND_SPIRAL_SAT, // Single hue spinning spiral fades saturation
  313. RGB_MATRIX_BAND_SPIRAL_VAL, // Single hue spinning spiral fades brightness
  314. RGB_MATRIX_CYCLE_ALL, // Full keyboard solid hue cycling through full gradient
  315. RGB_MATRIX_CYCLE_LEFT_RIGHT, // Full gradient scrolling left to right
  316. RGB_MATRIX_CYCLE_UP_DOWN, // Full gradient scrolling top to bottom
  317. RGB_MATRIX_CYCLE_OUT_IN, // Full gradient scrolling out to in
  318. RGB_MATRIX_CYCLE_OUT_IN_DUAL, // Full dual gradients scrolling out to in
  319. RGB_MATRIX_RAINBOW_MOVING_CHEVRON, // Full gradent Chevron shapped scrolling left to right
  320. RGB_MATRIX_CYCLE_PINWHEEL, // Full gradient spinning pinwheel around center of keyboard
  321. RGB_MATRIX_CYCLE_SPIRAL, // Full gradient spinning spiral around center of keyboard
  322. RGB_MATRIX_DUAL_BEACON, // Full gradient spinning around center of keyboard
  323. RGB_MATRIX_RAINBOW_BEACON, // Full tighter gradient spinning around center of keyboard
  324. RGB_MATRIX_RAINBOW_PINWHEELS, // Full dual gradients spinning two halfs of keyboard
  325. RGB_MATRIX_RAINDROPS, // Randomly changes a single key's hue
  326. RGB_MATRIX_JELLYBEAN_RAINDROPS, // Randomly changes a single key's hue and saturation
  327. RGB_MATRIX_HUE_BREATHING, // Hue shifts up a slight ammount at the same time, then shifts back
  328. RGB_MATRIX_HUE_PENDULUM, // Hue shifts up a slight ammount in a wave to the right, then back to the left
  329. RGB_MATRIX_HUE_WAVE, // Hue shifts up a slight ammount and then back down in a wave to the right
  330. #if define(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
  331. RGB_MATRIX_TYPING_HEATMAP, // How hot is your WPM!
  332. RGB_MATRIX_DIGITAL_RAIN, // That famous computer simulation
  333. #endif
  334. #if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES)
  335. RGB_MATRIX_SOLID_REACTIVE_SIMPLE, // Pulses keys hit to hue & value then fades value out
  336. RGB_MATRIX_SOLID_REACTIVE, // Static single hue, pulses keys hit to shifted hue then fades to current hue
  337. RGB_MATRIX_SOLID_REACTIVE_WIDE // Hue & value pulse near a single key hit then fades value out
  338. RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE // Hue & value pulse near multiple key hits then fades value out
  339. RGB_MATRIX_SOLID_REACTIVE_CROSS // Hue & value pulse the same column and row of a single key hit then fades value out
  340. RGB_MATRIX_SOLID_REACTIVE_MULTICROSS // Hue & value pulse the same column and row of multiple key hits then fades value out
  341. RGB_MATRIX_SOLID_REACTIVE_NEXUS // Hue & value pulse away on the same column and row of a single key hit then fades value out
  342. RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS // Hue & value pulse away on the same column and row of multiple key hits then fades value out
  343. RGB_MATRIX_SPLASH, // Full gradient & value pulse away from a single key hit then fades value out
  344. RGB_MATRIX_MULTISPLASH, // Full gradient & value pulse away from multiple key hits then fades value out
  345. RGB_MATRIX_SOLID_SPLASH, // Hue & value pulse away from a single key hit then fades value out
  346. RGB_MATRIX_SOLID_MULTISPLASH, // Hue & value pulse away from multiple key hits then fades value out
  347. #endif
  348. RGB_MATRIX_EFFECT_MAX
  349. };
  350. ```
  351. You can disable a single effect by defining `DISABLE_[EFFECT_NAME]` in your `config.h`:
  352. |Define |Description |
  353. |-------------------------------------------------------|-----------------------------------------------|
  354. |`#define DISABLE_RGB_MATRIX_ALPHAS_MODS` |Disables `RGB_MATRIX_ALPHAS_MODS` |
  355. |`#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN` |Disables `RGB_MATRIX_GRADIENT_UP_DOWN` |
  356. |`#define DISABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT` |Disables `MATRIX_GRADIENT_LEFT_RIGHT` |
  357. |`#define DISABLE_RGB_MATRIX_BREATHING` |Disables `RGB_MATRIX_BREATHING` |
  358. |`#define DISABLE_RGB_MATRIX_BAND_SAT` |Disables `RGB_MATRIX_BAND_SAT` |
  359. |`#define DISABLE_RGB_MATRIX_BAND_VAL` |Disables `RGB_MATRIX_BAND_VAL` |
  360. |`#define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT` |Disables `RGB_MATRIX_BAND_PINWHEEL_SAT` |
  361. |`#define DISABLE_RGB_MATRIX_BAND_PINWHEEL_VAL` |Disables `RGB_MATRIX_BAND_PINWHEEL_VAL` |
  362. |`#define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT` |Disables `RGB_MATRIX_BAND_SPIRAL_SAT` |
  363. |`#define DISABLE_RGB_MATRIX_BAND_SPIRAL_VAL` |Disables `RGB_MATRIX_BAND_SPIRAL_VAL` |
  364. |`#define DISABLE_RGB_MATRIX_CYCLE_ALL` |Disables `RGB_MATRIX_CYCLE_ALL` |
  365. |`#define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT` |Disables `RGB_MATRIX_CYCLE_LEFT_RIGHT` |
  366. |`#define DISABLE_RGB_MATRIX_CYCLE_UP_DOWN` |Disables `RGB_MATRIX_CYCLE_UP_DOWN` |
  367. |`#define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON` |Disables `RGB_MATRIX_RAINBOW_MOVING_CHEVRON` |
  368. |`#define DISABLE_RGB_MATRIX_CYCLE_OUT_IN` |Disables `RGB_MATRIX_CYCLE_OUT_IN` |
  369. |`#define DISABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL` |Disables `RGB_MATRIX_CYCLE_OUT_IN_DUAL` |
  370. |`#define DISABLE_RGB_MATRIX_CYCLE_PINWHEEL` |Disables `RGB_MATRIX_CYCLE_PINWHEEL` |
  371. |`#define DISABLE_RGB_MATRIX_CYCLE_SPIRAL` |Disables `RGB_MATRIX_CYCLE_SPIRAL` |
  372. |`#define DISABLE_RGB_MATRIX_DUAL_BEACON` |Disables `RGB_MATRIX_DUAL_BEACON` |
  373. |`#define DISABLE_RGB_MATRIX_RAINBOW_BEACON` |Disables `RGB_MATRIX_RAINBOW_BEACON` |
  374. |`#define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS` |Disables `RGB_MATRIX_RAINBOW_PINWHEELS` |
  375. |`#define DISABLE_RGB_MATRIX_RAINDROPS` |Disables `RGB_MATRIX_RAINDROPS` |
  376. |`#define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS` |Disables `RGB_MATRIX_JELLYBEAN_RAINDROPS` |
  377. |`#define DISABLE_RGB_MATRIX_HUE_BREATHING` |Disables `RGB_MATRIX_HUE_BREATHING` |
  378. |`#define DISABLE_RGB_MATRIX_HUE_PENDULUM` |Disables `RGB_MATRIX_HUE_PENDULUM` |
  379. |`#define DISABLE_RGB_MATRIX_HUE_WAVE ` |Disables `RGB_MATRIX_HUE_WAVE ` |
  380. |`#define DISABLE_RGB_MATRIX_TYPING_HEATMAP` |Disables `RGB_MATRIX_TYPING_HEATMAP` |
  381. |`#define DISABLE_RGB_MATRIX_DIGITAL_RAIN` |Disables `RGB_MATRIX_DIGITAL_RAIN` |
  382. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE` |Disables `RGB_MATRIX_SOLID_REACTIVE_SIMPLE` |
  383. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE` |Disables `RGB_MATRIX_SOLID_REACTIVE` |
  384. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE` |Disables `RGB_MATRIX_SOLID_REACTIVE_WIDE` |
  385. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE` |Disables `RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE` |
  386. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS` |Disables `RGB_MATRIX_SOLID_REACTIVE_CROSS` |
  387. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS` |Disables `RGB_MATRIX_SOLID_REACTIVE_MULTICROSS`|
  388. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS` |Disables `RGB_MATRIX_SOLID_REACTIVE_NEXUS` |
  389. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS` |Disables `RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS`|
  390. |`#define DISABLE_RGB_MATRIX_SPLASH` |Disables `RGB_MATRIX_SPLASH` |
  391. |`#define DISABLE_RGB_MATRIX_MULTISPLASH` |Disables `RGB_MATRIX_MULTISPLASH` |
  392. |`#define DISABLE_RGB_MATRIX_SOLID_SPLASH` |Disables `RGB_MATRIX_SOLID_SPLASH` |
  393. |`#define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH` |Disables `RGB_MATRIX_SOLID_MULTISPLASH` |
  394. ### RGB Matrix Effect Typing Heatmap :id=rgb-matrix-effect-typing-heatmap
  395. This effect will color the RGB matrix according to a heatmap of recently pressed
  396. keys. Whenever a key is pressed its "temperature" increases as well as that of
  397. its neighboring keys. The temperature of each key is then decreased
  398. automatically every 25 milliseconds by default.
  399. In order to change the delay of temperature decrease define
  400. `RGB_MATRIX_TYPING_HEATMAP_DECREASE_DELAY_MS`:
  401. ```c
  402. #define RGB_MATRIX_TYPING_HEATMAP_DECREASE_DELAY_MS 50
  403. ```
  404. ## Custom RGB Matrix Effects :id=custom-rgb-matrix-effects
  405. 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.
  406. To declare new effects, create a new `rgb_matrix_user/kb.inc` that looks something like this:
  407. `rgb_matrix_user.inc` should go in the root of the keymap directory.
  408. `rgb_matrix_kb.inc` should go in the root of the keyboard directory.
  409. 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:
  410. ```c
  411. rgb_matrix_mode(RGB_MATRIX_CUSTOM_my_cool_effect);
  412. ```
  413. ```c
  414. // !!! DO NOT ADD #pragma once !!! //
  415. // Step 1.
  416. // Declare custom effects using the RGB_MATRIX_EFFECT macro
  417. // (note the lack of semicolon after the macro!)
  418. RGB_MATRIX_EFFECT(my_cool_effect)
  419. RGB_MATRIX_EFFECT(my_cool_effect2)
  420. // Step 2.
  421. // Define effects inside the `RGB_MATRIX_CUSTOM_EFFECT_IMPLS` ifdef block
  422. #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
  423. // e.g: A simple effect, self-contained within a single method
  424. static bool my_cool_effect(effect_params_t* params) {
  425. RGB_MATRIX_USE_LIMITS(led_min, led_max);
  426. for (uint8_t i = led_min; i < led_max; i++) {
  427. rgb_matrix_set_color(i, 0xff, 0xff, 0x00);
  428. }
  429. return led_max < DRIVER_LED_TOTAL;
  430. }
  431. // e.g: A more complex effect, relying on external methods and state, with
  432. // dedicated init and run methods
  433. static uint8_t some_global_state;
  434. static void my_cool_effect2_complex_init(effect_params_t* params) {
  435. some_global_state = 1;
  436. }
  437. static bool my_cool_effect2_complex_run(effect_params_t* params) {
  438. RGB_MATRIX_USE_LIMITS(led_min, led_max);
  439. for (uint8_t i = led_min; i < led_max; i++) {
  440. rgb_matrix_set_color(i, 0xff, some_global_state++, 0xff);
  441. }
  442. return led_max < DRIVER_LED_TOTAL;
  443. }
  444. static bool my_cool_effect2(effect_params_t* params) {
  445. if (params->init) my_cool_effect2_complex_init(params);
  446. return my_cool_effect2_complex_run(params);
  447. }
  448. #endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
  449. ```
  450. For inspiration and examples, check out the built-in effects under `quantum/rgb_matrix_animations/`
  451. ## Colors :id=colors
  452. These are shorthands to popular colors. The `RGB` ones can be passed to the `setrgb` functions, while the `HSV` ones to the `sethsv` functions.
  453. |RGB |HSV |
  454. |---------------------|---------------------|
  455. |`RGB_AZURE` |`HSV_AZURE` |
  456. |`RGB_BLACK`/`RGB_OFF`|`HSV_BLACK`/`HSV_OFF`|
  457. |`RGB_BLUE` |`HSV_BLUE` |
  458. |`RGB_CHARTREUSE` |`HSV_CHARTREUSE` |
  459. |`RGB_CORAL` |`HSV_CORAL` |
  460. |`RGB_CYAN` |`HSV_CYAN` |
  461. |`RGB_GOLD` |`HSV_GOLD` |
  462. |`RGB_GOLDENROD` |`HSV_GOLDENROD` |
  463. |`RGB_GREEN` |`HSV_GREEN` |
  464. |`RGB_MAGENTA` |`HSV_MAGENTA` |
  465. |`RGB_ORANGE` |`HSV_ORANGE` |
  466. |`RGB_PINK` |`HSV_PINK` |
  467. |`RGB_PURPLE` |`HSV_PURPLE` |
  468. |`RGB_RED` |`HSV_RED` |
  469. |`RGB_SPRINGGREEN` |`HSV_SPRINGGREEN` |
  470. |`RGB_TEAL` |`HSV_TEAL` |
  471. |`RGB_TURQUOISE` |`HSV_TURQUOISE` |
  472. |`RGB_WHITE` |`HSV_WHITE` |
  473. |`RGB_YELLOW` |`HSV_YELLOW` |
  474. These are defined in [`color.h`](https://github.com/qmk/qmk_firmware/blob/master/quantum/color.h). Feel free to add to this list!
  475. ## Additional `config.h` Options :id=additional-configh-options
  476. ```c
  477. #define RGB_MATRIX_KEYPRESSES // reacts to keypresses
  478. #define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
  479. #define RGB_MATRIX_FRAMEBUFFER_EFFECTS // enable framebuffer effects
  480. #define RGB_DISABLE_TIMEOUT 0 // number of milliseconds to wait until rgb automatically turns off
  481. #define RGB_DISABLE_AFTER_TIMEOUT 0 // OBSOLETE: number of ticks to wait until disabling effects
  482. #define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
  483. #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)
  484. #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)
  485. #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
  486. #define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT // Sets the default mode, if none has been set
  487. #define RGB_MATRIX_STARTUP_HUE 0 // Sets the default hue value, if none has been set
  488. #define RGB_MATRIX_STARTUP_SAT 255 // Sets the default saturation value, if none has been set
  489. #define RGB_MATRIX_STARTUP_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS // Sets the default brightness value, if none has been set
  490. #define RGB_MATRIX_STARTUP_SPD 127 // Sets the default animation speed, if none has been set
  491. #define RGB_MATRIX_DISABLE_KEYCODES // disables control of rgb matrix by keycodes (must use code functions to control the feature)
  492. #define RGB_MATRIX_SPLIT { X, Y } // (Optional) For split keyboards, the number of LEDs connected on each half. X = left, Y = Right.
  493. // If RGB_MATRIX_KEYPRESSES or RGB_MATRIX_KEYRELEASES is enabled, you also will want to enable SPLIT_TRANSPORT_MIRROR
  494. ```
  495. ## EEPROM storage :id=eeprom-storage
  496. 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:
  497. ```c
  498. #define EECONFIG_RGB_MATRIX (uint32_t *)28
  499. ```
  500. Where `28` is an unused index from `eeconfig.h`.
  501. ## Functions :id=functions
  502. ### Direct Operation :id=direct-operation
  503. |Function |Description |
  504. |--------------------------------------------|-------------|
  505. |`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) |
  506. |`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) |
  507. ### Disable/Enable Effects :id=disable-enable-effects
  508. |Function |Description |
  509. |--------------------------------------------|-------------|
  510. |`rgb_matrix_toggle()` |Toggle effect range LEDs between on and off |
  511. |`rgb_matrix_toggle_noeeprom()` |Toggle effect range LEDs between on and off (not written to EEPROM) |
  512. |`rgb_matrix_enable()` |Turn effect range LEDs on, based on their previous state |
  513. |`rgb_matrix_enable_noeeprom()` |Turn effect range LEDs on, based on their previous state (not written to EEPROM) |
  514. |`rgb_matrix_disable()` |Turn effect range LEDs off, based on their previous state |
  515. |`rgb_matrix_disable_noeeprom()` |Turn effect range LEDs off, based on their previous state (not written to EEPROM) |
  516. ### Change Effect Mode :id=change-effect-mode
  517. |Function |Description |
  518. |--------------------------------------------|-------------|
  519. |`rgb_matrix_mode(mode)` |Set the mode, if RGB animations are enabled |
  520. |`rgb_matrix_mode_noeeprom(mode)` |Set the mode, if RGB animations are enabled (not written to EEPROM) |
  521. |`rgb_matrix_step()` |Change the mode to the next RGB animation in the list of enabled RGB animations |
  522. |`rgb_matrix_step_noeeprom()` |Change the mode to the next RGB animation in the list of enabled RGB animations (not written to EEPROM) |
  523. |`rgb_matrix_step_reverse()` |Change the mode to the previous RGB animation in the list of enabled RGB animations |
  524. |`rgb_matrix_step_reverse_noeeprom()` |Change the mode to the previous RGB animation in the list of enabled RGB animations (not written to EEPROM) |
  525. |`rgb_matrix_increase_speed()` |Increase the speed of the animations |
  526. |`rgb_matrix_increase_speed_noeeprom()` |Increase the speed of the animations (not written to EEPROM) |
  527. |`rgb_matrix_decrease_speed()` |Decrease the speed of the animations |
  528. |`rgb_matrix_decrease_speed_noeeprom()` |Decrease the speed of the animations (not written to EEPROM) |
  529. |`rgb_matrix_set_speed(speed)` |Set the speed of the animations to the given value where `speed` is between 0 and 255 |
  530. |`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) |
  531. ### Change Color :id=change-color
  532. |Function |Description |
  533. |--------------------------------------------|-------------|
  534. |`rgb_matrix_increase_hue()` |Increase the hue for effect range LEDs. This wraps around at maximum hue |
  535. |`rgb_matrix_increase_hue_noeeprom()` |Increase the hue for effect range LEDs. This wraps around at maximum hue (not written to EEPROM) |
  536. |`rgb_matrix_decrease_hue()` |Decrease the hue for effect range LEDs. This wraps around at minimum hue |
  537. |`rgb_matrix_decrease_hue_noeeprom()` |Decrease the hue for effect range LEDs. This wraps around at minimum hue (not written to EEPROM) |
  538. |`rgb_matrix_increase_sat()` |Increase the saturation for effect range LEDs. This wraps around at maximum saturation |
  539. |`rgb_matrix_increase_sat_noeeprom()` |Increase the saturation for effect range LEDs. This wraps around at maximum saturation (not written to EEPROM) |
  540. |`rgb_matrix_decrease_sat()` |Decrease the saturation for effect range LEDs. This wraps around at minimum saturation |
  541. |`rgb_matrix_decrease_sat_noeeprom()` |Decrease the saturation for effect range LEDs. This wraps around at minimum saturation (not written to EEPROM) |
  542. |`rgb_matrix_increase_val()` |Increase the value for effect range LEDs. This wraps around at maximum value |
  543. |`rgb_matrix_increase_val_noeeprom()` |Increase the value for effect range LEDs. This wraps around at maximum value (not written to EEPROM) |
  544. |`rgb_matrix_decrease_val()` |Decrease the value for effect range LEDs. This wraps around at minimum value |
  545. |`rgb_matrix_decrease_val_noeeprom()` |Decrease the value for effect range LEDs. This wraps around at minimum value (not written to EEPROM) |
  546. |`rgb_matrix_sethsv(h, s, v)` |Set LEDs to the given HSV value where `h`/`s`/`v` are between 0 and 255 |
  547. |`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) |
  548. ### Query Current Status :id=query-current-status
  549. |Function |Description |
  550. |---------------------------------|---------------------------|
  551. |`rgb_matrix_is_enabled()` |Gets current on/off status |
  552. |`rgb_matrix_get_mode()` |Gets current mode |
  553. |`rgb_matrix_get_hue()` |Gets current hue |
  554. |`rgb_matrix_get_sat()` |Gets current sat |
  555. |`rgb_matrix_get_val()` |Gets current val |
  556. |`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)|
  557. |`rgb_matrix_get_speed()` |Gets current speed |
  558. |`rgb_matrix_get_suspend_state()` |Gets current suspend state |
  559. ## Callbacks :id=callbacks
  560. ### Indicators :id=indicators
  561. 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:
  562. ```c
  563. void rgb_matrix_indicators_kb(void) {
  564. rgb_matrix_set_color(index, red, green, blue);
  565. }
  566. ```
  567. 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)`.
  568. ```c
  569. void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
  570. RGB_MATRIX_INDICATOR_SET_COLOR(index, red, green, blue);
  571. }
  572. ```
  573. ### Suspended state :id=suspended-state
  574. To use the suspend feature, make sure that `#define RGB_DISABLE_WHEN_USB_SUSPENDED true` is added to the `config.h` file.
  575. Additionally add this to your `<keyboard>.c`:
  576. ```c
  577. void suspend_power_down_kb(void) {
  578. rgb_matrix_set_suspend_state(true);
  579. suspend_power_down_user();
  580. }
  581. void suspend_wakeup_init_kb(void) {
  582. rgb_matrix_set_suspend_state(false);
  583. suspend_wakeup_init_user();
  584. }
  585. ```
  586. or add this to your `keymap.c`:
  587. ```c
  588. void suspend_power_down_user(void) {
  589. rgb_matrix_set_suspend_state(true);
  590. }
  591. void suspend_wakeup_init_user(void) {
  592. rgb_matrix_set_suspend_state(false);
  593. }
  594. ```