From 62ba66d61821fec6a5ad3bdccdf738e15e082461 Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Fri, 10 May 2019 18:55:02 -0500 Subject: Cleanup/rgb matrix (#5811) * clean up rgb matrix extern usage Moved rgb matrix boiler plate into macros Rebased onto typing heatmap pr * Fixing the reversed frame buffer access in digital rain * Fixing digital rain & typing heatmap if keyreactive effects are not enabled * Apply suggestions from code review Co-Authored-By: Drashna Jaelre * Adding parenthesizes to DRIVER_LED_TOTAL where necessary * Updated docs * added notes about parentheses --- quantum/rgb_matrix_animations/solid_reactive_anim.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'quantum/rgb_matrix_animations/solid_reactive_anim.h') diff --git a/quantum/rgb_matrix_animations/solid_reactive_anim.h b/quantum/rgb_matrix_animations/solid_reactive_anim.h index c3dba8a5af..37e339907a 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_anim.h +++ b/quantum/rgb_matrix_animations/solid_reactive_anim.h @@ -1,12 +1,9 @@ -#pragma once -#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) +#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE +RGB_MATRIX_EFFECT(SOLID_REACTIVE) +#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -extern led_config_t g_led_config; -extern rgb_config_t rgb_matrix_config; -extern last_hit_t g_last_hit_tracker; - -bool rgb_matrix_solid_reactive(effect_params_t* params) { +bool SOLID_REACTIVE(effect_params_t* params) { RGB_MATRIX_USE_LIMITS(led_min, led_max); HSV hsv = { rgb_matrix_config.hue, 255, rgb_matrix_config.val }; @@ -32,5 +29,6 @@ bool rgb_matrix_solid_reactive(effect_params_t* params) { return led_max < DRIVER_LED_TOTAL; } -#endif // DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON -#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) +#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED -- cgit v1.2.3 From c9a7161d934979770792ff1e91ccfcc3508d240b Mon Sep 17 00:00:00 2001 From: Ryan Caltabiano Date: Sun, 19 May 2019 08:34:25 -0500 Subject: Reduce rgb matrix firmware size --- .../rgb_matrix_animations/solid_reactive_anim.h | 28 ++++------------------ 1 file changed, 5 insertions(+), 23 deletions(-) (limited to 'quantum/rgb_matrix_animations/solid_reactive_anim.h') diff --git a/quantum/rgb_matrix_animations/solid_reactive_anim.h b/quantum/rgb_matrix_animations/solid_reactive_anim.h index 37e339907a..762a95db31 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_anim.h +++ b/quantum/rgb_matrix_animations/solid_reactive_anim.h @@ -3,30 +3,12 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -bool SOLID_REACTIVE(effect_params_t* params) { - RGB_MATRIX_USE_LIMITS(led_min, led_max); - - HSV hsv = { rgb_matrix_config.hue, 255, rgb_matrix_config.val }; - // Max tick based on speed scale ensures results from scale16by8 with rgb_matrix_config.speed are no greater than 255 - uint16_t max_tick = 65535 / rgb_matrix_config.speed; - // Relies on hue being 8-bit and wrapping - for (uint8_t i = led_min; i < led_max; i++) { - RGB_MATRIX_TEST_LED_FLAGS(); - uint16_t tick = max_tick; - // Reverse search to find most recent key hit - for (int8_t j = g_last_hit_tracker.count - 1; j >= 0; j--) { - if (g_last_hit_tracker.index[j] == i && g_last_hit_tracker.tick[j] < tick) { - tick = g_last_hit_tracker.tick[j]; - break; - } - } +static void SOLID_REACTIVE_math(HSV* hsv, uint16_t offset) { + hsv->h = rgb_matrix_config.hue + qsub8(130, offset); +} - uint16_t offset = scale16by8(tick, rgb_matrix_config.speed); - hsv.h = rgb_matrix_config.hue + qsub8(130, offset); - RGB rgb = hsv_to_rgb(hsv); - rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); - } - return led_max < DRIVER_LED_TOTAL; +bool SOLID_REACTIVE(effect_params_t* params) { + return effect_runner_reactive(params, &SOLID_REACTIVE_math); } #endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -- cgit v1.2.3 From cf215487ba35c6754cd1c52bb900a46bb52ed3a3 Mon Sep 17 00:00:00 2001 From: Ryan Caltabiano Date: Sun, 19 May 2019 23:12:29 -0500 Subject: Switching rgb_config_t to use HSV struct --- quantum/rgb_matrix_animations/solid_reactive_anim.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'quantum/rgb_matrix_animations/solid_reactive_anim.h') diff --git a/quantum/rgb_matrix_animations/solid_reactive_anim.h b/quantum/rgb_matrix_animations/solid_reactive_anim.h index 762a95db31..dd49b6530e 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_anim.h +++ b/quantum/rgb_matrix_animations/solid_reactive_anim.h @@ -3,8 +3,9 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static void SOLID_REACTIVE_math(HSV* hsv, uint16_t offset) { - hsv->h = rgb_matrix_config.hue + qsub8(130, offset); +static HSV SOLID_REACTIVE_math(HSV hsv, uint16_t offset) { + hsv.h += qsub8(130, offset); + return hsv; } bool SOLID_REACTIVE(effect_params_t* params) { -- cgit v1.2.3