aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2021-05-13 12:57:57 +1000
committerGitHub <noreply@github.com>2021-05-13 12:57:57 +1000
commit7078d5a5bdf9a639003a124342de567c976182ff (patch)
treef1b1507815f1664f898278a6f2ecf7cc3572a197
parentdbfe2d7e9ebcaa8b10203220a4213d0a750ffbba (diff)
downloadqmk_firmware-7078d5a5bdf9a639003a124342de567c976182ff.tar.gz
qmk_firmware-7078d5a5bdf9a639003a124342de567c976182ff.zip
LED Matrix: Documentation (#12685)
-rw-r--r--docs/feature_led_matrix.md356
-rw-r--r--docs/feature_rgb_matrix.md4
2 files changed, 313 insertions, 47 deletions
diff --git a/docs/feature_led_matrix.md b/docs/feature_led_matrix.md
index ac2be2e77..7834b940d 100644
--- a/docs/feature_led_matrix.md
+++ b/docs/feature_led_matrix.md
@@ -1,34 +1,21 @@
1# LED Matrix Lighting 1# LED Matrix Lighting :id=led-matrix-lighting
2 2
3This feature allows you to use LED matrices driven by external drivers. It hooks into the backlight system so you can use the same keycodes as backlighting to control it. 3This feature allows you to use LED matrices driven by external drivers. It hooks into the backlight system so you can use the same keycodes as backlighting to control it.
4 4
5If you want to use RGB LED's you should use the [RGB Matrix Subsystem](feature_rgb_matrix.md) instead. 5If you want to use RGB LED's you should use the [RGB Matrix Subsystem](feature_rgb_matrix.md) instead.
6 6
7## Driver configuration 7## Driver configuration :id=driver-configuration
8---
9### IS31FL3731 :id=is31fl3731
8 10
9### IS31FL3731 11There is basic support for addressable LED matrix lighting with the I2C IS31FL3731 LED controller. To enable it, add this to your `rules.mk`:
10
11There is basic support for addressable LED matrix lighting with the I2C IS31FL3731 RGB controller. To enable it, add this to your `rules.mk`:
12 12
13```make 13```make
14LED_MATRIX_ENABLE = yes 14LED_MATRIX_ENABLE = yes
15LED_MATRIX_DRIVER = IS31FL3731 15LED_MATRIX_DRIVER = IS31FL3731
16``` 16```
17 17
18You can use between 1 and 4 IS31FL3731 IC's. Do not specify `LED_DRIVER_ADDR_<N>` defines for IC's that are not present on your keyboard. You can define the following items in `config.h`: 18Configure the hardware via your `config.h`:
19
20| Variable | Description | Default |
21|----------|-------------|---------|
22| `ISSI_TIMEOUT` | (Optional) How long to wait for i2c messages | 100 |
23| `ISSI_PERSISTENCE` | (Optional) Retry failed messages this many times | 0 |
24| `LED_DRIVER_COUNT` | (Required) How many LED driver IC's are present | |
25| `DRIVER_LED_TOTAL` | (Required) How many LED lights are present across all drivers | |
26| `LED_DRIVER_ADDR_1` | (Required) Address for the first LED driver | |
27| `LED_DRIVER_ADDR_2` | (Optional) Address for the second LED driver | |
28| `LED_DRIVER_ADDR_3` | (Optional) Address for the third LED driver | |
29| `LED_DRIVER_ADDR_4` | (Optional) Address for the fourth LED driver | |
30
31Here is an example using 2 drivers.
32 19
33```c 20```c
34// This is a 7-bit address, that gets left-shifted and bit 0 21// This is a 7-bit address, that gets left-shifted and bit 0
@@ -38,63 +25,342 @@ Here is an example using 2 drivers.
38// 0b1110111 AD <-> VCC 25// 0b1110111 AD <-> VCC
39// 0b1110101 AD <-> SCL 26// 0b1110101 AD <-> SCL
40// 0b1110110 AD <-> SDA 27// 0b1110110 AD <-> SDA
41#define LED_DRIVER_ADDR_1 0b1110100 28#define DRIVER_ADDR_1 0b1110100
42#define LED_DRIVER_ADDR_2 0b1110110 29#define DRIVER_ADDR_2 0b1110110
43 30
44#define LED_DRIVER_COUNT 2 31#define DRIVER_COUNT 2
45#define LED_DRIVER_1_LED_COUNT 25 32#define DRIVER_1_LED_TOTAL 25
46#define LED_DRIVER_2_LED_COUNT 24 33#define DRIVER_2_LED_TOTAL 24
47#define DRIVER_LED_TOTAL LED_DRIVER_1_LED_TOTAL + LED_DRIVER_2_LED_TOTAL 34#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
48``` 35```
49 36
37!> 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`.
38
50Currently only 2 drivers are supported, but it would be trivial to support all 4 combinations. 39Currently only 2 drivers are supported, but it would be trivial to support all 4 combinations.
51 40
52Define these arrays listing all the LEDs in your `<keyboard>.c`: 41Define these arrays listing all the LEDs in your `<keyboard>.c`:
53 42
54```c 43```c
55 const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { 44const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
56 /* Refer to IS31 manual for these locations 45/* Refer to IS31 manual for these locations
57 * driver 46 * driver
58 * | LED address 47 * | LED address
59 * | | */ 48 * | | */
60 { 0, C1_1 }, 49 { 0, C1_1 },
61 { 0, C1_15 }, 50 { 0, C1_15 },
62 // ... 51 // ...
63 } 52}
64``` 53```
65 54
66Where `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-simple.h`. The `driver` is the index of the driver you defined in your `config.h` (`0`, `1`, `2`, or `3` ). 55Where `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-simple.h`. The `driver` is the index of the driver you defined in your `config.h` (`0`, `1`, `2`, or `3` ).
67 56
68## Keycodes 57---
58
59From 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:
60
61```c
62led_config_t g_led_config = { {
63 // Key Matrix to LED Index
64 { 5, NO_LED, NO_LED, 0 },
65 { NO_LED, NO_LED, NO_LED, NO_LED },
66 { 4, NO_LED, NO_LED, 1 },
67 { 3, NO_LED, NO_LED, 2 }
68}, {
69 // LED Index to Physical Position
70 { 188, 16 }, { 187, 48 }, { 149, 64 }, { 112, 64 }, { 37, 48 }, { 38, 16 }
71}, {
72 // LED Index to Flag
73 1, 4, 4, 4, 4, 1
74} };
75```
76
77The 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:
78
79```c
80x = 224 / (NUMBER_OF_COLS - 1) * COL_POSITION
81y = 64 / (NUMBER_OF_ROWS - 1) * ROW_POSITION
82```
83
84Where NUMBER_OF_COLS, NUMBER_OF_ROWS, COL_POSITION, & ROW_POSITION are all based on the physical layout of your keyboard, not the electrical layout.
85
86As 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 LED_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.
87
88`// 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.
89
90## Flags :id=flags
91
92|Define |Value |Description |
93|----------------------------|------|-------------------------------------------------|
94|`HAS_FLAGS(bits, flags)` |*n/a* |Evaluates to `true` if `bits` has all `flags` set|
95|`HAS_ANY_FLAGS(bits, flags)`|*n/a* |Evaluates to `true` if `bits` has any `flags` set|
96|`LED_FLAG_NONE` |`0x00`|If this LED has no flags |
97|`LED_FLAG_ALL` |`0xFF`|If this LED has all flags |
98|`LED_FLAG_MODIFIER` |`0x01`|If the LED is on a modifier key |
99|`LED_FLAG_KEYLIGHT` |`0x04`|If the LED is for key backlight |
100|`LED_FLAG_INDICATOR` |`0x08`|If the LED is for keyboard state indication |
101
102## Keycodes :id=keycodes
103
104All LED matrix keycodes are currently shared with the [Backlight feature](feature_backlight.md).
105
106|Key |Description |
107|---------|-----------------------------|
108|`BL_TOGG`|Toggle LED Matrix on or off |
109|`BL_STEP`|Cycle through modes |
110|`BL_ON` |Turn on LED Matrix |
111|`BL_OFF` |Turn off LED Matrix |
112|`BL_INC` |Increase the brightness level|
113|`BL_DEC` |Decrease the brightness level|
69 114
70All LED matrix keycodes are currently shared with the [backlight system](feature_backlight.md). 115## LED Matrix Effects :id=led-matrix-effects
71 116
72## LED Matrix Effects 117These are the effects that are currently available:
73 118
74Currently no LED matrix effects have been created. 119```c
120enum led_matrix_effects {
121 LED_MATRIX_NONE = 0,
122 LED_MATRIX_SOLID = 1, // Static single val, no speed support
123 LED_MATRIX_ALPHAS_MODS, // Static dual val, speed is val for LEDs marked as modifiers
124 LED_MATRIX_BREATHING, // Cycling brightness animation
125 LED_MATRIX_BAND, // Band fading brightness scrolling left to right
126 LED_MATRIX_BAND_PINWHEEL, // 3 blade spinning pinwheel fades brightness
127 LED_MATRIX_BAND_SPIRAL, // Spinning spiral fades brightness
128 LED_MATRIX_CYCLE_LEFT_RIGHT, // Full gradient scrolling left to right
129 LED_MATRIX_CYCLE_UP_DOWN, // Full gradient scrolling top to bottom
130 LED_MATRIX_CYCLE_OUT_IN, // Full gradient scrolling out to in
131 LED_MATRIX_DUAL_BEACON, // Full gradient spinning around center of keyboard
132#if defined(LED_MATRIX_KEYPRESSES) || defined(LED_MATRIX_KEYRELEASES)
133 LED_MATRIX_SOLID_REACTIVE_SIMPLE, // Pulses keys hit then fades out
134 LED_MATRIX_SOLID_REACTIVE_WIDE // Value pulses near a single key hit then fades out
135 LED_MATRIX_SOLID_REACTIVE_MULTIWIDE // Value pulses near multiple key hits then fades out
136 LED_MATRIX_SOLID_REACTIVE_CROSS // Value pulses the same column and row of a single key hit then fades out
137 LED_MATRIX_SOLID_REACTIVE_MULTICROSS // Value pulses the same column and row of multiple key hits then fades out
138 LED_MATRIX_SOLID_REACTIVE_NEXUS // Value pulses away on the same column and row of a single key hit then fades out
139 LED_MATRIX_SOLID_REACTIVE_MULTINEXUS // Value pulses away on the same column and row of multiple key hits then fades out
140 LED_MATRIX_SOLID_SPLASH, // Value pulses away from a single key hit then fades out
141 LED_MATRIX_SOLID_MULTISPLASH, // Value pulses away from multiple key hits then fades out
142#endif
143 LED_MATRIX_WAVE_LEFT_RIGHT // Sine wave scrolling from left to right
144 LED_MATRIX_WAVE_UP_DOWN // Sine wave scrolling from up to down
145 LED_MATRIX_EFFECT_MAX
146};
147```
148
149You can disable a single effect by defining `DISABLE_[EFFECT_NAME]` in your `config.h`:
150
151
152|Define |Description |
153|-------------------------------------------------------|-----------------------------------------------|
154|`#define DISABLE_LED_MATRIX_SOLID` |Disables `LED_MATRIX_SOLID` |
155|`#define DISABLE_LED_MATRIX_ALPHAS_MODS` |Disables `LED_MATRIX_ALPHAS_MODS` |
156|`#define DISABLE_LED_MATRIX_BREATHING` |Disables `LED_MATRIX_BREATHING` |
157|`#define DISABLE_LED_MATRIX_BAND` |Disables `LED_MATRIX_BAND` |
158|`#define DISABLE_LED_MATRIX_BAND_PINWHEEL` |Disables `LED_MATRIX_BAND_PINWHEEL` |
159|`#define DISABLE_LED_MATRIX_BAND_SPIRAL` |Disables `LED_MATRIX_BAND_SPIRAL` |
160|`#define DISABLE_LED_MATRIX_CYCLE_LEFT_RIGHT` |Disables `LED_MATRIX_CYCLE_LEFT_RIGHT` |
161|`#define DISABLE_LED_MATRIX_CYCLE_UP_DOWN` |Disables `LED_MATRIX_CYCLE_UP_DOWN` |
162|`#define DISABLE_LED_MATRIX_CYCLE_OUT_IN` |Disables `LED_MATRIX_CYCLE_OUT_IN` |
163|`#define DISABLE_LED_MATRIX_DUAL_BEACON` |Disables `LED_MATRIX_DUAL_BEACON` |
164|`#define DISABLE_LED_MATRIX_SOLID_REACTIVE_SIMPLE` |Disables `LED_MATRIX_SOLID_REACTIVE_SIMPLE` |
165|`#define DISABLE_LED_MATRIX_SOLID_REACTIVE_WIDE` |Disables `LED_MATRIX_SOLID_REACTIVE_WIDE` |
166|`#define DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE` |Disables `LED_MATRIX_SOLID_REACTIVE_MULTIWIDE` |
167|`#define DISABLE_LED_MATRIX_SOLID_REACTIVE_CROSS` |Disables `LED_MATRIX_SOLID_REACTIVE_CROSS` |
168|`#define DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTICROSS` |Disables `LED_MATRIX_SOLID_REACTIVE_MULTICROSS`|
169|`#define DISABLE_LED_MATRIX_SOLID_REACTIVE_NEXUS` |Disables `LED_MATRIX_SOLID_REACTIVE_NEXUS` |
170|`#define DISABLE_LED_MATRIX_SOLID_REACTIVE_MULTINEXUS` |Disables `LED_MATRIX_SOLID_REACTIVE_MULTINEXUS`|
171|`#define DISABLE_LED_MATRIX_SOLID_SPLASH` |Disables `LED_MATRIX_SOLID_SPLASH` |
172|`#define DISABLE_LED_MATRIX_SOLID_MULTISPLASH` |Disables `LED_MATRIX_SOLID_MULTISPLASH` |
173|`#define DISABLE_LED_MATRIX_WAVE_LEFT_RIGHT` |Disables `LED_MATRIX_WAVE_LEFT_RIGHT` |
174|`#define DISABLE_LED_MATRIX_WAVE_UP_DOWN` |Disables `LED_MATRIX_WAVE_UP_DOWN` |
175
176## Custom LED Matrix Effects :id=custom-led-matrix-effects
75 177
76## Custom Layer Effects 178By setting `LED_MATRIX_CUSTOM_USER` (and/or `LED_MATRIX_CUSTOM_KB`) in `rules.mk`, new effects can be defined directly from userspace, without having to edit any QMK core files.
77 179
78Custom layer effects can be done by defining this in your `<keyboard>.c`: 180To declare new effects, create a new `led_matrix_user/kb.inc` that looks something like this:
181
182`led_matrix_user.inc` should go in the root of the keymap directory.
183`led_matrix_kb.inc` should go in the root of the keyboard directory.
184
185To use custom effects in your code, simply prepend `LED_MATRIX_CUSTOM_` to the effect name specified in `LED_MATRIX_EFFECT()`. For example, an effect declared as `LED_MATRIX_EFFECT(my_cool_effect)` would be referenced with:
186
187```c
188led_matrix_mode(led_MATRIX_CUSTOM_my_cool_effect);
189```
79 190
80```c 191```c
192// !!! DO NOT ADD #pragma once !!! //
193
194// Step 1.
195// Declare custom effects using the LED_MATRIX_EFFECT macro
196// (note the lack of semicolon after the macro!)
197LED_MATRIX_EFFECT(my_cool_effect)
198LED_MATRIX_EFFECT(my_cool_effect2)
199
200// Step 2.
201// Define effects inside the `LED_MATRIX_CUSTOM_EFFECT_IMPLS` ifdef block
202#ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS
203
204// e.g: A simple effect, self-contained within a single method
205static bool my_cool_effect(effect_params_t* params) {
206 LED_MATRIX_USE_LIMITS(led_min, led_max);
207 for (uint8_t i = led_min; i < led_max; i++) {
208 led_matrix_set_value(i, 0xFF);
209 }
210 return led_max < DRIVER_LED_TOTAL;
211}
212
213// e.g: A more complex effect, relying on external methods and state, with
214// dedicated init and run methods
215static uint8_t some_global_state;
216static void my_cool_effect2_complex_init(effect_params_t* params) {
217 some_global_state = 1;
218}
219static bool my_cool_effect2_complex_run(effect_params_t* params) {
220 LED_MATRIX_USE_LIMITS(led_min, led_max);
221 for (uint8_t i = led_min; i < led_max; i++) {
222 led_matrix_set_value(i, some_global_state++);
223 }
224
225 return led_max < DRIVER_LED_TOTAL;
226}
227static bool my_cool_effect2(effect_params_t* params) {
228 if (params->init) my_cool_effect2_complex_init(params);
229 return my_cool_effect2_complex_run(params);
230}
231
232#endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
233```
234
235For inspiration and examples, check out the built-in effects under `quantum/led_matrix_animations/`
236
237
238
239
240
241
242
243
244
245## Additional `config.h` Options :id=additional-configh-options
246
247```c
248#define LED_MATRIX_KEYPRESSES // reacts to keypresses
249#define LED_MATRIX_KEYRELEASES // reacts to keyreleases (instead of keypresses)
250#define LED_DISABLE_TIMEOUT 0 // number of milliseconds to wait until led automatically turns off
251#define LED_DISABLE_AFTER_TIMEOUT 0 // OBSOLETE: number of ticks to wait until disabling effects
252#define LED_DISABLE_WHEN_USB_SUSPENDED false // turn off effects when suspended
253#define LED_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)
254#define LED_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)
255#define LED_MATRIX_MAXIMUM_BRIGHTNESS 255 // limits maximum brightness of LEDs
256#define LED_MATRIX_STARTUP_MODE LED_MATRIX_SOLID // Sets the default mode, if none has been set
257#define LED_MATRIX_STARTUP_VAL LED_MATRIX_MAXIMUM_BRIGHTNESS // Sets the default brightness value, if none has been set
258#define LED_MATRIX_STARTUP_SPD 127 // Sets the default animation speed, if none has been set
259#define LED_MATRIX_SPLIT { X, Y } // (Optional) For split keyboards, the number of LEDs connected on each half. X = left, Y = Right.
260 // If LED_MATRIX_KEYPRESSES or LED_MATRIX_KEYRELEASES is enabled, you also will want to enable SPLIT_TRANSPORT_MIRROR
261```
262
263## EEPROM storage :id=eeprom-storage
264
265The EEPROM for it is currently shared with the RGB 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:
266
267```c
268#define EECONFIG_LED_MATRIX (uint32_t *)28
269```
270
271Where `28` is an unused index from `eeconfig.h`.
272
273### Direct Operation :id=direct-operation
274|Function |Description |
275|--------------------------------------------|-------------|
276|`led_matrix_set_value_all(v)` |Set all of the LEDs to the given value, where `v` is between 0 and 255 (not written to EEPROM) |
277|`led_matrix_set_value(index, v)` |Set a single LED to the given value, where `v` is between 0 and 255, and `index` is between 0 and `DRIVER_LED_TOTAL` (not written to EEPROM) |
278
279### Disable/Enable Effects :id=disable-enable-effects
280|Function |Description |
281|--------------------------------------------|-------------|
282|`led_matrix_toggle()` |Toggle effect range LEDs between on and off |
283|`led_matrix_toggle_noeeprom()` |Toggle effect range LEDs between on and off (not written to EEPROM) |
284|`led_matrix_enable()` |Turn effect range LEDs on, based on their previous state |
285|`led_matrix_enable_noeeprom()` |Turn effect range LEDs on, based on their previous state (not written to EEPROM) |
286|`led_matrix_disable()` |Turn effect range LEDs off, based on their previous state |
287|`led_matrix_disable_noeeprom()` |Turn effect range LEDs off, based on their previous state (not written to EEPROM) |
288
289### Change Effect Mode :id=change-effect-mode
290|Function |Description |
291|--------------------------------------------|-------------|
292|`led_matrix_mode(mode)` |Set the mode, if LED animations are enabled |
293|`led_matrix_mode_noeeprom(mode)` |Set the mode, if LED animations are enabled (not written to EEPROM) |
294|`led_matrix_step()` |Change the mode to the next LED animation in the list of enabled LED animations |
295|`led_matrix_step_noeeprom()` |Change the mode to the next LED animation in the list of enabled LED animations (not written to EEPROM) |
296|`led_matrix_step_reverse()` |Change the mode to the previous LED animation in the list of enabled LED animations |
297|`led_matrix_step_reverse_noeeprom()` |Change the mode to the previous LED animation in the list of enabled LED animations (not written to EEPROM) |
298|`led_matrix_increase_speed()` |Increase the speed of the animations |
299|`led_matrix_increase_speed_noeeprom()` |Increase the speed of the animations (not written to EEPROM) |
300|`led_matrix_decrease_speed()` |Decrease the speed of the animations |
301|`led_matrix_decrease_speed_noeeprom()` |Decrease the speed of the animations (not written to EEPROM) |
302|`led_matrix_set_speed(speed)` |Set the speed of the animations to the given value where `speed` is between 0 and 255 |
303|`led_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) |
304
305### Change Value :id=change-value
306|Function |Description |
307|--------------------------------------------|-------------|
308|`led_matrix_increase_val()` |Increase the value for effect range LEDs. This wraps around at maximum value |
309|`led_matrix_increase_val_noeeprom()` |Increase the value for effect range LEDs. This wraps around at maximum value (not written to EEPROM) |
310|`led_matrix_decrease_val()` |Decrease the value for effect range LEDs. This wraps around at minimum value |
311|`led_matrix_decrease_val_noeeprom()` |Decrease the value for effect range LEDs. This wraps around at minimum value (not written to EEPROM) |
312
313### Query Current Status :id=query-current-status
314|Function |Description |
315|---------------------------------|---------------------------|
316|`led_matrix_is_enabled()` |Gets current on/off status |
317|`led_matrix_get_mode()` |Gets current mode |
318|`led_matrix_get_val()` |Gets current val |
319|`led_matrix_get_speed()` |Gets current speed |
320|`led_matrix_get_suspend_state()` |Gets current suspend state |
321
322## Callbacks :id=callbacks
323
324### Indicators :id=indicators
325
326If you want to set custom indicators, such as an LED for Caps Lock, or layer indication, you can use the `led_matrix_indicators_kb` or `led_matrix_indicators_user` function for that:
327```c
81void led_matrix_indicators_kb(void) { 328void led_matrix_indicators_kb(void) {
82 led_matrix_set_value(index, value); 329 led_matrix_set_color(index, value);
83} 330}
84``` 331```
85 332
86A similar function works in the keymap as `led_matrix_indicators_user`. 333In addition, there are the advanced indicator functions. These are aimed at those with heavily customized displays, where rendering every LED per cycle is expensive. This includes a special macro to help make this easier to use: `LED_MATRIX_INDICATOR_SET_VALUE(i, v)`.
334
335```c
336void led_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
337 LED_MATRIX_INDICATOR_SET_VALUE(index, value);
338}
339```
87 340
88## Suspended State 341## Suspended State :id=suspended-state
342To use the suspend feature, make sure that `#define LED_DISABLE_WHEN_USB_SUSPENDED true` is added to the `config.h` file.
89 343
90To use the suspend feature, add this to your `<keyboard>.c`: 344Additionally add this to your `<keyboard>.c`:
91 345
92```c 346```c
93void suspend_power_down_kb(void) { 347void suspend_power_down_kb(void) {
94 led_matrix_set_suspend_state(true); 348 led_matrix_set_suspend_state(true);
349 suspend_power_down_user();
95} 350}
96 351
97void suspend_wakeup_init_kb(void) { 352void suspend_wakeup_init_kb(void) {
98 led_matrix_set_suspend_state(false); 353 led_matrix_set_suspend_state(false);
354 suspend_wakeup_init_user();
355}
356```
357or add this to your `keymap.c`:
358```c
359void suspend_power_down_user(void) {
360 led_matrix_set_suspend_state(true);
361}
362
363void suspend_wakeup_init_user(void) {
364 led_matrix_set_suspend_state(false);
99} 365}
100``` \ No newline at end of file 366```
diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md
index 63ff7d6ad..ffbb8c0b6 100644
--- a/docs/feature_rgb_matrix.md
+++ b/docs/feature_rgb_matrix.md
@@ -399,7 +399,7 @@ static bool my_cool_effect2(effect_params_t* params) {
399#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS 399#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
400``` 400```
401 401
402For inspiration and examples, check out the built-in effects under `quantum/rgb_matrix_animation/` 402For inspiration and examples, check out the built-in effects under `quantum/rgb_matrix_animations/`
403 403
404 404
405## Colors :id=colors 405## Colors :id=colors
@@ -453,7 +453,7 @@ These are defined in [`rgblight_list.h`](https://github.com/qmk/qmk_firmware/blo
453 453
454## EEPROM storage :id=eeprom-storage 454## EEPROM storage :id=eeprom-storage
455 455
456The 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: 456The 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:
457 457
458```c 458```c
459#define EECONFIG_RGB_MATRIX (uint32_t *)28 459#define EECONFIG_RGB_MATRIX (uint32_t *)28