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.

521 lines
30 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. Configure the hardware via your `config.h`:
  13. ```c
  14. // This is a 7-bit address, that gets left-shifted and bit 0
  15. // set to 0 for write, 1 for read (as per I2C protocol)
  16. // The address will vary depending on your wiring:
  17. // 0b1110100 AD <-> GND
  18. // 0b1110111 AD <-> VCC
  19. // 0b1110101 AD <-> SCL
  20. // 0b1110110 AD <-> SDA
  21. #define DRIVER_ADDR_1 0b1110100
  22. #define DRIVER_ADDR_2 0b1110110
  23. #define DRIVER_COUNT 2
  24. #define DRIVER_1_LED_TOTAL 25
  25. #define DRIVER_2_LED_TOTAL 24
  26. #define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
  27. ```
  28. !> 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`.
  29. Currently only 2 drivers are supported, but it would be trivial to support all 4 combinations.
  30. Define these arrays listing all the LEDs in your `<keyboard>.c`:
  31. ```c
  32. const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
  33. /* Refer to IS31 manual for these locations
  34. * driver
  35. * | R location
  36. * | | G location
  37. * | | | B location
  38. * | | | | */
  39. {0, C1_3, C2_3, C3_3},
  40. ....
  41. }
  42. ```
  43. Where `Cx_y` is the location of the LED in the matrix defined by [the datasheet](http://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` or `1` right now).
  44. ---
  45. ### IS31FL3733/IS31FL3737 :id=is31fl3733is31fl3737
  46. !> For the IS31FL3737, replace all instances of `IS31FL3733` below with `IS31FL3737`.
  47. There is basic support for addressable RGB matrix lighting with the I2C IS31FL3733 RGB controller. To enable it, add this to your `rules.mk`:
  48. ```makefile
  49. RGB_MATRIX_ENABLE = yes
  50. RGB_MATRIX_DRIVER = IS31FL3733
  51. ```
  52. Configure the hardware via your `config.h`:
  53. ```c
  54. // This is a 7-bit address, that gets left-shifted and bit 0
  55. // set to 0 for write, 1 for read (as per I2C protocol)
  56. // The address will vary depending on your wiring:
  57. // 00 <-> GND
  58. // 01 <-> SCL
  59. // 10 <-> SDA
  60. // 11 <-> VCC
  61. // ADDR1 represents A1:A0 of the 7-bit address.
  62. // ADDR2 represents A3:A2 of the 7-bit address.
  63. // The result is: 0b101(ADDR2)(ADDR1)
  64. #define DRIVER_ADDR_1 0b1010000
  65. #define DRIVER_ADDR_2 0b1010000 // this is here for compliancy reasons.
  66. #define DRIVER_COUNT 2
  67. #define DRIVER_1_LED_TOTAL 64
  68. #define DRIVER_LED_TOTAL DRIVER_1_LED_TOTAL
  69. ```
  70. 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`
  71. Define these arrays listing all the LEDs in your `<keyboard>.c`:
  72. ```c
  73. const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
  74. /* Refer to IS31 manual for these locations
  75. * driver
  76. * | R location
  77. * | | G location
  78. * | | | B location
  79. * | | | | */
  80. {0, B_1, A_1, C_1},
  81. ....
  82. }
  83. ```
  84. Where `X_Y` is the location of the LED in the matrix defined by [the datasheet](http://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` (Only `0` right now).
  85. ---
  86. ### WS2812 :id=ws2812
  87. 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`:
  88. ```makefile
  89. RGB_MATRIX_ENABLE = yes
  90. RGB_MATRIX_DRIVER = WS2812
  91. ```
  92. Configure the hardware via your `config.h`:
  93. ```c
  94. // The pin connected to the data pin of the LEDs
  95. #define RGB_DI_PIN D7
  96. // The number of LEDs connected
  97. #define DRIVER_LED_TOTAL 70
  98. ```
  99. ---
  100. 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:
  101. ```c
  102. led_config_t g_led_config = { {
  103. // Key Matrix to LED Index
  104. { 5, NO_LED, NO_LED, 0 },
  105. { NO_LED, NO_LED, NO_LED, NO_LED },
  106. { 4, NO_LED, NO_LED, 1 },
  107. { 3, NO_LED, NO_LED, 2 }
  108. }, {
  109. // LED Index to Physical Position
  110. { 188, 16 }, { 187, 48 }, { 149, 64 }, { 112, 64 }, { 37, 48 }, { 38, 16 }
  111. }, {
  112. // LED Index to Flag
  113. 1, 4, 4, 4, 4, 1
  114. } };
  115. ```
  116. 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:
  117. ```c
  118. x = 224 / (NUMBER_OF_COLS - 1) * COL_POSITION
  119. y = 64 / (NUMBER_OF_ROWS - 1) * ROW_POSITION
  120. ```
  121. 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.
  122. 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.
  123. `// 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.
  124. ## Flags :id=flags
  125. |Define |Value |Description |
  126. |----------------------------|------|-------------------------------------------------|
  127. |`HAS_FLAGS(bits, flags)` |*n/a* |Evaluates to `true` if `bits` has all `flags` set|
  128. |`HAS_ANY_FLAGS(bits, flags)`|*n/a* |Evaluates to `true` if `bits` has any `flags` set|
  129. |`LED_FLAG_NONE` |`0x00`|If this LED has no flags |
  130. |`LED_FLAG_ALL` |`0xFF`|If this LED has all flags |
  131. |`LED_FLAG_MODIFIER` |`0x01`|If the LED is on a modifier key |
  132. |`LED_FLAG_UNDERGLOW` |`0x02`|If the LED is for underglow |
  133. |`LED_FLAG_KEYLIGHT` |`0x04`|If the LED is for key backlight |
  134. |`LED_FLAG_INDICATOR` |`0x08`|If the LED is for keyboard state indication |
  135. ## Keycodes :id=keycodes
  136. All RGB keycodes are currently shared with the RGBLIGHT system:
  137. |Key |Aliases |Description |
  138. |-------------------|----------|--------------------------------------------------------------------------------------|
  139. |`RGB_TOG` | |Toggle RGB lighting on or off |
  140. |`RGB_MODE_FORWARD` |`RGB_MOD` |Cycle through modes, reverse direction when Shift is held |
  141. |`RGB_MODE_REVERSE` |`RGB_RMOD`|Cycle through modes in reverse, forward direction when Shift is held |
  142. |`RGB_HUI` | |Increase hue, decrease hue when Shift is held |
  143. |`RGB_HUD` | |Decrease hue, increase hue when Shift is held |
  144. |`RGB_SAI` | |Increase saturation, decrease saturation when Shift is held |
  145. |`RGB_SAD` | |Decrease saturation, increase saturation when Shift is held |
  146. |`RGB_VAI` | |Increase value (brightness), decrease value when Shift is held |
  147. |`RGB_VAD` | |Decrease value (brightness), increase value when Shift is held |
  148. |`RGB_SPI` | |Increase effect speed (does not support eeprom yet), decrease speed when Shift is held|
  149. |`RGB_SPD` | |Decrease effect speed (does not support eeprom yet), increase speed when Shift is held|
  150. |`RGB_MODE_PLAIN` |`RGB_M_P `|Static (no animation) mode |
  151. |`RGB_MODE_BREATHE` |`RGB_M_B` |Breathing animation mode |
  152. |`RGB_MODE_RAINBOW` |`RGB_M_R` |Full gradient scrolling left to right (uses the `RGB_MATRIX_CYCLE_LEFT_RIGHT` mode) |
  153. |`RGB_MODE_SWIRL` |`RGB_M_SW`|Full gradient spinning pinwheel around center of keyboard (uses `RGB_MATRIX_CYCLE_PINWHEEL` mode) |
  154. * `RGB_MODE_*` keycodes will generally work, but not all of the modes are currently mapped to the correct effects for the RGB Matrix system.
  155. `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.
  156. !> 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.
  157. ## RGB Matrix Effects :id=rgb-matrix-effects
  158. 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:
  159. ```c
  160. enum rgb_matrix_effects {
  161. RGB_MATRIX_NONE = 0,
  162. RGB_MATRIX_SOLID_COLOR = 1, // Static single hue, no speed support
  163. RGB_MATRIX_ALPHAS_MODS, // Static dual hue, speed is hue for secondary hue
  164. RGB_MATRIX_GRADIENT_UP_DOWN, // Static gradient top to bottom, speed controls how much gradient changes
  165. RGB_MATRIX_GRADIENT_LEFT_RIGHT, // Static gradient left to right, speed controls how much gradient changes
  166. RGB_MATRIX_BREATHING, // Single hue brightness cycling animation
  167. RGB_MATRIX_BAND_SAT, // Single hue band fading saturation scrolling left to right
  168. RGB_MATRIX_BAND_VAL, // Single hue band fading brightness scrolling left to right
  169. RGB_MATRIX_BAND_PINWHEEL_SAT, // Single hue 3 blade spinning pinwheel fades saturation
  170. RGB_MATRIX_BAND_PINWHEEL_VAL, // Single hue 3 blade spinning pinwheel fades brightness
  171. RGB_MATRIX_BAND_SPIRAL_SAT, // Single hue spinning spiral fades saturation
  172. RGB_MATRIX_BAND_SPIRAL_VAL, // Single hue spinning spiral fades brightness
  173. RGB_MATRIX_CYCLE_ALL, // Full keyboard solid hue cycling through full gradient
  174. RGB_MATRIX_CYCLE_LEFT_RIGHT, // Full gradient scrolling left to right
  175. RGB_MATRIX_CYCLE_UP_DOWN, // Full gradient scrolling top to bottom
  176. RGB_MATRIX_CYCLE_OUT_IN, // Full gradient scrolling out to in
  177. RGB_MATRIX_CYCLE_OUT_IN_DUAL, // Full dual gradients scrolling out to in
  178. RGB_MATRIX_RAINBOW_MOVING_CHEVRON, // Full gradent Chevron shapped scrolling left to right
  179. RGB_MATRIX_CYCLE_PINWHEEL, // Full gradient spinning pinwheel around center of keyboard
  180. RGB_MATRIX_CYCLE_SPIRAL, // Full gradient spinning spiral around center of keyboard
  181. RGB_MATRIX_DUAL_BEACON, // Full gradient spinning around center of keyboard
  182. RGB_MATRIX_RAINBOW_BEACON, // Full tighter gradient spinning around center of keyboard
  183. RGB_MATRIX_RAINBOW_PINWHEELS, // Full dual gradients spinning two halfs of keyboard
  184. RGB_MATRIX_RAINDROPS, // Randomly changes a single key's hue
  185. RGB_MATRIX_JELLYBEAN_RAINDROPS, // Randomly changes a single key's hue and saturation
  186. #if define(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
  187. RGB_MATRIX_TYPING_HEATMAP, // How hot is your WPM!
  188. RGB_MATRIX_DIGITAL_RAIN, // That famous computer simulation
  189. #endif
  190. #if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES)
  191. RGB_MATRIX_SOLID_REACTIVE_SIMPLE, // Pulses keys hit to hue & value then fades value out
  192. RGB_MATRIX_SOLID_REACTIVE, // Static single hue, pulses keys hit to shifted hue then fades to current hue
  193. RGB_MATRIX_SOLID_REACTIVE_WIDE // Hue & value pulse near a single key hit then fades value out
  194. RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE // Hue & value pulse near multiple key hits then fades value out
  195. RGB_MATRIX_SOLID_REACTIVE_CROSS // Hue & value pulse the same column and row of a single key hit then fades value out
  196. RGB_MATRIX_SOLID_REACTIVE_MULTICROSS // Hue & value pulse the same column and row of multiple key hits then fades value out
  197. RGB_MATRIX_SOLID_REACTIVE_NEXUS // Hue & value pulse away on the same column and row of a single key hit then fades value out
  198. RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS // Hue & value pulse away on the same column and row of multiple key hits then fades value out
  199. RGB_MATRIX_SPLASH, // Full gradient & value pulse away from a single key hit then fades value out
  200. RGB_MATRIX_MULTISPLASH, // Full gradient & value pulse away from multiple key hits then fades value out
  201. RGB_MATRIX_SOLID_SPLASH, // Hue & value pulse away from a single key hit then fades value out
  202. RGB_MATRIX_SOLID_MULTISPLASH, // Hue & value pulse away from multiple key hits then fades value out
  203. #endif
  204. RGB_MATRIX_EFFECT_MAX
  205. };
  206. ```
  207. You can disable a single effect by defining `DISABLE_[EFFECT_NAME]` in your `config.h`:
  208. |Define |Description |
  209. |-------------------------------------------------------|-----------------------------------------------|
  210. |`#define DISABLE_RGB_MATRIX_ALPHAS_MODS` |Disables `RGB_MATRIX_ALPHAS_MODS` |
  211. |`#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN` |Disables `RGB_MATRIX_GRADIENT_UP_DOWN` |
  212. |`#define DISABLE_RGB_MATRIX_BREATHING` |Disables `RGB_MATRIX_BREATHING` |
  213. |`#define DISABLE_RGB_MATRIX_BAND_SAT` |Disables `RGB_MATRIX_BAND_SAT` |
  214. |`#define DISABLE_RGB_MATRIX_BAND_VAL` |Disables `RGB_MATRIX_BAND_VAL` |
  215. |`#define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT` |Disables `RGB_MATRIX_BAND_PINWHEEL_SAT` |
  216. |`#define DISABLE_RGB_MATRIX_BAND_PINWHEEL_VAL` |Disables `RGB_MATRIX_BAND_PINWHEEL_VAL` |
  217. |`#define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT` |Disables `RGB_MATRIX_BAND_SPIRAL_SAT` |
  218. |`#define DISABLE_RGB_MATRIX_BAND_SPIRAL_VAL` |Disables `RGB_MATRIX_BAND_SPIRAL_VAL` |
  219. |`#define DISABLE_RGB_MATRIX_CYCLE_ALL` |Disables `RGB_MATRIX_CYCLE_ALL` |
  220. |`#define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT` |Disables `RGB_MATRIX_CYCLE_LEFT_RIGHT` |
  221. |`#define DISABLE_RGB_MATRIX_CYCLE_UP_DOWN` |Disables `RGB_MATRIX_CYCLE_UP_DOWN` |
  222. |`#define DISABLE_RGB_MATRIX_CYCLE_OUT_IN` |Disables `RGB_MATRIX_CYCLE_OUT_IN` |
  223. |`#define DISABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL` |Disables `RGB_MATRIX_CYCLE_OUT_IN_DUAL` |
  224. |`#define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON` |Disables `RGB_MATRIX_RAINBOW_MOVING_CHEVRON` |
  225. |`#define DISABLE_RGB_MATRIX_DUAL_BEACON` |Disables `RGB_MATRIX_DUAL_BEACON` |
  226. |`#define DISABLE_RGB_MATRIX_CYCLE_PINWHEEL` |Disables `RGB_MATRIX_CYCLE_PINWHEEL` |
  227. |`#define DISABLE_RGB_MATRIX_CYCLE_SPIRAL` |Disables `RGB_MATRIX_CYCLE_SPIRAL` |
  228. |`#define DISABLE_RGB_MATRIX_RAINBOW_BEACON` |Disables `RGB_MATRIX_RAINBOW_BEACON` |
  229. |`#define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS` |Disables `RGB_MATRIX_RAINBOW_PINWHEELS` |
  230. |`#define DISABLE_RGB_MATRIX_RAINDROPS` |Disables `RGB_MATRIX_RAINDROPS` |
  231. |`#define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS` |Disables `RGB_MATRIX_JELLYBEAN_RAINDROPS` |
  232. |`#define DISABLE_RGB_MATRIX_TYPING_HEATMAP` |Disables `RGB_MATRIX_TYPING_HEATMAP` |
  233. |`#define DISABLE_RGB_MATRIX_DIGITAL_RAIN` |Disables `RGB_MATRIX_DIGITAL_RAIN` |
  234. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE` |Disables `RGB_MATRIX_SOLID_REACTIVE` |
  235. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE` |Disables `RGB_MATRIX_SOLID_REACTIVE_SIMPLE` |
  236. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE` |Disables `RGB_MATRIX_SOLID_REACTIVE_WIDE` |
  237. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE` |Disables `RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE` |
  238. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS` |Disables `RGB_MATRIX_SOLID_REACTIVE_CROSS` |
  239. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS` |Disables `RGB_MATRIX_SOLID_REACTIVE_MULTICROSS`|
  240. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS` |Disables `RGB_MATRIX_SOLID_REACTIVE_NEXUS` |
  241. |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS` |Disables `RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS`|
  242. |`#define DISABLE_RGB_MATRIX_SPLASH` |Disables `RGB_MATRIX_SPLASH` |
  243. |`#define DISABLE_RGB_MATRIX_MULTISPLASH` |Disables `RGB_MATRIX_MULTISPLASH` |
  244. |`#define DISABLE_RGB_MATRIX_SOLID_SPLASH` |Disables `RGB_MATRIX_SOLID_SPLASH` |
  245. |`#define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH` |Disables `RGB_MATRIX_SOLID_MULTISPLASH` |
  246. ## Custom RGB Matrix Effects :id=custom-rgb-matrix-effects
  247. 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.
  248. To declare new effects, create a new `rgb_matrix_user/kb.inc` that looks something like this:
  249. `rgb_matrix_user.inc` should go in the root of the keymap directory.
  250. `rgb_matrix_kb.inc` should go in the root of the keyboard directory.
  251. ```c
  252. // !!! DO NOT ADD #pragma once !!! //
  253. // Step 1.
  254. // Declare custom effects using the RGB_MATRIX_EFFECT macro
  255. // (note the lack of semicolon after the macro!)
  256. RGB_MATRIX_EFFECT(my_cool_effect)
  257. RGB_MATRIX_EFFECT(my_cool_effect2)
  258. // Step 2.
  259. // Define effects inside the `RGB_MATRIX_CUSTOM_EFFECT_IMPLS` ifdef block
  260. #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
  261. // e.g: A simple effect, self-contained within a single method
  262. static bool my_cool_effect(effect_params_t* params) {
  263. RGB_MATRIX_USE_LIMITS(led_min, led_max);
  264. for (uint8_t i = led_min; i < led_max; i++) {
  265. rgb_matrix_set_color(i, 0xff, 0xff, 0x00);
  266. }
  267. return led_max < DRIVER_LED_TOTAL;
  268. }
  269. // e.g: A more complex effect, relying on external methods and state, with
  270. // dedicated init and run methods
  271. static uint8_t some_global_state;
  272. static void my_cool_effect2_complex_init(effect_params_t* params) {
  273. some_global_state = 1;
  274. }
  275. static bool my_cool_effect2_complex_run(effect_params_t* params) {
  276. RGB_MATRIX_USE_LIMITS(led_min, led_max);
  277. for (uint8_t i = led_min; i < led_max; i++) {
  278. rgb_matrix_set_color(i, 0xff, some_global_state++, 0xff);
  279. }
  280. return led_max < DRIVER_LED_TOTAL;
  281. }
  282. static bool my_cool_effect2(effect_params_t* params) {
  283. if (params->init) my_cool_effect2_complex_init(params);
  284. return my_cool_effect2_complex_run(params);
  285. }
  286. #endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
  287. ```
  288. For inspiration and examples, check out the built-in effects under `quantum/rgb_matrix_animation/`
  289. ## Colors :id=colors
  290. These are shorthands to popular colors. The `RGB` ones can be passed to the `setrgb` functions, while the `HSV` ones to the `sethsv` functions.
  291. |RGB |HSV |
  292. |-------------------|-------------------|
  293. |`RGB_WHITE` |`HSV_WHITE` |
  294. |`RGB_RED` |`HSV_RED` |
  295. |`RGB_CORAL` |`HSV_CORAL` |
  296. |`RGB_ORANGE` |`HSV_ORANGE` |
  297. |`RGB_GOLDENROD` |`HSV_GOLDENROD` |
  298. |`RGB_GOLD` |`HSV_GOLD` |
  299. |`RGB_YELLOW` |`HSV_YELLOW` |
  300. |`RGB_CHARTREUSE` |`HSV_CHARTREUSE` |
  301. |`RGB_GREEN` |`HSV_GREEN` |
  302. |`RGB_SPRINGGREEN` |`HSV_SPRINGGREEN` |
  303. |`RGB_TURQUOISE` |`HSV_TURQUOISE` |
  304. |`RGB_TEAL` |`HSV_TEAL` |
  305. |`RGB_CYAN` |`HSV_CYAN` |
  306. |`RGB_AZURE` |`HSV_AZURE` |
  307. |`RGB_BLUE` |`HSV_BLUE` |
  308. |`RGB_PURPLE` |`HSV_PURPLE` |
  309. |`RGB_MAGENTA` |`HSV_MAGENTA` |
  310. |`RGB_PINK` |`HSV_PINK` |
  311. These are defined in [`rgblight_list.h`](https://github.com/qmk/qmk_firmware/blob/master/quantum/rgblight_list.h). Feel free to add to this list!
  312. ## Additional `config.h` Options :id=additional-configh-options
  313. ```c
  314. #define RGB_MATRIX_KEYPRESSES // reacts to keypresses
  315. #define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
  316. #define RGB_DISABLE_TIMEOUT 0 // number of milliseconds to wait until rgb automatically turns off
  317. #define RGB_DISABLE_AFTER_TIMEOUT 0 // OBSOLETE: number of ticks to wait until disabling effects
  318. #define RGB_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended
  319. #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)
  320. #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)
  321. #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
  322. #define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT // Sets the default mode, if none has been set
  323. #define RGB_MATRIX_STARTUP_HUE 0 // Sets the default hue value, if none has been set
  324. #define RGB_MATRIX_STARTUP_SAT 255 // Sets the default saturation value, if none has been set
  325. #define RGB_MATRIX_STARTUP_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS // Sets the default brightness value, if none has been set
  326. #define RGB_MATRIX_STARTUP_SPD 127 // Sets the default animation speed, if none has been set
  327. #define RGB_MATRIX_DISABLE_KEYCODES // disables control of rgb matrix by keycodes (must use code functions to control the feature)
  328. ```
  329. ## EEPROM storage :id=eeprom-storage
  330. The EEPROM for it is currently shared with the RGBLIGHT system (it's generally assumed only one RGB would be used at a time), but could be configured to use its own 32bit address with:
  331. ```c
  332. #define EECONFIG_RGB_MATRIX (uint32_t *)28
  333. ```
  334. Where `28` is an unused index from `eeconfig.h`.
  335. ## Functions :id=functions
  336. ### Direct Operation :id=direct-operation
  337. |Function |Description |
  338. |--------------------------------------------|-------------|
  339. |`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) |
  340. |`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) |
  341. ### Disable/Enable Effects :id=disable-enable-effects
  342. |Function |Description |
  343. |--------------------------------------------|-------------|
  344. |`rgb_matrix_toggle()` |Toggle effect range LEDs between on and off |
  345. |`rgb_matrix_toggle_noeeprom()` |Toggle effect range LEDs between on and off (not written to EEPROM) |
  346. |`rgb_matrix_enable()` |Turn effect range LEDs on, based on their previous state |
  347. |`rgb_matrix_enable_noeeprom()` |Turn effect range LEDs on, based on their previous state (not written to EEPROM) |
  348. |`rgb_matrix_disable()` |Turn effect range LEDs off, based on their previous state |
  349. |`rgb_matrix_disable_noeeprom()` |Turn effect range LEDs off, based on their previous state (not written to EEPROM) |
  350. ### Change Effect Mode :id=change-effect-mode
  351. |Function |Description |
  352. |--------------------------------------------|-------------|
  353. |`rgb_matrix_mode(mode)` |Set the mode, if RGB animations are enabled |
  354. |`rgb_matrix_mode_noeeprom(mode)` |Set the mode, if RGB animations are enabled (not written to EEPROM) |
  355. |`rgb_matrix_step()` |Change the mode to the next RGB animation in the list of enabled RGB animations |
  356. |`rgb_matrix_step_noeeprom()` |Change the mode to the next RGB animation in the list of enabled RGB animations (not written to EEPROM) |
  357. |`rgb_matrix_step_reverse()` |Change the mode to the previous RGB animation in the list of enabled RGB animations |
  358. |`rgb_matrix_step_reverse_noeeprom()` |Change the mode to the previous RGB animation in the list of enabled RGB animations (not written to EEPROM) |
  359. |`rgb_matrix_increase_speed()` |Increase the speed of the animations |
  360. |`rgb_matrix_increase_speed_noeeprom()` |Increase the speed of the animations (not written to EEPROM) |
  361. |`rgb_matrix_decrease_speed()` |Decrease the speed of the animations |
  362. |`rgb_matrix_decrease_speed_noeeprom()` |Decrease the speed of the animations (not written to EEPROM) |
  363. |`rgb_matrix_set_speed(speed)` |Set the speed of the animations to the given value where `speed` is between 0 and 255 |
  364. |`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) |
  365. ### Change Color :id=change-color
  366. |Function |Description |
  367. |--------------------------------------------|-------------|
  368. |`rgb_matrix_increase_hue()` |Increase the hue for effect range LEDs. This wraps around at maximum hue |
  369. |`rgb_matrix_increase_hue_noeeprom()` |Increase the hue for effect range LEDs. This wraps around at maximum hue (not written to EEPROM) |
  370. |`rgb_matrix_decrease_hue()` |Decrease the hue for effect range LEDs. This wraps around at minimum hue |
  371. |`rgb_matrix_decrease_hue_noeeprom()` |Decrease the hue for effect range LEDs. This wraps around at minimum hue (not written to EEPROM) |
  372. |`rgb_matrix_increase_sat()` |Increase the saturation for effect range LEDs. This wraps around at maximum saturation |
  373. |`rgb_matrix_increase_sat_noeeprom()` |Increase the saturation for effect range LEDs. This wraps around at maximum saturation (not written to EEPROM) |
  374. |`rgb_matrix_decrease_sat()` |Decrease the saturation for effect range LEDs. This wraps around at minimum saturation |
  375. |`rgb_matrix_decrease_sat_noeeprom()` |Decrease the saturation for effect range LEDs. This wraps around at minimum saturation (not written to EEPROM) |
  376. |`rgb_matrix_increase_val()` |Increase the value for effect range LEDs. This wraps around at maximum value |
  377. |`rgb_matrix_increase_val_noeeprom()` |Increase the value for effect range LEDs. This wraps around at maximum value (not written to EEPROM) |
  378. |`rgb_matrix_decrease_val()` |Decrease the value for effect range LEDs. This wraps around at minimum value |
  379. |`rgb_matrix_decrease_val_noeeprom()` |Decrease the value for effect range LEDs. This wraps around at minimum value (not written to EEPROM) |
  380. |`rgb_matrix_sethsv(h, s, v)` |Set LEDs to the given HSV value where `h`/`s`/`v` are between 0 and 255 |
  381. |`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) |
  382. ### Query Current Status :id=query-current-status
  383. |Function |Description |
  384. |---------------------------------|---------------------------|
  385. |`rgb_matrix_is_enabled()` |Gets current on/off status |
  386. |`rgb_matrix_get_mode()` |Gets current mode |
  387. |`rgb_matrix_get_hue()` |Gets current hue |
  388. |`rgb_matrix_get_sat()` |Gets current sat |
  389. |`rgb_matrix_get_val()` |Gets current val |
  390. |`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)|
  391. |`rgb_matrix_get_speed()` |Gets current speed |
  392. |`rgb_matrix_get_suspend_state()` |Gets current suspend state |
  393. ## Callbacks :id=callbacks
  394. ### Indicators :id=indicators
  395. 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:
  396. ```c
  397. void rgb_matrix_indicators_kb(void) {
  398. rgb_matrix_set_color(index, red, green, blue);
  399. }
  400. ```
  401. 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)`.
  402. ```c
  403. void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
  404. RGB_MATRIX_INDICATOR_SET_COLOR(index, red, green, blue);
  405. }
  406. ```
  407. ### Suspended state :id=suspended-state
  408. To use the suspend feature, make sure that `#define RGB_DISABLE_WHEN_USB_SUSPENDED true` is added to the `config.h` file.
  409. Additionally add this to your `<keyboard>.c`:
  410. ```c
  411. void suspend_power_down_kb(void) {
  412. rgb_matrix_set_suspend_state(true);
  413. suspend_power_down_user();
  414. }
  415. void suspend_wakeup_init_kb(void) {
  416. rgb_matrix_set_suspend_state(false);
  417. suspend_wakeup_init_user();
  418. }
  419. ```
  420. or add this to your `keymap.c`:
  421. ```c
  422. void suspend_power_down_user(void) {
  423. rgb_matrix_set_suspend_state(true);
  424. }
  425. void suspend_wakeup_init_user(void) {
  426. rgb_matrix_set_suspend_state(false);
  427. }
  428. ```