summaryrefslogtreecommitdiff
path: root/quantum/rgb_matrix_animations
diff options
context:
space:
mode:
authorXScorpion2 <rcalt2vt@gmail.com>2019-05-10 18:55:02 -0500
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>2019-05-10 16:55:02 -0700
commit62ba66d61821fec6a5ad3bdccdf738e15e082461 (patch)
tree4b0fb100299a7a7e9a51cbbe96da94df8a57483f /quantum/rgb_matrix_animations
parentfebaf9dec42ce4d4ade316f811145a291137ee94 (diff)
downloadqmk_firmware-62ba66d61821fec6a5ad3bdccdf738e15e082461.tar.gz
qmk_firmware-62ba66d61821fec6a5ad3bdccdf738e15e082461.zip
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 <drashna@live.com> * Adding parenthesizes to DRIVER_LED_TOTAL where necessary * Updated docs * added notes about parentheses
Diffstat (limited to 'quantum/rgb_matrix_animations')
-rw-r--r--quantum/rgb_matrix_animations/alpha_mods_anim.h9
-rw-r--r--quantum/rgb_matrix_animations/breathing_anim.h9
-rw-r--r--quantum/rgb_matrix_animations/cycle_all_anim.h10
-rw-r--r--quantum/rgb_matrix_animations/cycle_left_right_anim.h10
-rw-r--r--quantum/rgb_matrix_animations/cycle_up_down_anim.h10
-rw-r--r--quantum/rgb_matrix_animations/digital_rain_anim.h32
-rw-r--r--quantum/rgb_matrix_animations/dual_beacon_anim.h10
-rw-r--r--quantum/rgb_matrix_animations/gradient_up_down_anim.h10
-rw-r--r--quantum/rgb_matrix_animations/jellybean_raindrops_anim.h10
-rw-r--r--quantum/rgb_matrix_animations/rainbow_beacon_anim.h10
-rw-r--r--quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h10
-rw-r--r--quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h10
-rw-r--r--quantum/rgb_matrix_animations/raindrops_anim.h11
-rw-r--r--quantum/rgb_matrix_animations/rgb_matrix_effects.inc23
-rw-r--r--quantum/rgb_matrix_animations/solid_color_anim.h10
-rw-r--r--quantum/rgb_matrix_animations/solid_reactive_anim.h16
-rw-r--r--quantum/rgb_matrix_animations/solid_reactive_cross.h18
-rw-r--r--quantum/rgb_matrix_animations/solid_reactive_nexus.h18
-rw-r--r--quantum/rgb_matrix_animations/solid_reactive_simple_anim.h9
-rw-r--r--quantum/rgb_matrix_animations/solid_reactive_wide.h18
-rw-r--r--quantum/rgb_matrix_animations/solid_splash_anim.h18
-rw-r--r--quantum/rgb_matrix_animations/splash_anim.h19
-rw-r--r--quantum/rgb_matrix_animations/typing_heatmap_anim.h9
23 files changed, 169 insertions, 140 deletions
diff --git a/quantum/rgb_matrix_animations/alpha_mods_anim.h b/quantum/rgb_matrix_animations/alpha_mods_anim.h
index d7f6f4655b..0fee19aefc 100644
--- a/quantum/rgb_matrix_animations/alpha_mods_anim.h
+++ b/quantum/rgb_matrix_animations/alpha_mods_anim.h
@@ -1,11 +1,9 @@
-#pragma once
#ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS
-
-extern led_config_t g_led_config;
-extern rgb_config_t rgb_matrix_config;
+RGB_MATRIX_EFFECT(ALPHAS_MODS)
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
// alphas = color1, mods = color2
-bool rgb_matrix_alphas_mods(effect_params_t* params) {
+bool ALPHAS_MODS(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val };
@@ -24,4 +22,5 @@ bool rgb_matrix_alphas_mods(effect_params_t* params) {
return led_max < DRIVER_LED_TOTAL;
}
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // DISABLE_RGB_MATRIX_ALPHAS_MODS
diff --git a/quantum/rgb_matrix_animations/breathing_anim.h b/quantum/rgb_matrix_animations/breathing_anim.h
index 54d60f927d..c357b53031 100644
--- a/quantum/rgb_matrix_animations/breathing_anim.h
+++ b/quantum/rgb_matrix_animations/breathing_anim.h
@@ -1,10 +1,8 @@
-#pragma once
#ifndef DISABLE_RGB_MATRIX_BREATHING
+RGB_MATRIX_EFFECT(BREATHING)
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-extern rgb_counters_t g_rgb_counters;
-extern rgb_config_t rgb_matrix_config;
-
-bool rgb_matrix_breathing(effect_params_t* params) {
+bool BREATHING(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 8);
@@ -18,4 +16,5 @@ bool rgb_matrix_breathing(effect_params_t* params) {
return led_max < DRIVER_LED_TOTAL;
}
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // DISABLE_RGB_MATRIX_BREATHING
diff --git a/quantum/rgb_matrix_animations/cycle_all_anim.h b/quantum/rgb_matrix_animations/cycle_all_anim.h
index e93798f900..e6319cad7f 100644
--- a/quantum/rgb_matrix_animations/cycle_all_anim.h
+++ b/quantum/rgb_matrix_animations/cycle_all_anim.h
@@ -1,11 +1,8 @@
-#pragma once
#ifndef DISABLE_RGB_MATRIX_CYCLE_ALL
+RGB_MATRIX_EFFECT(CYCLE_ALL)
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-extern rgb_counters_t g_rgb_counters;
-extern led_config_t g_led_config;
-extern rgb_config_t rgb_matrix_config;
-
-bool rgb_matrix_cycle_all(effect_params_t* params) {
+bool CYCLE_ALL(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
@@ -18,4 +15,5 @@ bool rgb_matrix_cycle_all(effect_params_t* params) {
return led_max < DRIVER_LED_TOTAL;
}
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // DISABLE_RGB_MATRIX_CYCLE_ALL
diff --git a/quantum/rgb_matrix_animations/cycle_left_right_anim.h b/quantum/rgb_matrix_animations/cycle_left_right_anim.h
index 4b09d5826b..d9a00530a0 100644
--- a/quantum/rgb_matrix_animations/cycle_left_right_anim.h
+++ b/quantum/rgb_matrix_animations/cycle_left_right_anim.h
@@ -1,11 +1,8 @@
-#pragma once
#ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
+RGB_MATRIX_EFFECT(CYCLE_LEFT_RIGHT)
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-extern rgb_counters_t g_rgb_counters;
-extern led_config_t g_led_config;
-extern rgb_config_t rgb_matrix_config;
-
-bool rgb_matrix_cycle_left_right(effect_params_t* params) {
+bool CYCLE_LEFT_RIGHT(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
@@ -19,4 +16,5 @@ bool rgb_matrix_cycle_left_right(effect_params_t* params) {
return led_max < DRIVER_LED_TOTAL;
}
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
diff --git a/quantum/rgb_matrix_animations/cycle_up_down_anim.h b/quantum/rgb_matrix_animations/cycle_up_down_anim.h
index 403214bb73..f2b31d9da5 100644
--- a/quantum/rgb_matrix_animations/cycle_up_down_anim.h
+++ b/quantum/rgb_matrix_animations/cycle_up_down_anim.h
@@ -1,11 +1,8 @@
-#pragma once
#ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN
+RGB_MATRIX_EFFECT(CYCLE_UP_DOWN)
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-extern rgb_counters_t g_rgb_counters;
-extern led_config_t g_led_config;
-extern rgb_config_t rgb_matrix_config;
-
-bool rgb_matrix_cycle_up_down(effect_params_t* params) {
+bool CYCLE_UP_DOWN(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
@@ -19,4 +16,5 @@ bool rgb_matrix_cycle_up_down(effect_params_t* params) {
return led_max < DRIVER_LED_TOTAL;
}
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // DISABLE_RGB_MATRIX_CYCLE_UP_DOWN
diff --git a/quantum/rgb_matrix_animations/digital_rain_anim.h b/quantum/rgb_matrix_animations/digital_rain_anim.h
index 6ccba392aa..982399cbde 100644
--- a/quantum/rgb_matrix_animations/digital_rain_anim.h
+++ b/quantum/rgb_matrix_animations/digital_rain_anim.h
@@ -1,14 +1,13 @@
-#pragma once
#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_DIGITAL_RAIN)
+RGB_MATRIX_EFFECT(DIGITAL_RAIN)
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#ifndef RGB_DIGITAL_RAIN_DROPS
// lower the number for denser effect/wider keyboard
#define RGB_DIGITAL_RAIN_DROPS 24
#endif
-extern uint8_t rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS];
-
-bool rgb_matrix_digital_rain(effect_params_t* params) {
+bool DIGITAL_RAIN(effect_params_t* params) {
// algorithm ported from https://github.com/tremby/Kaleidoscope-LEDEffect-DigitalRain
const uint8_t drop_ticks = 28;
const uint8_t pure_green_intensity = 0xd0;
@@ -19,7 +18,7 @@ bool rgb_matrix_digital_rain(effect_params_t* params) {
if (params->init) {
rgb_matrix_set_color_all(0, 0, 0);
- memset(rgb_frame_buffer, 0, sizeof rgb_frame_buffer);
+ memset(rgb_frame_buffer, 0, sizeof(rgb_frame_buffer));
drop = 0;
}
@@ -28,11 +27,11 @@ bool rgb_matrix_digital_rain(effect_params_t* params) {
if (row == 0 && drop == 0 && rand() < RAND_MAX / RGB_DIGITAL_RAIN_DROPS) {
// top row, pixels have just fallen and we're
// making a new rain drop in this column
- rgb_frame_buffer[col][row] = max_intensity;
+ rgb_frame_buffer[row][col] = max_intensity;
}
- else if (rgb_frame_buffer[col][row] > 0 && rgb_frame_buffer[col][row] < max_intensity) {
+ else if (rgb_frame_buffer[row][col] > 0 && rgb_frame_buffer[row][col] < max_intensity) {
// neither fully bright nor dark, decay it
- rgb_frame_buffer[col][row]--;
+ rgb_frame_buffer[row][col]--;
}
// set the pixel colour
uint8_t led[LED_HITS_TO_REMEMBER];
@@ -40,12 +39,12 @@ bool rgb_matrix_digital_rain(effect_params_t* params) {
// TODO: multiple leds are supported mapped to the same row/column
if (led_count > 0) {
- if (rgb_frame_buffer[col][row] > pure_green_intensity) {
- const uint8_t boost = (uint8_t) ((uint16_t) max_brightness_boost * (rgb_frame_buffer[col][row] - pure_green_intensity) / (max_intensity - pure_green_intensity));
+ if (rgb_frame_buffer[row][col] > pure_green_intensity) {
+ const uint8_t boost = (uint8_t) ((uint16_t) max_brightness_boost * (rgb_frame_buffer[row][col] - pure_green_intensity) / (max_intensity - pure_green_intensity));
rgb_matrix_set_color(led[0], boost, max_intensity, boost);
}
else {
- const uint8_t green = (uint8_t) ((uint16_t) max_intensity * rgb_frame_buffer[col][row] / pure_green_intensity);
+ const uint8_t green = (uint8_t) ((uint16_t) max_intensity * rgb_frame_buffer[row][col] / pure_green_intensity);
rgb_matrix_set_color(led[0], 0, green, 0);
}
}
@@ -58,15 +57,15 @@ bool rgb_matrix_digital_rain(effect_params_t* params) {
for (uint8_t row = MATRIX_ROWS - 1; row > 0; row--) {
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
// if ths is on the bottom row and bright allow decay
- if (row == MATRIX_ROWS - 1 && rgb_frame_buffer[col][row] == max_intensity) {
- rgb_frame_buffer[col][row]--;
+ if (row == MATRIX_ROWS - 1 && rgb_frame_buffer[row][col] == max_intensity) {
+ rgb_frame_buffer[row][col]--;
}
// check if the pixel above is bright
- if (rgb_frame_buffer[col][row - 1] == max_intensity) {
+ if (rgb_frame_buffer[row - 1][col] == max_intensity) {
// allow old bright pixel to decay
- rgb_frame_buffer[col][row - 1]--;
+ rgb_frame_buffer[row - 1][col]--;
// make this pixel bright
- rgb_frame_buffer[col][row] = max_intensity;
+ rgb_frame_buffer[row][col] = max_intensity;
}
}
}
@@ -74,4 +73,5 @@ bool rgb_matrix_digital_rain(effect_params_t* params) {
return false;
}
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_DIGITAL_RAIN)
diff --git a/quantum/rgb_matrix_animations/dual_beacon_anim.h b/quantum/rgb_matrix_animations/dual_beacon_anim.h
index dcb594029e..f853f71ecc 100644
--- a/quantum/rgb_matrix_animations/dual_beacon_anim.h
+++ b/quantum/rgb_matrix_animations/dual_beacon_anim.h
@@ -1,11 +1,8 @@
-#pragma once
#ifndef DISABLE_RGB_MATRIX_DUAL_BEACON
+RGB_MATRIX_EFFECT(DUAL_BEACON)
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-extern rgb_counters_t g_rgb_counters;
-extern led_config_t g_led_config;
-extern rgb_config_t rgb_matrix_config;
-
-bool rgb_matrix_dual_beacon(effect_params_t* params) {
+bool DUAL_BEACON(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
@@ -21,4 +18,5 @@ bool rgb_matrix_dual_beacon(effect_params_t* params) {
return led_max < DRIVER_LED_TOTAL;
}
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // DISABLE_RGB_MATRIX_DUAL_BEACON
diff --git a/quantum/rgb_matrix_animations/gradient_up_down_anim.h b/quantum/rgb_matrix_animations/gradient_up_down_anim.h
index 7a6ed14219..d9fcd4d988 100644
--- a/quantum/rgb_matrix_animations/gradient_up_down_anim.h
+++ b/quantum/rgb_matrix_animations/gradient_up_down_anim.h
@@ -1,10 +1,8 @@
-#pragma once
#ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
+RGB_MATRIX_EFFECT(GRADIENT_UP_DOWN)
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-extern led_config_t g_led_config;
-extern rgb_config_t rgb_matrix_config;
-
-bool rgb_matrix_gradient_up_down(effect_params_t* params) {
+bool GRADIENT_UP_DOWN(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
@@ -19,4 +17,6 @@ bool rgb_matrix_gradient_up_down(effect_params_t* params) {
}
return led_max < DRIVER_LED_TOTAL;
}
+
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
diff --git a/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h
index 5ea971435e..8f0b1bd914 100644
--- a/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h
+++ b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h
@@ -1,9 +1,6 @@
-#pragma once
#ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
-
-extern rgb_counters_t g_rgb_counters;
-extern led_config_t g_led_config;
-extern rgb_config_t rgb_matrix_config;
+RGB_MATRIX_EFFECT(JELLYBEAN_RAINDROPS)
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static void jellybean_raindrops_set_color(int i, effect_params_t* params) {
if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return;
@@ -12,7 +9,7 @@ static void jellybean_raindrops_set_color(int i, effect_params_t* params) {
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
-bool rgb_matrix_jellybean_raindrops(effect_params_t* params) {
+bool JELLYBEAN_RAINDROPS(effect_params_t* params) {
if (!params->init) {
// Change one LED every tick, make sure speed is not 0
if (scale16by8(g_rgb_counters.tick, qadd8(rgb_matrix_config.speed, 16)) % 5 == 0) {
@@ -28,4 +25,5 @@ bool rgb_matrix_jellybean_raindrops(effect_params_t* params) {
return led_max < DRIVER_LED_TOTAL;
}
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
diff --git a/quantum/rgb_matrix_animations/rainbow_beacon_anim.h b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h
index d462880731..a0e0f814c5 100644
--- a/quantum/rgb_matrix_animations/rainbow_beacon_anim.h
+++ b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h
@@ -1,11 +1,8 @@
-#pragma once
#ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON
+RGB_MATRIX_EFFECT(RAINBOW_BEACON)
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-extern rgb_counters_t g_rgb_counters;
-extern led_config_t g_led_config;
-extern rgb_config_t rgb_matrix_config;
-
-bool rgb_matrix_rainbow_beacon(effect_params_t* params) {
+bool RAINBOW_BEACON(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
@@ -21,4 +18,5 @@ bool rgb_matrix_rainbow_beacon(effect_params_t* params) {
return led_max < DRIVER_LED_TOTAL;
}
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // DISABLE_RGB_MATRIX_RAINBOW_BEACON
diff --git a/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h b/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h
index 3b7d9689f8..39352b0c13 100644
--- a/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h
+++ b/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h
@@ -1,11 +1,8 @@
-#pragma once
#ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
+RGB_MATRIX_EFFECT(RAINBOW_MOVING_CHEVRON)
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-extern rgb_counters_t g_rgb_counters;
-extern led_config_t g_led_config;
-extern rgb_config_t rgb_matrix_config;
-
-bool rgb_matrix_rainbow_moving_chevron(effect_params_t* params) {
+bool RAINBOW_MOVING_CHEVRON(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
@@ -19,4 +16,5 @@ bool rgb_matrix_rainbow_moving_chevron(effect_params_t* params) {
return led_max < DRIVER_LED_TOTAL;
}
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
diff --git a/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h b/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h
index e92f351765..275aaa48d9 100644
--- a/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h
+++ b/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h
@@ -1,11 +1,8 @@
-#pragma once
#ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
+RGB_MATRIX_EFFECT(PINWHEELS)
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-extern rgb_counters_t g_rgb_counters;
-extern led_config_t g_led_config;
-extern rgb_config_t rgb_matrix_config;
-
-bool rgb_matrix_rainbow_pinwheels(effect_params_t* params) {
+bool PINWHEELS(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
@@ -21,4 +18,5 @@ bool rgb_matrix_rainbow_pinwheels(effect_params_t* params) {
return led_max < DRIVER_LED_TOTAL;
}
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
diff --git a/quantum/rgb_matrix_animations/raindrops_anim.h b/quantum/rgb_matrix_animations/raindrops_anim.h
index 4ce1d65e57..09d0d1df87 100644
--- a/quantum/rgb_matrix_animations/raindrops_anim.h
+++ b/quantum/rgb_matrix_animations/raindrops_anim.h
@@ -1,10 +1,6 @@
-#pragma once
#ifndef DISABLE_RGB_MATRIX_RAINDROPS
-#include "rgb_matrix_types.h"
-
-extern rgb_counters_t g_rgb_counters;
-extern led_config_t g_led_config;
-extern rgb_config_t rgb_matrix_config;
+RGB_MATRIX_EFFECT(RAINDROPS)
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static void raindrops_set_color(int i, effect_params_t* params) {
if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return;
@@ -23,7 +19,7 @@ static void raindrops_set_color(int i, effect_params_t* params) {
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
-bool rgb_matrix_raindrops(effect_params_t* params) {
+bool RAINDROPS(effect_params_t* params) {
if (!params->init) {
// Change one LED every tick, make sure speed is not 0
if (scale16by8(g_rgb_counters.tick, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) {
@@ -39,4 +35,5 @@ bool rgb_matrix_raindrops(effect_params_t* params) {
return led_max < DRIVER_LED_TOTAL;
}
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // DISABLE_RGB_MATRIX_RAINDROPS
diff --git a/quantum/rgb_matrix_animations/rgb_matrix_effects.inc b/quantum/rgb_matrix_animations/rgb_matrix_effects.inc
new file mode 100644
index 0000000000..9bc6454613
--- /dev/null
+++ b/quantum/rgb_matrix_animations/rgb_matrix_effects.inc
@@ -0,0 +1,23 @@
+// Add your new core rgb matrix effect here, order determins enum order, requires "rgb_matrix_animations/ directory
+#include "rgb_matrix_animations/solid_color_anim.h"
+#include "rgb_matrix_animations/alpha_mods_anim.h"
+#include "rgb_matrix_animations/gradient_up_down_anim.h"
+#include "rgb_matrix_animations/breathing_anim.h"
+#include "rgb_matrix_animations/cycle_all_anim.h"
+#include "rgb_matrix_animations/cycle_left_right_anim.h"
+#include "rgb_matrix_animations/cycle_up_down_anim.h"
+#include "rgb_matrix_animations/rainbow_moving_chevron_anim.h"
+#include "rgb_matrix_animations/dual_beacon_anim.h"
+#include "rgb_matrix_animations/rainbow_beacon_anim.h"
+#include "rgb_matrix_animations/rainbow_pinwheels_anim.h"
+#include "rgb_matrix_animations/raindrops_anim.h"
+#include "rgb_matrix_animations/jellybean_raindrops_anim.h"
+#include "rgb_matrix_animations/typing_heatmap_anim.h"
+#include "rgb_matrix_animations/digital_rain_anim.h"
+#include "rgb_matrix_animations/solid_reactive_simple_anim.h"
+#include "rgb_matrix_animations/solid_reactive_anim.h"
+#include "rgb_matrix_animations/solid_reactive_wide.h"
+#include "rgb_matrix_animations/solid_reactive_cross.h"
+#include "rgb_matrix_animations/solid_reactive_nexus.h"
+#include "rgb_matrix_animations/splash_anim.h"
+#include "rgb_matrix_animations/solid_splash_anim.h"
diff --git a/quantum/rgb_matrix_animations/solid_color_anim.h b/quantum/rgb_matrix_animations/solid_color_anim.h
index ba2cea15e3..9376425598 100644
--- a/quantum/rgb_matrix_animations/solid_color_anim.h
+++ b/quantum/rgb_matrix_animations/solid_color_anim.h
@@ -1,9 +1,7 @@
-#pragma once
+RGB_MATRIX_EFFECT(SOLID_COLOR)
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
-extern led_config_t g_led_config;
-extern rgb_config_t rgb_matrix_config;
-
-bool rgb_matrix_solid_color(effect_params_t* params) {
+bool SOLID_COLOR(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val };
@@ -14,3 +12,5 @@ bool rgb_matrix_solid_color(effect_params_t* params) {
}
return led_max < DRIVER_LED_TOTAL;
}
+
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
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
diff --git a/quantum/rgb_matrix_animations/solid_reactive_cross.h b/quantum/rgb_matrix_animations/solid_reactive_cross.h
index 8858f71e60..62210f82d6 100644
--- a/quantum/rgb_matrix_animations/solid_reactive_cross.h
+++ b/quantum/rgb_matrix_animations/solid_reactive_cross.h
@@ -1,10 +1,15 @@
-#pragma once
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS)
-extern led_config_t g_led_config;
-extern rgb_config_t rgb_matrix_config;
-extern last_hit_t g_last_hit_tracker;
+#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS
+RGB_MATRIX_EFFECT(SOLID_REACTIVE_CROSS)
+#endif
+
+#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS
+RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTICROSS)
+#endif
+
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static bool rgb_matrix_solid_reactive_multicross_range(uint8_t start, effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
@@ -38,13 +43,14 @@ static bool rgb_matrix_solid_reactive_multicross_range(uint8_t start, effect_par
return led_max < DRIVER_LED_TOTAL;
}
-bool rgb_matrix_solid_reactive_multicross(effect_params_t* params) {
+bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) {
return rgb_matrix_solid_reactive_multicross_range(0, params);
}
-bool rgb_matrix_solid_reactive_cross(effect_params_t* params) {
+bool SOLID_REACTIVE_CROSS(effect_params_t* params) {
return rgb_matrix_solid_reactive_multicross_range(qsub8(g_last_hit_tracker.count, 1), params);
}
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS)
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix_animations/solid_reactive_nexus.h b/quantum/rgb_matrix_animations/solid_reactive_nexus.h
index c0e3c24507..33f478ac70 100644
--- a/quantum/rgb_matrix_animations/solid_reactive_nexus.h
+++ b/quantum/rgb_matrix_animations/solid_reactive_nexus.h
@@ -1,10 +1,15 @@
-#pragma once
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS)
-extern led_config_t g_led_config;
-extern rgb_config_t rgb_matrix_config;
-extern last_hit_t g_last_hit_tracker;
+#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS
+RGB_MATRIX_EFFECT(SOLID_REACTIVE_NEXUS)
+#endif
+
+#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS
+RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTINEXUS)
+#endif
+
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static bool rgb_matrix_solid_reactive_multinexus_range(uint8_t start, effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
@@ -36,13 +41,14 @@ static bool rgb_matrix_solid_reactive_multinexus_range(uint8_t start, effect_par
return led_max < DRIVER_LED_TOTAL;
}
-bool rgb_matrix_solid_reactive_multinexus(effect_params_t* params) {
+bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) {
return rgb_matrix_solid_reactive_multinexus_range(0, params);
}
-bool rgb_matrix_solid_reactive_nexus(effect_params_t* params) {
+bool SOLID_REACTIVE_NEXUS(effect_params_t* params) {
return rgb_matrix_solid_reactive_multinexus_range(qsub8(g_last_hit_tracker.count, 1), params);
}
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS)
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h
index abc7e36a89..a568a54386 100644
--- a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h
+++ b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h
@@ -1,12 +1,10 @@
#pragma once
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
+RGB_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE)
+#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_simple(effect_params_t* params) {
+bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 };
@@ -31,5 +29,6 @@ bool rgb_matrix_solid_reactive_simple(effect_params_t* params) {
return led_max < DRIVER_LED_TOTAL;
}
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix_animations/solid_reactive_wide.h b/quantum/rgb_matrix_animations/solid_reactive_wide.h
index 3d1d38e806..ff0f6f5eca 100644
--- a/quantum/rgb_matrix_animations/solid_reactive_wide.h
+++ b/quantum/rgb_matrix_animations/solid_reactive_wide.h
@@ -1,10 +1,15 @@
-#pragma once
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE)
-extern led_config_t g_led_config;
-extern rgb_config_t rgb_matrix_config;
-extern last_hit_t g_last_hit_tracker;
+#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE
+RGB_MATRIX_EFFECT(SOLID_REACTIVE_WIDE)
+#endif
+
+#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE
+RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTIWIDE)
+#endif
+
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static bool rgb_matrix_solid_reactive_multiwide_range(uint8_t start, effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
@@ -30,13 +35,14 @@ static bool rgb_matrix_solid_reactive_multiwide_range(uint8_t start, effect_para
return led_max < DRIVER_LED_TOTAL;
}
-bool rgb_matrix_solid_reactive_multiwide(effect_params_t* params) {
+bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) {
return rgb_matrix_solid_reactive_multiwide_range(0, params);
}
-bool rgb_matrix_solid_reactive_wide(effect_params_t* params) {
+bool SOLID_REACTIVE_WIDE(effect_params_t* params) {
return rgb_matrix_solid_reactive_multiwide_range(qsub8(g_last_hit_tracker.count, 1), params);
}
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE)
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix_animations/solid_splash_anim.h b/quantum/rgb_matrix_animations/solid_splash_anim.h
index 4e5565d0d3..d439bd8880 100644
--- a/quantum/rgb_matrix_animations/solid_splash_anim.h
+++ b/quantum/rgb_matrix_animations/solid_splash_anim.h
@@ -1,10 +1,15 @@
-#pragma once
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#if !defined(DISABLE_RGB_MATRIX_SOLID_SPLASH) || !defined(DISABLE_RGB_MATRIX_SOLID_MULTISPLASH)
-extern led_config_t g_led_config;
-extern rgb_config_t rgb_matrix_config;
-extern last_hit_t g_last_hit_tracker;
+#ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH
+RGB_MATRIX_EFFECT(SOLID_SPLASH)
+#endif
+
+#ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
+RGB_MATRIX_EFFECT(SOLID_MULTISPLASH)
+#endif
+
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static bool rgb_matrix_solid_multisplash_range(uint8_t start, effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
@@ -30,13 +35,14 @@ static bool rgb_matrix_solid_multisplash_range(uint8_t start, effect_params_t* p
return led_max < DRIVER_LED_TOTAL;
}
-bool rgb_matrix_solid_multisplash(effect_params_t* params) {
+bool SOLID_MULTISPLASH(effect_params_t* params) {
return rgb_matrix_solid_multisplash_range(0, params);
}
-bool rgb_matrix_solid_splash(effect_params_t* params) {
+bool SOLID_SPLASH(effect_params_t* params) {
return rgb_matrix_solid_multisplash_range(qsub8(g_last_hit_tracker.count, 1), params);
}
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // !defined(DISABLE_RGB_MATRIX_SPLASH) && !defined(DISABLE_RGB_MATRIX_MULTISPLASH)
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix_animations/splash_anim.h b/quantum/rgb_matrix_animations/splash_anim.h
index fbe7761117..214dab68da 100644
--- a/quantum/rgb_matrix_animations/splash_anim.h
+++ b/quantum/rgb_matrix_animations/splash_anim.h
@@ -1,10 +1,16 @@
-#pragma once
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
#if !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH)
-extern led_config_t g_led_config;
-extern rgb_config_t rgb_matrix_config;
-extern last_hit_t g_last_hit_tracker;
+#ifndef DISABLE_RGB_MATRIX_SPLASH
+RGB_MATRIX_EFFECT(SPLASH)
+#endif
+
+#ifndef DISABLE_RGB_MATRIX_MULTISPLASH
+RGB_MATRIX_EFFECT(MULTISPLASH)
+#endif
+
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+
static bool rgb_matrix_multisplash_range(uint8_t start, effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
@@ -32,13 +38,14 @@ static bool rgb_matrix_multisplash_range(uint8_t start, effect_params_t* params)
return led_max < DRIVER_LED_TOTAL;
}
-bool rgb_matrix_multisplash(effect_params_t* params) {
+bool MULTISPLASH(effect_params_t* params) {
return rgb_matrix_multisplash_range(0, params);
}
-bool rgb_matrix_splash(effect_params_t* params) {
+bool SPLASH(effect_params_t* params) {
return rgb_matrix_multisplash_range(qsub8(g_last_hit_tracker.count, 1), params);
}
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH)
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
diff --git a/quantum/rgb_matrix_animations/typing_heatmap_anim.h b/quantum/rgb_matrix_animations/typing_heatmap_anim.h
index aade53fccc..e6b34717b2 100644
--- a/quantum/rgb_matrix_animations/typing_heatmap_anim.h
+++ b/quantum/rgb_matrix_animations/typing_heatmap_anim.h
@@ -1,8 +1,6 @@
-#pragma once
#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP)
-
-extern rgb_config_t rgb_matrix_config;
-extern uint8_t rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS];
+RGB_MATRIX_EFFECT(TYPING_HEATMAP)
+#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
void process_rgb_matrix_typing_heatmap(keyrecord_t *record) {
uint8_t row = record->event.key.row;
@@ -35,7 +33,7 @@ void process_rgb_matrix_typing_heatmap(keyrecord_t *record) {
}
}
-bool rgb_matrix_typing_heatmap(effect_params_t* params) {
+bool TYPING_HEATMAP(effect_params_t* params) {
// Modified version of RGB_MATRIX_USE_LIMITS to work off of matrix row / col size
uint8_t led_min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter;
uint8_t led_max = led_min + RGB_MATRIX_LED_PROCESS_LIMIT;
@@ -72,4 +70,5 @@ bool rgb_matrix_typing_heatmap(effect_params_t* params) {
return led_max < sizeof(rgb_frame_buffer);
}
+#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP)