From 50f634a772d3d9ac0ec497496acac7b60d612629 Mon Sep 17 00:00:00 2001 From: James Thomson Date: Sat, 8 Oct 2022 23:59:40 +0100 Subject: [PATCH 1/2] Fix boundary in `RGB_MATRIX_INDICATOR_SET_COLOR` Exclude index equal to `led_max` as it is 1 greater than the index of the last/max LED. --- quantum/rgb_matrix/rgb_matrix.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h index fc9fc3e020e9..c6b4c26ac68e 100644 --- a/quantum/rgb_matrix/rgb_matrix.h +++ b/quantum/rgb_matrix/rgb_matrix.h @@ -81,7 +81,7 @@ #endif #define RGB_MATRIX_INDICATOR_SET_COLOR(i, r, g, b) \ - if (i >= led_min && i <= led_max) { \ + if (i >= led_min && i < led_max) { \ rgb_matrix_set_color(i, r, g, b); \ } From c1f5c01baae2df8280ec70b1cf0b816302ae51c4 Mon Sep 17 00:00:00 2001 From: James Thomson Date: Mon, 10 Oct 2022 19:41:59 +0100 Subject: [PATCH 2/2] Update Markdown examples --- docs/feature_rgb_matrix.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md index 31f0a2cbc555..0716917bae40 100644 --- a/docs/feature_rgb_matrix.md +++ b/docs/feature_rgb_matrix.md @@ -908,7 +908,7 @@ Caps Lock indicator on alphanumeric flagged keys: ```c void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { if (host_keyboard_led_state().caps_lock) { - for (uint8_t i = led_min; i <= led_max; i++) { + for (uint8_t i = led_min; i < led_max; i++) { if (g_led_config.flags[i] & LED_FLAG_KEYLIGHT) { rgb_matrix_set_color(i, RGB_RED); } @@ -920,7 +920,7 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { Layer indicator on all keys: ```c void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { - for (uint8_t i = led_min; i <= led_max; i++) { + for (uint8_t i = led_min; i < led_max; i++) { switch(get_highest_layer(layer_state|default_layer_state)) { case 2: rgb_matrix_set_color(i, RGB_BLUE); @@ -945,7 +945,7 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { 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 && + 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); } @@ -976,7 +976,7 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { } RGB rgb = hsv_to_rgb(hsv); - for (uint8_t i = led_min; i <= led_max; i++) { + for (uint8_t i = led_min; i < led_max; i++) { if (HAS_FLAGS(g_led_config.flags[i], 0x01)) { // 0x01 == LED_FLAG_MODIFIER rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); }