From 161c4b21dc3021b2df208ad8cc6f1b7f7f5ca7f3 Mon Sep 17 00:00:00 2001 From: Ryan Caltabiano Date: Mon, 25 Mar 2019 19:13:30 -0500 Subject: [PATCH] Updating effect function api for future extensions --- quantum/rgb_matrix.c | 56 +++++++++---------- quantum/rgb_matrix.h | 2 +- .../rgb_matrix_animations/alpha_mods_anim.h | 2 +- .../rgb_matrix_animations/breathing_anim.h | 2 +- .../rgb_matrix_animations/cycle_all_anim.h | 2 +- .../cycle_left_right_anim.h | 2 +- .../cycle_up_down_anim.h | 2 +- .../rgb_matrix_animations/digital_rain_anim.h | 4 +- .../rgb_matrix_animations/dual_beacon_anim.h | 2 +- .../gradient_up_down_anim.h | 2 +- .../jellybean_raindrops_anim.h | 4 +- .../rainbow_beacon_anim.h | 2 +- .../rainbow_moving_chevron_anim.h | 2 +- .../rainbow_pinwheels_anim.h | 2 +- .../rgb_matrix_animations/raindrops_anim.h | 4 +- .../rgb_matrix_animations/solid_color_anim.h | 2 +- .../solid_reactive_anim.h | 2 +- .../solid_reactive_simple_anim.h | 2 +- .../rgb_matrix_animations/solid_splash_anim.h | 10 ++-- quantum/rgb_matrix_animations/splash_anim.h | 10 ++-- quantum/rgb_matrix_types.h | 18 +++--- 21 files changed, 66 insertions(+), 68 deletions(-) diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index b70f2d09bb..16ca7e179c 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -211,8 +211,8 @@ void rgb_matrix_test(void) { } } -static bool rgb_matrix_none(bool init, uint8_t iter) { - if (!init) { +static bool rgb_matrix_none(effect_params_t* params) { + if (!params->init) { return false; } @@ -225,7 +225,7 @@ static bool rgb_matrix_none(bool init, uint8_t iter) { static uint8_t rgb_last_enable = UINT8_MAX; static uint8_t rgb_last_effect = UINT8_MAX; -static uint8_t rgb_anim_iter = 0; +static effect_params_t rgb_effect_params = { 0, 0 }; static rgb_task_states rgb_task_state = SYNCING; static void rgb_task_timers(void) { @@ -261,7 +261,7 @@ static void rgb_task_sync(void) { static void rgb_task_start(void) { // reset iter - rgb_anim_iter = 0; + rgb_effect_params.iter = 0; // update double buffers g_rgb_counters.tick = rgb_counters_buffer; @@ -275,112 +275,112 @@ static void rgb_task_start(void) { static void rgb_task_render(uint8_t effect) { bool rendering = false; - bool initialize = (effect != rgb_last_effect) || (rgb_matrix_config.enable != rgb_last_enable); + rgb_effect_params.init = (effect != rgb_last_effect) || (rgb_matrix_config.enable != rgb_last_enable); // each effect can opt to do calculations // and/or request PWM buffer updates. switch (effect) { case RGB_MATRIX_NONE: - rendering = rgb_matrix_none(initialize, rgb_anim_iter); + rendering = rgb_matrix_none(&rgb_effect_params); break; case RGB_MATRIX_SOLID_COLOR: - rendering = rgb_matrix_solid_color(initialize, rgb_anim_iter); // Max 1ms Avg 0ms + rendering = rgb_matrix_solid_color(&rgb_effect_params); // Max 1ms Avg 0ms break; #ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS case RGB_MATRIX_ALPHAS_MODS: - rendering = rgb_matrix_alphas_mods(initialize, rgb_anim_iter); // Max 2ms Avg 1ms + rendering = rgb_matrix_alphas_mods(&rgb_effect_params); // Max 2ms Avg 1ms break; #endif // DISABLE_RGB_MATRIX_ALPHAS_MODS #ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN case RGB_MATRIX_GRADIENT_UP_DOWN: - rendering = rgb_matrix_gradient_up_down(initialize, rgb_anim_iter); // Max 4ms Avg 3ms + rendering = rgb_matrix_gradient_up_down(&rgb_effect_params); // Max 4ms Avg 3ms break; #endif // DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN #ifndef DISABLE_RGB_MATRIX_BREATHING case RGB_MATRIX_BREATHING: - rendering = rgb_matrix_breathing(initialize, rgb_anim_iter); // Max 1ms Avg 0ms + rendering = rgb_matrix_breathing(&rgb_effect_params); // Max 1ms Avg 0ms break; #endif // DISABLE_RGB_MATRIX_BREATHING #ifndef DISABLE_RGB_MATRIX_CYCLE_ALL case RGB_MATRIX_CYCLE_ALL: - rendering = rgb_matrix_cycle_all(initialize, rgb_anim_iter); // Max 4ms Avg 3ms + rendering = rgb_matrix_cycle_all(&rgb_effect_params); // Max 4ms Avg 3ms break; #endif // DISABLE_RGB_MATRIX_CYCLE_ALL #ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT case RGB_MATRIX_CYCLE_LEFT_RIGHT: - rendering = rgb_matrix_cycle_left_right(initialize, rgb_anim_iter); // Max 4ms Avg 3ms + rendering = rgb_matrix_cycle_left_right(&rgb_effect_params); // Max 4ms Avg 3ms break; #endif // DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT #ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN case RGB_MATRIX_CYCLE_UP_DOWN: - rendering = rgb_matrix_cycle_up_down(initialize, rgb_anim_iter); // Max 4ms Avg 3ms + rendering = rgb_matrix_cycle_up_down(&rgb_effect_params); // Max 4ms Avg 3ms break; #endif // DISABLE_RGB_MATRIX_CYCLE_UP_DOWN #ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON case RGB_MATRIX_RAINBOW_MOVING_CHEVRON: - rendering = rgb_matrix_rainbow_moving_chevron(initialize, rgb_anim_iter); // Max 4ms Avg 3ms + rendering = rgb_matrix_rainbow_moving_chevron(&rgb_effect_params); // Max 4ms Avg 3ms break; #endif // DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON #ifndef DISABLE_RGB_MATRIX_DUAL_BEACON case RGB_MATRIX_DUAL_BEACON: - rendering = rgb_matrix_dual_beacon(initialize, rgb_anim_iter); // Max 4ms Avg 3ms + rendering = rgb_matrix_dual_beacon(&rgb_effect_params); // Max 4ms Avg 3ms break; #endif // DISABLE_RGB_MATRIX_DUAL_BEACON #ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON case RGB_MATRIX_RAINBOW_BEACON: - rendering = rgb_matrix_rainbow_beacon(initialize, rgb_anim_iter); // Max 4ms Avg 3ms + rendering = rgb_matrix_rainbow_beacon(&rgb_effect_params); // Max 4ms Avg 3ms break; #endif // DISABLE_RGB_MATRIX_RAINBOW_BEACON #ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS case RGB_MATRIX_RAINBOW_PINWHEELS: - rendering = rgb_matrix_rainbow_pinwheels(initialize, rgb_anim_iter); // Max 4ms Avg 3ms + rendering = rgb_matrix_rainbow_pinwheels(&rgb_effect_params); // Max 4ms Avg 3ms break; #endif // DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS #ifndef DISABLE_RGB_MATRIX_RAINDROPS case RGB_MATRIX_RAINDROPS: - rendering = rgb_matrix_raindrops(initialize, rgb_anim_iter); // Max 1ms Avg 0ms + rendering = rgb_matrix_raindrops(&rgb_effect_params); // Max 1ms Avg 0ms break; #endif // DISABLE_RGB_MATRIX_RAINDROPS #ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS case RGB_MATRIX_JELLYBEAN_RAINDROPS: - rendering = rgb_matrix_jellybean_raindrops(initialize, rgb_anim_iter); // Max 1ms Avg 0ms + rendering = rgb_matrix_jellybean_raindrops(&rgb_effect_params); // Max 1ms Avg 0ms break; #endif // DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS #ifndef DISABLE_RGB_MATRIX_DIGITAL_RAIN case RGB_MATRIX_DIGITAL_RAIN: - rendering = rgb_matrix_digital_rain(initialize, rgb_anim_iter); // Max 9ms Avg 8ms | this is expensive, fix it + rendering = rgb_matrix_digital_rain(&rgb_effect_params); // Max 9ms Avg 8ms | this is expensive, fix it break; #endif // DISABLE_RGB_MATRIX_DIGITAL_RAIN #if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE case RGB_MATRIX_SOLID_REACTIVE_SIMPLE: - rendering = rgb_matrix_solid_reactive_simple(initialize, rgb_anim_iter);// Max 4ms Avg 3ms + rendering = rgb_matrix_solid_reactive_simple(&rgb_effect_params);// Max 4ms Avg 3ms break; #endif #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE case RGB_MATRIX_SOLID_REACTIVE: - rendering = rgb_matrix_solid_reactive(initialize, rgb_anim_iter); // Max 4ms Avg 3ms + rendering = rgb_matrix_solid_reactive(&rgb_effect_params); // Max 4ms Avg 3ms break; #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE #ifndef DISABLE_RGB_MATRIX_SPLASH case RGB_MATRIX_SPLASH: - rendering = rgb_matrix_splash(initialize, rgb_anim_iter); // Max 5ms Avg 3ms + rendering = rgb_matrix_splash(&rgb_effect_params); // Max 5ms Avg 3ms break; #endif // DISABLE_RGB_MATRIX_SPLASH #ifndef DISABLE_RGB_MATRIX_MULTISPLASH case RGB_MATRIX_MULTISPLASH: - rendering = rgb_matrix_multisplash(initialize, rgb_anim_iter); // Max 10ms Avg 5ms + rendering = rgb_matrix_multisplash(&rgb_effect_params); // Max 10ms Avg 5ms break; #endif // DISABLE_RGB_MATRIX_MULTISPLASH #ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH case RGB_MATRIX_SOLID_SPLASH: - rendering = rgb_matrix_solid_splash(initialize, rgb_anim_iter); // Max 5ms Avg 3ms + rendering = rgb_matrix_solid_splash(&rgb_effect_params); // Max 5ms Avg 3ms break; #endif // DISABLE_RGB_MATRIX_SOLID_SPLASH #ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH case RGB_MATRIX_SOLID_MULTISPLASH: - rendering = rgb_matrix_solid_multisplash(initialize, rgb_anim_iter); // Max 10ms Avg 5ms + rendering = rgb_matrix_solid_multisplash(&rgb_effect_params); // Max 10ms Avg 5ms break; #endif // DISABLE_RGB_MATRIX_SOLID_MULTISPLASH #endif // defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) @@ -393,12 +393,12 @@ static void rgb_task_render(uint8_t effect) { return; } - rgb_anim_iter++; + rgb_effect_params.iter++; // next task if (!rendering) { rgb_task_state = FLUSHING; - if (!initialize && effect == RGB_MATRIX_NONE) { + if (!rgb_effect_params.init && effect == RGB_MATRIX_NONE) { // We only need to flush once if we are RGB_MATRIX_NONE rgb_task_state = SYNCING; } diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h index fe49e06213..f1d831642e 100644 --- a/quantum/rgb_matrix.h +++ b/quantum/rgb_matrix.h @@ -40,7 +40,7 @@ #endif #if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < DRIVER_LED_TOTAL -#define RGB_MATRIX_USE_LIMITS(min, max) uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * iter; \ +#define RGB_MATRIX_USE_LIMITS(min, max) uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter; \ uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \ if (max > DRIVER_LED_TOTAL) \ max = DRIVER_LED_TOTAL; diff --git a/quantum/rgb_matrix_animations/alpha_mods_anim.h b/quantum/rgb_matrix_animations/alpha_mods_anim.h index 8859b3a87f..cc1914d7f4 100644 --- a/quantum/rgb_matrix_animations/alpha_mods_anim.h +++ b/quantum/rgb_matrix_animations/alpha_mods_anim.h @@ -5,7 +5,7 @@ extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; // alphas = color1, mods = color2 -bool rgb_matrix_alphas_mods(bool init, uint8_t iter) { +bool rgb_matrix_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 }; diff --git a/quantum/rgb_matrix_animations/breathing_anim.h b/quantum/rgb_matrix_animations/breathing_anim.h index 4af606a063..fb90b66bdf 100644 --- a/quantum/rgb_matrix_animations/breathing_anim.h +++ b/quantum/rgb_matrix_animations/breathing_anim.h @@ -3,7 +3,7 @@ extern rgb_config_t rgb_matrix_config; -bool rgb_matrix_breathing(bool init, uint8_t iter) { +bool rgb_matrix_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); diff --git a/quantum/rgb_matrix_animations/cycle_all_anim.h b/quantum/rgb_matrix_animations/cycle_all_anim.h index 8f1b64c658..5c18cfa0c9 100644 --- a/quantum/rgb_matrix_animations/cycle_all_anim.h +++ b/quantum/rgb_matrix_animations/cycle_all_anim.h @@ -5,7 +5,7 @@ extern rgb_counters_t g_rgb_counters; extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; -bool rgb_matrix_cycle_all(bool init, uint8_t iter) { +bool rgb_matrix_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 }; diff --git a/quantum/rgb_matrix_animations/cycle_left_right_anim.h b/quantum/rgb_matrix_animations/cycle_left_right_anim.h index 420e95cab1..f519aeb476 100644 --- a/quantum/rgb_matrix_animations/cycle_left_right_anim.h +++ b/quantum/rgb_matrix_animations/cycle_left_right_anim.h @@ -5,7 +5,7 @@ extern rgb_counters_t g_rgb_counters; extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; -bool rgb_matrix_cycle_left_right(bool init, uint8_t iter) { +bool rgb_matrix_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 }; diff --git a/quantum/rgb_matrix_animations/cycle_up_down_anim.h b/quantum/rgb_matrix_animations/cycle_up_down_anim.h index eae0eb1963..8b91d890de 100644 --- a/quantum/rgb_matrix_animations/cycle_up_down_anim.h +++ b/quantum/rgb_matrix_animations/cycle_up_down_anim.h @@ -5,7 +5,7 @@ extern rgb_counters_t g_rgb_counters; extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; -bool rgb_matrix_cycle_up_down(bool init, uint8_t iter) { +bool rgb_matrix_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 }; diff --git a/quantum/rgb_matrix_animations/digital_rain_anim.h b/quantum/rgb_matrix_animations/digital_rain_anim.h index 75ef851f17..4ba3c1c87d 100644 --- a/quantum/rgb_matrix_animations/digital_rain_anim.h +++ b/quantum/rgb_matrix_animations/digital_rain_anim.h @@ -6,7 +6,7 @@ #define RGB_DIGITAL_RAIN_DROPS 24 #endif -bool rgb_matrix_digital_rain(bool init, uint8_t iter) { +bool rgb_matrix_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; @@ -16,7 +16,7 @@ bool rgb_matrix_digital_rain(bool init, uint8_t iter) { static uint8_t map[MATRIX_COLS][MATRIX_ROWS] = {{0}}; static uint8_t drop = 0; - if (init) { + if (params->init) { rgb_matrix_set_color_all(0, 0, 0); memset(map, 0, sizeof map); drop = 0; diff --git a/quantum/rgb_matrix_animations/dual_beacon_anim.h b/quantum/rgb_matrix_animations/dual_beacon_anim.h index a56c8cc2cd..dda3157809 100644 --- a/quantum/rgb_matrix_animations/dual_beacon_anim.h +++ b/quantum/rgb_matrix_animations/dual_beacon_anim.h @@ -5,7 +5,7 @@ extern rgb_counters_t g_rgb_counters; extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; -bool rgb_matrix_dual_beacon(bool init, uint8_t iter) { +bool rgb_matrix_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 }; diff --git a/quantum/rgb_matrix_animations/gradient_up_down_anim.h b/quantum/rgb_matrix_animations/gradient_up_down_anim.h index dabe0ef098..11498e22f5 100644 --- a/quantum/rgb_matrix_animations/gradient_up_down_anim.h +++ b/quantum/rgb_matrix_animations/gradient_up_down_anim.h @@ -4,7 +4,7 @@ extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; -bool rgb_matrix_gradient_up_down(bool init, uint8_t iter) { +bool rgb_matrix_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 }; diff --git a/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h index 766a0f19a4..01ff5c2306 100644 --- a/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h +++ b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h @@ -11,8 +11,8 @@ static void jellybean_raindrops_set_color(int i) { rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } -bool rgb_matrix_jellybean_raindrops(bool init, uint8_t iter) { - if (!init) { +bool rgb_matrix_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) { jellybean_raindrops_set_color(rand() % DRIVER_LED_TOTAL); diff --git a/quantum/rgb_matrix_animations/rainbow_beacon_anim.h b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h index 3e28864ca2..3c15e64ab6 100644 --- a/quantum/rgb_matrix_animations/rainbow_beacon_anim.h +++ b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h @@ -5,7 +5,7 @@ extern rgb_counters_t g_rgb_counters; extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; -bool rgb_matrix_rainbow_beacon(bool init, uint8_t iter) { +bool rgb_matrix_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 }; diff --git a/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h b/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h index 4cce1984a6..0d11d52802 100644 --- a/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h +++ b/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h @@ -5,7 +5,7 @@ extern rgb_counters_t g_rgb_counters; extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; -bool rgb_matrix_rainbow_moving_chevron(bool init, uint8_t iter) { +bool rgb_matrix_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 }; diff --git a/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h b/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h index 28b53d5171..d7cd42cbe8 100644 --- a/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h +++ b/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h @@ -5,7 +5,7 @@ extern rgb_counters_t g_rgb_counters; extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; -bool rgb_matrix_rainbow_pinwheels(bool init, uint8_t iter) { +bool rgb_matrix_rainbow_pinwheels(effect_params_t* params) { RGB_MATRIX_USE_LIMITS(led_min, led_max); HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val }; diff --git a/quantum/rgb_matrix_animations/raindrops_anim.h b/quantum/rgb_matrix_animations/raindrops_anim.h index a6dc3431fc..fc721375b0 100644 --- a/quantum/rgb_matrix_animations/raindrops_anim.h +++ b/quantum/rgb_matrix_animations/raindrops_anim.h @@ -21,8 +21,8 @@ static void raindrops_set_color(int i) { rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } -bool rgb_matrix_raindrops(bool init, uint8_t iter) { - if (!init) { +bool rgb_matrix_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) { raindrops_set_color(rand() % DRIVER_LED_TOTAL); diff --git a/quantum/rgb_matrix_animations/solid_color_anim.h b/quantum/rgb_matrix_animations/solid_color_anim.h index 98b473409e..24a197beb3 100644 --- a/quantum/rgb_matrix_animations/solid_color_anim.h +++ b/quantum/rgb_matrix_animations/solid_color_anim.h @@ -2,7 +2,7 @@ extern rgb_config_t rgb_matrix_config; -bool rgb_matrix_solid_color(bool init, uint8_t iter) { +bool rgb_matrix_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 }; diff --git a/quantum/rgb_matrix_animations/solid_reactive_anim.h b/quantum/rgb_matrix_animations/solid_reactive_anim.h index ac406a9745..4a6cc2077d 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_anim.h +++ b/quantum/rgb_matrix_animations/solid_reactive_anim.h @@ -5,7 +5,7 @@ extern rgb_config_t rgb_matrix_config; extern last_hit_t g_last_hit_tracker; -bool rgb_matrix_solid_reactive(bool init, uint8_t iter) { +bool rgb_matrix_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 }; diff --git a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h index 9e1cb37b8e..933b06bc7f 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h +++ b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h @@ -5,7 +5,7 @@ extern rgb_config_t rgb_matrix_config; extern last_hit_t g_last_hit_tracker; -bool rgb_matrix_solid_reactive_simple(bool init, uint8_t iter) { +bool rgb_matrix_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 }; diff --git a/quantum/rgb_matrix_animations/solid_splash_anim.h b/quantum/rgb_matrix_animations/solid_splash_anim.h index 7df8c26cb4..e858db4cd9 100644 --- a/quantum/rgb_matrix_animations/solid_splash_anim.h +++ b/quantum/rgb_matrix_animations/solid_splash_anim.h @@ -6,7 +6,7 @@ extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; extern last_hit_t g_last_hit_tracker; -static bool rgb_matrix_solid_multisplash_range(uint8_t start, uint8_t iter) { +static bool rgb_matrix_solid_multisplash_range(uint8_t start, effect_params_t* params) { RGB_MATRIX_USE_LIMITS(led_min, led_max); HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 }; @@ -30,12 +30,12 @@ static bool rgb_matrix_solid_multisplash_range(uint8_t start, uint8_t iter) { return led_max < DRIVER_LED_TOTAL; } -bool rgb_matrix_solid_multisplash(bool init, uint8_t iter) { - return rgb_matrix_solid_multisplash_range(0, iter); +bool rgb_matrix_solid_multisplash(effect_params_t* params) { + return rgb_matrix_solid_multisplash_range(0, params); } -bool rgb_matrix_solid_splash(bool init, uint8_t iter) { - return rgb_matrix_solid_multisplash_range(qsub8(g_last_hit_tracker.count, 1), iter); +bool rgb_matrix_solid_splash(effect_params_t* params) { + return rgb_matrix_solid_multisplash_range(qsub8(g_last_hit_tracker.count, 1), params); } #endif // !defined(DISABLE_RGB_MATRIX_SPLASH) && !defined(DISABLE_RGB_MATRIX_MULTISPLASH) diff --git a/quantum/rgb_matrix_animations/splash_anim.h b/quantum/rgb_matrix_animations/splash_anim.h index 2bc6a06955..783778fd85 100644 --- a/quantum/rgb_matrix_animations/splash_anim.h +++ b/quantum/rgb_matrix_animations/splash_anim.h @@ -6,7 +6,7 @@ extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL]; extern rgb_config_t rgb_matrix_config; extern last_hit_t g_last_hit_tracker; -static bool rgb_matrix_multisplash_range(uint8_t start, uint8_t iter) { +static bool rgb_matrix_multisplash_range(uint8_t start, effect_params_t* params) { RGB_MATRIX_USE_LIMITS(led_min, led_max); HSV hsv = { 0, rgb_matrix_config.sat, 0 }; @@ -32,12 +32,12 @@ static bool rgb_matrix_multisplash_range(uint8_t start, uint8_t iter) { return led_max < DRIVER_LED_TOTAL; } -bool rgb_matrix_multisplash(bool init, uint8_t iter) { - return rgb_matrix_multisplash_range(0, iter); +bool rgb_matrix_multisplash(effect_params_t* params) { + return rgb_matrix_multisplash_range(0, params); } -bool rgb_matrix_splash(bool init, uint8_t iter) { - return rgb_matrix_multisplash_range(qsub8(g_last_hit_tracker.count, 1), iter); +bool rgb_matrix_splash(effect_params_t* params) { + return rgb_matrix_multisplash_range(qsub8(g_last_hit_tracker.count, 1), params); } #endif // !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH) diff --git a/quantum/rgb_matrix_types.h b/quantum/rgb_matrix_types.h index a3b0fd0bff..ab98b89d7d 100644 --- a/quantum/rgb_matrix_types.h +++ b/quantum/rgb_matrix_types.h @@ -35,6 +35,14 @@ typedef enum rgb_task_states { SYNCING } rgb_task_states; +typedef uint8_t led_flags_t; + +typedef struct PACKED { + uint8_t iter; + led_flags_t flags; + bool init; +} effect_params_t; + typedef struct PACKED { // Global tick at 20 Hz uint32_t tick; @@ -61,16 +69,6 @@ typedef struct PACKED { uint8_t modifier:1; } rgb_led; -/*typedef union { - uint32_t raw; // 32 bits - struct { - bool enable :1; // 1 bit - uint8_t mode :7; // 7 bits - HSV hsv; // 24 bits - uint8_t speed; // 8 bits - }; // 40 bits =( -} rgb_config_t;*/ - typedef union { uint32_t raw; struct PACKED {