summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAlbert Y <76888457+filterpaper@users.noreply.github.com>2021-12-27 11:16:18 +0800
committerGitHub <noreply@github.com>2021-12-27 14:16:18 +1100
commite3073be4884c53bbd922477a83553d03f4eb7ebb (patch)
treeceb7266bbe85d45654cfcb65d907ea5a792f2535 /docs
parent58f7aefadd075d9cb335b99d24629744164013c7 (diff)
RGB Matrix layer key indicator (#14626)
* Add layer key indicator example * Update description * Deobfuscate with index variable * Add missing layer variable * Correct color name and indicator function * Function typo * Place layer variable outside loops to save firmware space Co-authored-by: filterpaper <filterpaper@localhost>
Diffstat (limited to 'docs')
-rw-r--r--docs/feature_rgb_matrix.md20
1 files changed, 20 insertions, 0 deletions
diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md
index 8ba39b476b..3132360a38 100644
--- a/docs/feature_rgb_matrix.md
+++ b/docs/feature_rgb_matrix.md
@@ -790,6 +790,26 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
}
```
+Layer indicator with only configured keys:
+```c
+void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
+ if (get_highest_layer(layer_state) > 0) {
+ uint8_t layer = get_highest_layer(layer_state);
+
+ for (uint8_t row = 0; row < MATRIX_ROWS; ++row) {
+ for (uint8_t col = 0; col < MATRIX_COLS; ++col) {
+ uint8_t index = g_led_config.matrix_co[row][col];
+
+ if (index >= led_min && index <= led_max && index != NO_LED &&
+ keymap_key_to_keycode(layer, (keypos_t){col,row}) > KC_TRNS) {
+ rgb_matrix_set_color(index, RGB_GREEN);
+ }
+ }
+ }
+ }
+}
+```
+
#### Examples :id=indicator-examples
This example sets the modifiers to be a specific color based on the layer state. You can use a switch case here, instead, if you would like. This uses HSV and then converts to RGB, because this allows the brightness to be limited (important when using the WS2812 driver).