From 221ac2eabbc73c9d59583c6d78c779bbfec0d7bc Mon Sep 17 00:00:00 2001 From: M-AS Date: Sun, 17 Mar 2019 13:38:51 -0400 Subject: [PATCH] New RGB Matrix effect: Single color reactive (#5330) * Adds new RGB Matrix effect: rgb_matrix_config'd reactive LEDs * [Docs] Adds disable for new effect * [Docs] Added new effect to list of effects --- docs/feature_rgb_matrix.md | 2 ++ quantum/rgb_matrix.c | 19 +++++++++++++++++++ quantum/rgb_matrix.h | 3 +++ 3 files changed, 24 insertions(+) diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md index 910a704691..8d1efb12a2 100644 --- a/docs/feature_rgb_matrix.md +++ b/docs/feature_rgb_matrix.md @@ -147,6 +147,7 @@ These are the effects that are currently available: RGB_MATRIX_DIGITAL_RAIN, #ifdef RGB_MATRIX_KEYPRESSES RGB_MATRIX_SOLID_REACTIVE, + RGB_MATRIX_REACTIVE_SIMPLE, RGB_MATRIX_SPLASH, RGB_MATRIX_MULTISPLASH, RGB_MATRIX_SOLID_SPLASH, @@ -173,6 +174,7 @@ You can disable a single effect by defining `DISABLE_[EFFECT_NAME]` in your `con |`#define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS` |Disables `RGB_MATRIX_JELLYBEAN_RAINDROPS` | |`#define DISABLE_RGB_MATRIX_DIGITAL_RAIN` |Disables `RGB_MATRIX_DIGITAL_RAIN` | |`#define DISABLE_RGB_MATRIX_SOLID_REACTIVE` |Disables `RGB_MATRIX_SOLID_REACTIVE` | +|`#define DISABLE_RGB_MATRIX_REACTIVE_SIMPLE` |Disables `RGB_MATRIX_REACTIVE_SIMPLE` | |`#define DISABLE_RGB_MATRIX_SPLASH` |Disables `RGB_MATRIX_SPLASH` | |`#define DISABLE_RGB_MATRIX_MULTISPLASH` |Disables `RGB_MATRIX_MULTISPLASH` | |`#define DISABLE_RGB_MATRIX_SOLID_SPLASH` |Disables `RGB_MATRIX_SOLID_SPLASH` | diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 2ed36304dc..56a97e3c7d 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -221,6 +221,20 @@ void rgb_matrix_solid_reactive(void) { } } +void rgb_matrix_solid_reactive_simple(void) +{ + HSV hsv = {.h = rgb_matrix_config.hue, .s = rgb_matrix_config.sat, .v = rgb_matrix_config.val}; + RGB rgb; + + for (int i = 0; i < DRIVER_LED_TOTAL; i++) { + uint16_t offset2 = g_key_hit[i] << 2; + offset2 = (offset2 <= 255) ? (255 - offset2) : 0; + hsv.v = offset2 * rgb_matrix_config.val / RGB_MATRIX_MAXIMUM_BRIGHTNESS; + rgb = hsv_to_rgb(hsv); + rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); + } +} + // alphas = color1, mods = color2 void rgb_matrix_alphas_mods(void) { @@ -755,6 +769,11 @@ void rgb_matrix_task(void) { rgb_matrix_solid_reactive(); break; #endif + #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE + case RGB_MATRIX_SOLID_REACTIVE_SIMPLE: + rgb_matrix_solid_reactive_simple(); + break; + #endif #ifndef DISABLE_RGB_MATRIX_SPLASH case RGB_MATRIX_SPLASH: rgb_matrix_splash(); diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h index e43532d11e..e6acd2d4b5 100644 --- a/quantum/rgb_matrix.h +++ b/quantum/rgb_matrix.h @@ -110,6 +110,9 @@ enum rgb_matrix_effects { #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE RGB_MATRIX_SOLID_REACTIVE, #endif + #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE + RGB_MATRIX_SOLID_REACTIVE_SIMPLE, + #endif #ifndef DISABLE_RGB_MATRIX_SPLASH RGB_MATRIX_SPLASH, #endif