Skip to content

Commit 300dab7

Browse files
authored
[Code] Add solid reactive gradient mode (#17228)
1 parent 3c58f98 commit 300dab7

6 files changed

+25
-0
lines changed

docs/feature_rgb_matrix.md

+10
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,16 @@ Remove the spread effect entirely.
688688
#define RGB_MATRIX_TYPING_HEATMAP_SLIM
689689
```
690690

691+
### RGB Matrix Effect Solid Reactive :id=rgb-matrix-effect-solid-reactive
692+
693+
Solid reactive effects will pulse RGB light on key presses with user configurable hues. To enable gradient mode that will automatically change reactive color, add the following define:
694+
695+
```c
696+
#define RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
697+
```
698+
699+
Gradient mode will loop through the color wheel hues over time and its duration can be controlled with the effect speed keycodes (`RGB_SPI`/`RGB_SPD`).
700+
691701
## Custom RGB Matrix Effects :id=custom-rgb-matrix-effects
692702

693703
By setting `RGB_MATRIX_CUSTOM_USER = yes` in `rules.mk`, new effects can be defined directly from your keymap or userspace, without having to edit any QMK core files. To declare new effects, create a `rgb_matrix_user.inc` file in the user keymap directory or userspace folder.

quantum/rgb_matrix/animations/solid_reactive_anim.h

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE)
44
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
55

66
static HSV SOLID_REACTIVE_math(HSV hsv, uint16_t offset) {
7+
# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
8+
hsv.h = scale16by8(g_rgb_timer, add8(rgb_matrix_config.speed, 1) >> 6);
9+
# endif
710
hsv.h += qsub8(130, offset);
811
return hsv;
912
}

quantum/rgb_matrix/animations/solid_reactive_cross.h

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ static HSV SOLID_REACTIVE_CROSS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t di
1919
dy = dy * 16 > 255 ? 255 : dy * 16;
2020
effect += dx > dy ? dy : dx;
2121
if (effect > 255) effect = 255;
22+
# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
23+
hsv.h = scale16by8(g_rgb_timer, add8(rgb_matrix_config.speed, 1) >> 6);
24+
# endif
2225
hsv.v = qadd8(hsv.v, 255 - effect);
2326
return hsv;
2427
}

quantum/rgb_matrix/animations/solid_reactive_nexus.h

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ static HSV SOLID_REACTIVE_NEXUS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t di
1616
if (effect > 255) effect = 255;
1717
if (dist > 72) effect = 255;
1818
if ((dx > 8 || dx < -8) && (dy > 8 || dy < -8)) effect = 255;
19+
# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
20+
hsv.h = scale16by8(g_rgb_timer, add8(rgb_matrix_config.speed, 1) >> 6);
21+
# endif
1922
hsv.v = qadd8(hsv.v, 255 - effect);
2023
hsv.h = rgb_matrix_config.hsv.h + dy / 4;
2124
return hsv;

quantum/rgb_matrix/animations/solid_reactive_simple_anim.h

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE)
44
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
55

66
static HSV SOLID_REACTIVE_SIMPLE_math(HSV hsv, uint16_t offset) {
7+
# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
8+
hsv.h = scale16by8(g_rgb_timer, add8(rgb_matrix_config.speed, 1) >> 6);
9+
# endif
710
hsv.v = scale8(255 - offset, hsv.v);
811
return hsv;
912
}

quantum/rgb_matrix/animations/solid_reactive_wide.h

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTIWIDE)
1414
static HSV SOLID_REACTIVE_WIDE_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) {
1515
uint16_t effect = tick + dist * 5;
1616
if (effect > 255) effect = 255;
17+
# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
18+
hsv.h = scale16by8(g_rgb_timer, add8(rgb_matrix_config.speed, 1) >> 6);
19+
# endif
1720
hsv.v = qadd8(hsv.v, 255 - effect);
1821
return hsv;
1922
}

0 commit comments

Comments
 (0)