diff options
Diffstat (limited to 'quantum/rgb_matrix_animations')
32 files changed, 382 insertions, 458 deletions
diff --git a/quantum/rgb_matrix_animations/alpha_mods_anim.h b/quantum/rgb_matrix_animations/alpha_mods_anim.h index 8df3356f61..0778ab2098 100644 --- a/quantum/rgb_matrix_animations/alpha_mods_anim.h +++ b/quantum/rgb_matrix_animations/alpha_mods_anim.h @@ -1,26 +1,26 @@ #ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS RGB_MATRIX_EFFECT(ALPHAS_MODS) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS // alphas = color1, mods = color2 bool ALPHAS_MODS(effect_params_t* params) { - RGB_MATRIX_USE_LIMITS(led_min, led_max); + RGB_MATRIX_USE_LIMITS(led_min, led_max); - HSV hsv = rgb_matrix_config.hsv; - RGB rgb1 = hsv_to_rgb(hsv); - hsv.h += rgb_matrix_config.speed; - RGB rgb2 = hsv_to_rgb(hsv); + HSV hsv = rgb_matrix_config.hsv; + RGB rgb1 = hsv_to_rgb(hsv); + hsv.h += rgb_matrix_config.speed; + RGB rgb2 = hsv_to_rgb(hsv); - for (uint8_t i = led_min; i < led_max; i++) { - RGB_MATRIX_TEST_LED_FLAGS(); - if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) { - rgb_matrix_set_color(i, rgb2.r, rgb2.g, rgb2.b); - } else { - rgb_matrix_set_color(i, rgb1.r, rgb1.g, rgb1.b); + for (uint8_t i = led_min; i < led_max; i++) { + RGB_MATRIX_TEST_LED_FLAGS(); + if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) { + rgb_matrix_set_color(i, rgb2.r, rgb2.g, rgb2.b); + } else { + rgb_matrix_set_color(i, rgb1.r, rgb1.g, rgb1.b); + } } - } - return led_max < DRIVER_LED_TOTAL; + return led_max < DRIVER_LED_TOTAL; } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_ALPHAS_MODS +# 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 0af7b42cf3..92431555e7 100644 --- a/quantum/rgb_matrix_animations/breathing_anim.h +++ b/quantum/rgb_matrix_animations/breathing_anim.h @@ -1,20 +1,20 @@ #ifndef DISABLE_RGB_MATRIX_BREATHING RGB_MATRIX_EFFECT(BREATHING) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS bool BREATHING(effect_params_t* params) { - RGB_MATRIX_USE_LIMITS(led_min, led_max); + RGB_MATRIX_USE_LIMITS(led_min, led_max); - HSV hsv = rgb_matrix_config.hsv; - uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 8); - hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); - RGB rgb = hsv_to_rgb(hsv); - for (uint8_t i = led_min; i < led_max; i++) { - RGB_MATRIX_TEST_LED_FLAGS(); - rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); - } - return led_max < DRIVER_LED_TOTAL; + HSV hsv = rgb_matrix_config.hsv; + uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 8); + hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); + RGB rgb = hsv_to_rgb(hsv); + for (uint8_t i = led_min; i < led_max; i++) { + RGB_MATRIX_TEST_LED_FLAGS(); + rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); + } + return led_max < DRIVER_LED_TOTAL; } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_BREATHING +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // DISABLE_RGB_MATRIX_BREATHING diff --git a/quantum/rgb_matrix_animations/colorband_pinwheel_sat_anim.h b/quantum/rgb_matrix_animations/colorband_pinwheel_sat_anim.h index 4585c52716..3df3cfda7d 100644 --- a/quantum/rgb_matrix_animations/colorband_pinwheel_sat_anim.h +++ b/quantum/rgb_matrix_animations/colorband_pinwheel_sat_anim.h @@ -1,15 +1,13 @@ #ifndef DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT RGB_MATRIX_EFFECT(BAND_PINWHEEL_SAT) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS static HSV BAND_PINWHEEL_SAT_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) { hsv.s = scale8(hsv.s - time - atan2_8(dy, dx) * 3, hsv.s); return hsv; } -bool BAND_PINWHEEL_SAT(effect_params_t* params) { - return effect_runner_dx_dy(params, &BAND_PINWHEEL_SAT_math); -} +bool BAND_PINWHEEL_SAT(effect_params_t* params) { return effect_runner_dx_dy(params, &BAND_PINWHEEL_SAT_math); } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT diff --git a/quantum/rgb_matrix_animations/colorband_pinwheel_val_anim.h b/quantum/rgb_matrix_animations/colorband_pinwheel_val_anim.h index 5cdb873489..7d80074fd5 100644 --- a/quantum/rgb_matrix_animations/colorband_pinwheel_val_anim.h +++ b/quantum/rgb_matrix_animations/colorband_pinwheel_val_anim.h @@ -1,15 +1,13 @@ #ifndef DISABLE_RGB_MATRIX_BAND_PINWHEEL_VAL RGB_MATRIX_EFFECT(BAND_PINWHEEL_VAL) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS static HSV BAND_PINWHEEL_VAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) { hsv.v = scale8(hsv.v - time - atan2_8(dy, dx) * 3, hsv.v); return hsv; } -bool BAND_PINWHEEL_VAL(effect_params_t* params) { - return effect_runner_dx_dy(params, &BAND_PINWHEEL_VAL_math); -} +bool BAND_PINWHEEL_VAL(effect_params_t* params) { return effect_runner_dx_dy(params, &BAND_PINWHEEL_VAL_math); } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_BAND_PINWHEEL_VAL +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // DISABLE_RGB_MATRIX_BAND_PINWHEEL_VAL diff --git a/quantum/rgb_matrix_animations/colorband_sat_anim.h b/quantum/rgb_matrix_animations/colorband_sat_anim.h index a5175f1cd9..35b830af6b 100644 --- a/quantum/rgb_matrix_animations/colorband_sat_anim.h +++ b/quantum/rgb_matrix_animations/colorband_sat_anim.h @@ -1,16 +1,14 @@ #ifndef DISABLE_RGB_MATRIX_BAND_SAT RGB_MATRIX_EFFECT(BAND_SAT) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS static HSV BAND_SAT_math(HSV hsv, uint8_t i, uint8_t time) { int16_t s = hsv.s - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8; - hsv.s = scale8(s < 0 ? 0 : s, hsv.s); + hsv.s = scale8(s < 0 ? 0 : s, hsv.s); return hsv; } -bool BAND_SAT(effect_params_t* params) { - return effect_runner_i(params, &BAND_SAT_math); -} +bool BAND_SAT(effect_params_t* params) { return effect_runner_i(params, &BAND_SAT_math); } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_BAND_SAT +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // DISABLE_RGB_MATRIX_BAND_SAT diff --git a/quantum/rgb_matrix_animations/colorband_spiral_sat_anim.h b/quantum/rgb_matrix_animations/colorband_spiral_sat_anim.h index 096c675de8..048157aa1b 100644 --- a/quantum/rgb_matrix_animations/colorband_spiral_sat_anim.h +++ b/quantum/rgb_matrix_animations/colorband_spiral_sat_anim.h @@ -1,15 +1,13 @@ #ifndef DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT RGB_MATRIX_EFFECT(BAND_SPIRAL_SAT) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS static HSV BAND_SPIRAL_SAT_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { hsv.s = scale8(hsv.s + dist - time - atan2_8(dy, dx), hsv.s); return hsv; } -bool BAND_SPIRAL_SAT(effect_params_t* params) { - return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_SAT_math); -} +bool BAND_SPIRAL_SAT(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_SAT_math); } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT diff --git a/quantum/rgb_matrix_animations/colorband_spiral_val_anim.h b/quantum/rgb_matrix_animations/colorband_spiral_val_anim.h index 1d4cc0c84f..bff2da1616 100644 --- a/quantum/rgb_matrix_animations/colorband_spiral_val_anim.h +++ b/quantum/rgb_matrix_animations/colorband_spiral_val_anim.h @@ -1,15 +1,13 @@ #ifndef DISABLE_RGB_MATRIX_BAND_SPIRAL_VAL RGB_MATRIX_EFFECT(BAND_SPIRAL_VAL) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS static HSV BAND_SPIRAL_VAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { hsv.v = scale8(hsv.v + dist - time - atan2_8(dy, dx), hsv.v); return hsv; } -bool BAND_SPIRAL_VAL(effect_params_t* params) { - return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_VAL_math); -} +bool BAND_SPIRAL_VAL(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_VAL_math); } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_BAND_SPIRAL_VAL +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // DISABLE_RGB_MATRIX_BAND_SPIRAL_VAL diff --git a/quantum/rgb_matrix_animations/colorband_val_anim.h b/quantum/rgb_matrix_animations/colorband_val_anim.h index de0bbb4715..f1aaf1d067 100644 --- a/quantum/rgb_matrix_animations/colorband_val_anim.h +++ b/quantum/rgb_matrix_animations/colorband_val_anim.h @@ -1,16 +1,14 @@ #ifndef DISABLE_RGB_MATRIX_BAND_VAL RGB_MATRIX_EFFECT(BAND_VAL) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS static HSV BAND_VAL_math(HSV hsv, uint8_t i, uint8_t time) { int16_t v = hsv.v - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8; - hsv.v = scale8(v < 0 ? 0 : v, hsv.v); + hsv.v = scale8(v < 0 ? 0 : v, hsv.v); return hsv; } -bool BAND_VAL(effect_params_t* params) { - return effect_runner_i(params, &BAND_VAL_math); -} +bool BAND_VAL(effect_params_t* params) { return effect_runner_i(params, &BAND_VAL_math); } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_BAND_VAL +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // DISABLE_RGB_MATRIX_BAND_VAL diff --git a/quantum/rgb_matrix_animations/cycle_all_anim.h b/quantum/rgb_matrix_animations/cycle_all_anim.h index 0c45aba8b1..faf8598a39 100644 --- a/quantum/rgb_matrix_animations/cycle_all_anim.h +++ b/quantum/rgb_matrix_animations/cycle_all_anim.h @@ -1,15 +1,13 @@ #ifndef DISABLE_RGB_MATRIX_CYCLE_ALL RGB_MATRIX_EFFECT(CYCLE_ALL) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static HSV CYCLE_ALL_math(HSV hsv, uint8_t i, uint8_t time){ +static HSV CYCLE_ALL_math(HSV hsv, uint8_t i, uint8_t time) { hsv.h = time; return hsv; } -bool CYCLE_ALL(effect_params_t* params) { - return effect_runner_i(params, &CYCLE_ALL_math); -} +bool CYCLE_ALL(effect_params_t* params) { return effect_runner_i(params, &CYCLE_ALL_math); } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_CYCLE_ALL +# 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 d2e5b4fbdf..cf911eb937 100644 --- a/quantum/rgb_matrix_animations/cycle_left_right_anim.h +++ b/quantum/rgb_matrix_animations/cycle_left_right_anim.h @@ -1,15 +1,13 @@ #ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT RGB_MATRIX_EFFECT(CYCLE_LEFT_RIGHT) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static HSV CYCLE_LEFT_RIGHT_math(HSV hsv, uint8_t i, uint8_t time) { +static HSV CYCLE_LEFT_RIGHT_math(HSV hsv, uint8_t i, uint8_t time) { hsv.h = g_led_config.point[i].x - time; return hsv; } -bool CYCLE_LEFT_RIGHT(effect_params_t* params) { - return effect_runner_i(params, &CYCLE_LEFT_RIGHT_math); -} +bool CYCLE_LEFT_RIGHT(effect_params_t* params) { return effect_runner_i(params, &CYCLE_LEFT_RIGHT_math); } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT diff --git a/quantum/rgb_matrix_animations/cycle_out_in_anim.h b/quantum/rgb_matrix_animations/cycle_out_in_anim.h index fa7c3b09cf..d66acd4b2b 100644 --- a/quantum/rgb_matrix_animations/cycle_out_in_anim.h +++ b/quantum/rgb_matrix_animations/cycle_out_in_anim.h @@ -1,15 +1,13 @@ #ifndef DISABLE_RGB_MATRIX_CYCLE_OUT_IN RGB_MATRIX_EFFECT(CYCLE_OUT_IN) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static HSV CYCLE_OUT_IN_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { +static HSV CYCLE_OUT_IN_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { hsv.h = 3 * dist / 2 + time; return hsv; } -bool CYCLE_OUT_IN(effect_params_t* params) { - return effect_runner_dx_dy_dist(params, &CYCLE_OUT_IN_math); -} +bool CYCLE_OUT_IN(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &CYCLE_OUT_IN_math); } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_CYCLE_OUT_IN +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // DISABLE_RGB_MATRIX_CYCLE_OUT_IN diff --git a/quantum/rgb_matrix_animations/cycle_out_in_dual_anim.h b/quantum/rgb_matrix_animations/cycle_out_in_dual_anim.h index 74a2c9aa58..fe8396140f 100644 --- a/quantum/rgb_matrix_animations/cycle_out_in_dual_anim.h +++ b/quantum/rgb_matrix_animations/cycle_out_in_dual_anim.h @@ -1,17 +1,15 @@ #ifndef DISABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL RGB_MATRIX_EFFECT(CYCLE_OUT_IN_DUAL) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static HSV CYCLE_OUT_IN_DUAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) { - dx = (k_rgb_matrix_center.x / 2) - abs8(dx); +static HSV CYCLE_OUT_IN_DUAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) { + dx = (k_rgb_matrix_center.x / 2) - abs8(dx); uint8_t dist = sqrt16(dx * dx + dy * dy); - hsv.h = 3 * dist + time; + hsv.h = 3 * dist + time; return hsv; } -bool CYCLE_OUT_IN_DUAL(effect_params_t* params) { - return effect_runner_dx_dy(params, &CYCLE_OUT_IN_DUAL_math); -} +bool CYCLE_OUT_IN_DUAL(effect_params_t* params) { return effect_runner_dx_dy(params, &CYCLE_OUT_IN_DUAL_math); } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // DISABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL diff --git a/quantum/rgb_matrix_animations/cycle_pinwheel_anim.h b/quantum/rgb_matrix_animations/cycle_pinwheel_anim.h index 54e222dc2e..7799887099 100644 --- a/quantum/rgb_matrix_animations/cycle_pinwheel_anim.h +++ b/quantum/rgb_matrix_animations/cycle_pinwheel_anim.h @@ -1,15 +1,13 @@ #ifndef DISABLE_RGB_MATRIX_CYCLE_PINWHEEL RGB_MATRIX_EFFECT(CYCLE_PINWHEEL) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static HSV CYCLE_PINWHEEL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) { +static HSV CYCLE_PINWHEEL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) { hsv.h = atan2_8(dy, dx) + time; return hsv; } -bool CYCLE_PINWHEEL(effect_params_t* params) { - return effect_runner_dx_dy(params, &CYCLE_PINWHEEL_math); -} +bool CYCLE_PINWHEEL(effect_params_t* params) { return effect_runner_dx_dy(params, &CYCLE_PINWHEEL_math); } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_CYCLE_PINWHEEL +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // DISABLE_RGB_MATRIX_CYCLE_PINWHEEL diff --git a/quantum/rgb_matrix_animations/cycle_spiral_anim.h b/quantum/rgb_matrix_animations/cycle_spiral_anim.h index b27d7a83c7..80cfb0dbc7 100644 --- a/quantum/rgb_matrix_animations/cycle_spiral_anim.h +++ b/quantum/rgb_matrix_animations/cycle_spiral_anim.h @@ -1,15 +1,13 @@ #ifndef DISABLE_RGB_MATRIX_CYCLE_SPIRAL RGB_MATRIX_EFFECT(CYCLE_SPIRAL) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static HSV CYCLE_SPIRAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { +static HSV CYCLE_SPIRAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) { hsv.h = dist - time - atan2_8(dy, dx); return hsv; } -bool CYCLE_SPIRAL(effect_params_t* params) { - return effect_runner_dx_dy_dist(params, &CYCLE_SPIRAL_math); -} +bool CYCLE_SPIRAL(effect_params_t* params) { return effect_runner_dx_dy_dist(params, &CYCLE_SPIRAL_math); } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_CYCLE_SPIRAL +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // DISABLE_RGB_MATRIX_CYCLE_SPIRAL diff --git a/quantum/rgb_matrix_animations/cycle_up_down_anim.h b/quantum/rgb_matrix_animations/cycle_up_down_anim.h index 4bf8ef2ae4..5016f739d6 100644 --- a/quantum/rgb_matrix_animations/cycle_up_down_anim.h +++ b/quantum/rgb_matrix_animations/cycle_up_down_anim.h @@ -1,15 +1,13 @@ #ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN RGB_MATRIX_EFFECT(CYCLE_UP_DOWN) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static HSV CYCLE_UP_DOWN_math(HSV hsv, uint8_t i, uint8_t time) { +static HSV CYCLE_UP_DOWN_math(HSV hsv, uint8_t i, uint8_t time) { hsv.h = g_led_config.point[i].y - time; return hsv; } -bool CYCLE_UP_DOWN(effect_params_t* params) { - return effect_runner_i(params, &CYCLE_UP_DOWN_math); -} +bool CYCLE_UP_DOWN(effect_params_t* params) { return effect_runner_i(params, &CYCLE_UP_DOWN_math); } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_CYCLE_UP_DOWN +# 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 982399cbde..7a4a52db1b 100644 --- a/quantum/rgb_matrix_animations/digital_rain_anim.h +++ b/quantum/rgb_matrix_animations/digital_rain_anim.h @@ -1,77 +1,75 @@ #if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_DIGITAL_RAIN) RGB_MATRIX_EFFECT(DIGITAL_RAIN) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# 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 +# ifndef RGB_DIGITAL_RAIN_DROPS +// lower the number for denser effect/wider keyboard +# define RGB_DIGITAL_RAIN_DROPS 24 +# endif 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; - const uint8_t max_brightness_boost = 0xc0; - const uint8_t max_intensity = 0xff; + // algorithm ported from https://github.com/tremby/Kaleidoscope-LEDEffect-DigitalRain + const uint8_t drop_ticks = 28; + const uint8_t pure_green_intensity = 0xd0; + const uint8_t max_brightness_boost = 0xc0; + const uint8_t max_intensity = 0xff; - static uint8_t drop = 0; + static uint8_t drop = 0; - if (params->init) { - rgb_matrix_set_color_all(0, 0, 0); - memset(rgb_frame_buffer, 0, sizeof(rgb_frame_buffer)); - drop = 0; - } + if (params->init) { + rgb_matrix_set_color_all(0, 0, 0); + memset(rgb_frame_buffer, 0, sizeof(rgb_frame_buffer)); + drop = 0; + } - for (uint8_t col = 0; col < MATRIX_COLS; col++) { - for (uint8_t row = 0; row < MATRIX_ROWS; row++) { - 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[row][col] = 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[row][col]--; - } - // set the pixel colour - uint8_t led[LED_HITS_TO_REMEMBER]; - uint8_t led_count = rgb_matrix_map_row_column_to_led(row, col, led); + for (uint8_t col = 0; col < MATRIX_COLS; col++) { + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + 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[row][col] = 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[row][col]--; + } + // set the pixel colour + uint8_t led[LED_HITS_TO_REMEMBER]; + uint8_t led_count = rgb_matrix_map_row_column_to_led(row, col, led); - // TODO: multiple leds are supported mapped to the same row/column - if (led_count > 0) { - 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[row][col] / pure_green_intensity); - rgb_matrix_set_color(led[0], 0, green, 0); + // TODO: multiple leds are supported mapped to the same row/column + if (led_count > 0) { + 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[row][col] / pure_green_intensity); + rgb_matrix_set_color(led[0], 0, green, 0); + } + } } - } } - } - if (++drop > drop_ticks) { - // reset drop timer - drop = 0; - 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[row][col] == max_intensity) { - rgb_frame_buffer[row][col]--; - } - // check if the pixel above is bright - if (rgb_frame_buffer[row - 1][col] == max_intensity) { - // allow old bright pixel to decay - rgb_frame_buffer[row - 1][col]--; - // make this pixel bright - rgb_frame_buffer[row][col] = max_intensity; + if (++drop > drop_ticks) { + // reset drop timer + drop = 0; + 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[row][col] == max_intensity) { + rgb_frame_buffer[row][col]--; + } + // check if the pixel above is bright + if (rgb_frame_buffer[row - 1][col] == max_intensity) { + // allow old bright pixel to decay + rgb_frame_buffer[row - 1][col]--; + // make this pixel bright + rgb_frame_buffer[row][col] = max_intensity; + } + } } - } } - } - return false; + return false; } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_DIGITAL_RAIN) +# 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 336a41b2ce..ce94871681 100644 --- a/quantum/rgb_matrix_animations/dual_beacon_anim.h +++ b/quantum/rgb_matrix_animations/dual_beacon_anim.h @@ -1,15 +1,13 @@ #ifndef DISABLE_RGB_MATRIX_DUAL_BEACON RGB_MATRIX_EFFECT(DUAL_BEACON) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static HSV DUAL_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { +static HSV DUAL_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { hsv.h += ((g_led_config.point[i].y - k_rgb_matrix_center.y) * cos + (g_led_config.point[i].x - k_rgb_matrix_center.x) * sin) / 128; return hsv; } -bool DUAL_BEACON(effect_params_t* params) { - return effect_runner_sin_cos_i(params, &DUAL_BEACON_math); -} +bool DUAL_BEACON(effect_params_t* params) { return effect_runner_sin_cos_i(params, &DUAL_BEACON_math); } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_DUAL_BEACON +# 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 12848ab4cc..0f1f8e23cf 100644 --- a/quantum/rgb_matrix_animations/gradient_up_down_anim.h +++ b/quantum/rgb_matrix_animations/gradient_up_down_anim.h @@ -1,22 +1,22 @@ #ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN RGB_MATRIX_EFFECT(GRADIENT_UP_DOWN) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS bool GRADIENT_UP_DOWN(effect_params_t* params) { - RGB_MATRIX_USE_LIMITS(led_min, led_max); + RGB_MATRIX_USE_LIMITS(led_min, led_max); - HSV hsv = rgb_matrix_config.hsv; - uint8_t scale = scale8(64, rgb_matrix_config.speed); - for (uint8_t i = led_min; i < led_max; i++) { - RGB_MATRIX_TEST_LED_FLAGS(); - // The y range will be 0..64, map this to 0..4 - // Relies on hue being 8-bit and wrapping - hsv.h = rgb_matrix_config.hsv.h + scale * (g_led_config.point[i].y >> 4); - RGB rgb = hsv_to_rgb(hsv); - rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); - } - return led_max < DRIVER_LED_TOTAL; + HSV hsv = rgb_matrix_config.hsv; + uint8_t scale = scale8(64, rgb_matrix_config.speed); + for (uint8_t i = led_min; i < led_max; i++) { + RGB_MATRIX_TEST_LED_FLAGS(); + // The y range will be 0..64, map this to 0..4 + // Relies on hue being 8-bit and wrapping + hsv.h = rgb_matrix_config.hsv.h + scale * (g_led_config.point[i].y >> 4); + RGB rgb = hsv_to_rgb(hsv); + rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); + } + return led_max < DRIVER_LED_TOTAL; } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN +# 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 bffa0a42d7..5596146a38 100644 --- a/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h +++ b/quantum/rgb_matrix_animations/jellybean_raindrops_anim.h @@ -1,29 +1,29 @@ #ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS RGB_MATRIX_EFFECT(JELLYBEAN_RAINDROPS) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# 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; - HSV hsv = { rand() & 0xFF , rand() & 0xFF, rgb_matrix_config.hsv.v }; - RGB rgb = hsv_to_rgb(hsv); - rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); + if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return; + HSV hsv = {rand() & 0xFF, rand() & 0xFF, rgb_matrix_config.hsv.v}; + RGB rgb = hsv_to_rgb(hsv); + rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } 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) { - jellybean_raindrops_set_color(rand() % DRIVER_LED_TOTAL, 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, params); + } + return false; } - return false; - } - RGB_MATRIX_USE_LIMITS(led_min, led_max); - for (int i = led_min; i < led_max; i++) { - jellybean_raindrops_set_color(i, params); - } - return led_max < DRIVER_LED_TOTAL; + RGB_MATRIX_USE_LIMITS(led_min, led_max); + for (int i = led_min; i < led_max; i++) { + jellybean_raindrops_set_color(i, params); + } + return led_max < DRIVER_LED_TOTAL; } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS +# 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 f53c819a9e..977261182f 100644 --- a/quantum/rgb_matrix_animations/rainbow_beacon_anim.h +++ b/quantum/rgb_matrix_animations/rainbow_beacon_anim.h @@ -1,15 +1,13 @@ #ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON RGB_MATRIX_EFFECT(RAINBOW_BEACON) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static HSV RAINBOW_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { +static HSV RAINBOW_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { hsv.h += ((g_led_config.point[i].y - k_rgb_matrix_center.y) * 2 * cos + (g_led_config.point[i].x - k_rgb_matrix_center.x) * 2 * sin) / 128; return hsv; } -bool RAINBOW_BEACON(effect_params_t* params) { - return effect_runner_sin_cos_i(params, &RAINBOW_BEACON_math); -} +bool RAINBOW_BEACON(effect_params_t* params) { return effect_runner_sin_cos_i(params, &RAINBOW_BEACON_math); } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_RAINBOW_BEACON +# 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 e78c55e8dd..e51e7b2516 100644 --- a/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h +++ b/quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h @@ -1,15 +1,13 @@ #ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON RGB_MATRIX_EFFECT(RAINBOW_MOVING_CHEVRON) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static HSV RAINBOW_MOVING_CHEVRON_math(HSV hsv, uint8_t i, uint8_t time) { +static HSV RAINBOW_MOVING_CHEVRON_math(HSV hsv, uint8_t i, uint8_t time) { hsv.h += abs8(g_led_config.point[i].y - k_rgb_matrix_center.y) + (g_led_config.point[i].x - time); return hsv; } -bool RAINBOW_MOVING_CHEVRON(effect_params_t* params) { - return effect_runner_i(params, &RAINBOW_MOVING_CHEVRON_math); -} +bool RAINBOW_MOVING_CHEVRON(effect_params_t* params) { return effect_runner_i(params, &RAINBOW_MOVING_CHEVRON_math); } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON +# 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 8298fec468..4f69456c3a 100644 --- a/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h +++ b/quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h @@ -1,15 +1,13 @@ #ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS RGB_MATRIX_EFFECT(PINWHEELS) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static HSV PINWHEELS_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { +static HSV PINWHEELS_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) { hsv.h += ((g_led_config.point[i].y - k_rgb_matrix_center.y) * 3 * cos + (56 - abs8(g_led_config.point[i].x - k_rgb_matrix_center.x)) * 3 * sin) / 128; return hsv; } -bool PINWHEELS(effect_params_t* params) { - return effect_runner_sin_cos_i(params, &PINWHEELS_math); -} +bool PINWHEELS(effect_params_t* params) { return effect_runner_sin_cos_i(params, &PINWHEELS_math); } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS +# 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 a4fed51658..9f839a1bce 100644 --- a/quantum/rgb_matrix_animations/raindrops_anim.h +++ b/quantum/rgb_matrix_animations/raindrops_anim.h @@ -1,39 +1,39 @@ #ifndef DISABLE_RGB_MATRIX_RAINDROPS RGB_MATRIX_EFFECT(RAINDROPS) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# 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; - HSV hsv = { 0 , rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v }; + if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return; + HSV hsv = {0, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v}; - // Take the shortest path between hues - int16_t deltaH = ((rgb_matrix_config.hsv.h + 180) % 360 - rgb_matrix_config.hsv.h) / 4; - if (deltaH > 127) { - deltaH -= 256; - } else if (deltaH < -127) { - deltaH += 256; - } + // Take the shortest path between hues + int16_t deltaH = ((rgb_matrix_config.hsv.h + 180) % 360 - rgb_matrix_config.hsv.h) / 4; + if (deltaH > 127) { + deltaH -= 256; + } else if (deltaH < -127) { + deltaH += 256; + } - hsv.h = rgb_matrix_config.hsv.h + (deltaH * (rand() & 0x03)); - RGB rgb = hsv_to_rgb(hsv); - rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); + hsv.h = rgb_matrix_config.hsv.h + (deltaH * (rand() & 0x03)); + RGB rgb = hsv_to_rgb(hsv); + rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } 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) { - raindrops_set_color(rand() % DRIVER_LED_TOTAL, 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, params); + } + return false; } - return false; - } - RGB_MATRIX_USE_LIMITS(led_min, led_max); - for (int i = led_min; i < led_max; i++) { - raindrops_set_color(i, params); - } - return led_max < DRIVER_LED_TOTAL; + RGB_MATRIX_USE_LIMITS(led_min, led_max); + for (int i = led_min; i < led_max; i++) { + raindrops_set_color(i, params); + } + return led_max < DRIVER_LED_TOTAL; } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_RAINDROPS +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // DISABLE_RGB_MATRIX_RAINDROPS diff --git a/quantum/rgb_matrix_animations/solid_color_anim.h b/quantum/rgb_matrix_animations/solid_color_anim.h index 6e40638035..c8f5e70e7a 100644 --- a/quantum/rgb_matrix_animations/solid_color_anim.h +++ b/quantum/rgb_matrix_animations/solid_color_anim.h @@ -2,14 +2,14 @@ RGB_MATRIX_EFFECT(SOLID_COLOR) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS bool SOLID_COLOR(effect_params_t* params) { - RGB_MATRIX_USE_LIMITS(led_min, led_max); + RGB_MATRIX_USE_LIMITS(led_min, led_max); - RGB rgb = hsv_to_rgb(rgb_matrix_config.hsv); - for (uint8_t i = led_min; i < led_max; i++) { - RGB_MATRIX_TEST_LED_FLAGS(); - rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); - } - return led_max < DRIVER_LED_TOTAL; + RGB rgb = hsv_to_rgb(rgb_matrix_config.hsv); + for (uint8_t i = led_min; i < led_max; i++) { + RGB_MATRIX_TEST_LED_FLAGS(); + rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); + } + return led_max < DRIVER_LED_TOTAL; } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#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 dd49b6530e..d45bb961bc 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_anim.h +++ b/quantum/rgb_matrix_animations/solid_reactive_anim.h @@ -1,17 +1,15 @@ #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED -#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE +# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE RGB_MATRIX_EFFECT(SOLID_REACTIVE) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static HSV SOLID_REACTIVE_math(HSV hsv, uint16_t 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) { - return effect_runner_reactive(params, &SOLID_REACTIVE_math); -} +bool SOLID_REACTIVE(effect_params_t* params) { return effect_runner_reactive(params, &SOLID_REACTIVE_math); } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE -#endif // 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 5b9cfcbd52..f76c68e8c7 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_cross.h +++ b/quantum/rgb_matrix_animations/solid_reactive_cross.h @@ -1,41 +1,36 @@ #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED -#if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) +# if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) -#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS +# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS RGB_MATRIX_EFFECT(SOLID_REACTIVE_CROSS) -#endif +# endif -#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS +# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTICROSS) -#endif +# endif -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static HSV SOLID_REACTIVE_CROSS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { +static HSV SOLID_REACTIVE_CROSS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { uint16_t effect = tick + dist; - dx = dx < 0 ? dx * -1 : dx; - dy = dy < 0 ? dy * -1 : dy; - dx = dx * 16 > 255 ? 255 : dx * 16; - dy = dy * 16 > 255 ? 255 : dy * 16; + dx = dx < 0 ? dx * -1 : dx; + dy = dy < 0 ? dy * -1 : dy; + dx = dx * 16 > 255 ? 255 : dx * 16; + dy = dy * 16 > 255 ? 255 : dy * 16; effect += dx > dy ? dy : dx; - if (effect > 255) - effect = 255; + if (effect > 255) effect = 255; hsv.v = qadd8(hsv.v, 255 - effect); return hsv; } -#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS -bool SOLID_REACTIVE_CROSS(effect_params_t* params) { - return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_CROSS_math); -} -#endif +# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS +bool SOLID_REACTIVE_CROSS(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_CROSS_math); } +# endif -#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS -bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) { - return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_CROSS_math); -} -#endif +# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS +bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_CROSS_math); } +# endif -#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 +# 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 e90eaf4b28..17f94e3c18 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_nexus.h +++ b/quantum/rgb_matrix_animations/solid_reactive_nexus.h @@ -1,41 +1,34 @@ #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED -#if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) +# if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) -#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS +# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS RGB_MATRIX_EFFECT(SOLID_REACTIVE_NEXUS) -#endif +# endif -#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS +# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTINEXUS) -#endif +# endif -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static HSV SOLID_REACTIVE_NEXUS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { +static HSV SOLID_REACTIVE_NEXUS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { uint16_t effect = tick - dist; - if (effect > 255) - effect = 255; - if (dist > 72) - effect = 255; - if ((dx > 8 || dx < -8) && (dy > 8 || dy < -8)) - effect = 255; + if (effect > 255) effect = 255; + if (dist > 72) effect = 255; + if ((dx > 8 || dx < -8) && (dy > 8 || dy < -8)) effect = 255; hsv.v = qadd8(hsv.v, 255 - effect); hsv.h = rgb_matrix_config.hsv.h + dy / 4; return hsv; } -#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS -bool SOLID_REACTIVE_NEXUS(effect_params_t* params) { - return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_NEXUS_math); -} -#endif +# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS +bool SOLID_REACTIVE_NEXUS(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_NEXUS_math); } +# endif -#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS -bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) { - return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_NEXUS_math); -} -#endif +# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS +bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_NEXUS_math); } +# endif -#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 +# 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 77c8ff6724..12eb248cc0 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h +++ b/quantum/rgb_matrix_animations/solid_reactive_simple_anim.h @@ -1,17 +1,15 @@ #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED -#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE +# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE RGB_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static HSV SOLID_REACTIVE_SIMPLE_math(HSV hsv, uint16_t offset) { +static HSV SOLID_REACTIVE_SIMPLE_math(HSV hsv, uint16_t offset) { hsv.v = scale8(255 - offset, hsv.v); return hsv; } -bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) { - return effect_runner_reactive(params, &SOLID_REACTIVE_SIMPLE_math); -} +bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) { return effect_runner_reactive(params, &SOLID_REACTIVE_SIMPLE_math); } -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED +# 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 73779dfa74..1cc4dca728 100644 --- a/quantum/rgb_matrix_animations/solid_reactive_wide.h +++ b/quantum/rgb_matrix_animations/solid_reactive_wide.h @@ -1,36 +1,31 @@ #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED -#if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) +# if !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) -#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE +# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE RGB_MATRIX_EFFECT(SOLID_REACTIVE_WIDE) -#endif +# endif -#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE +# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTIWIDE) -#endif +# endif -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -static HSV SOLID_REACTIVE_WIDE_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { +static HSV SOLID_REACTIVE_WIDE_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { uint16_t effect = tick + dist * 5; - if (effect > 255) - effect = 255; + if (effect > 255) effect = 255; hsv.v = qadd8(hsv.v, 255 - effect); return hsv; } -#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE -bool SOLID_REACTIVE_WIDE(effect_params_t* params) { - return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_WIDE_math); -} -#endif +# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE +bool SOLID_REACTIVE_WIDE(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_WIDE_math); } +# endif -#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE -bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) { - return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_WIDE_math); -} -#endif +# ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE +bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_WIDE_math); } +# endif -#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 +# 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 441f35576b..99efb4996a 100644 --- a/quantum/rgb_matrix_animations/solid_splash_anim.h +++ b/quantum/rgb_matrix_animations/solid_splash_anim.h @@ -1,36 +1,31 @@ #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED -#if !defined(DISABLE_RGB_MATRIX_SOLID_SPLASH) || !defined(DISABLE_RGB_MATRIX_SOLID_MULTISPLASH) +# if !defined(DISABLE_RGB_MATRIX_SOLID_SPLASH) || !defined(DISABLE_RGB_MATRIX_SOLID_MULTISPLASH) -#ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH +# ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH RGB_MATRIX_EFFECT(SOLID_SPLASH) -#endif +# endif -#ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH +# ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH RGB_MATRIX_EFFECT(SOLID_MULTISPLASH) -#endif +# endif -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -HSV SOLID_SPLASH_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { +HSV SOLID_SPLASH_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { uint16_t effect = tick - dist; - if (effect > 255) - effect = 255; + if (effect > 255) effect = 255; hsv.v = qadd8(hsv.v, 255 - effect); return hsv; } -#ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH -bool SOLID_SPLASH(effect_params_t* params) { - return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_SPLASH_math); -} -#endif +# ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH +bool SOLID_SPLASH(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_SPLASH_math); } +# endif -#ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH -bool SOLID_MULTISPLASH(effect_params_t* params) { - return effect_runner_reactive_splash(0, params, &SOLID_SPLASH_math); -} -#endif +# ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH +bool SOLID_MULTISPLASH(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_SPLASH_math); } +# endif -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // !defined(DISABLE_RGB_MATRIX_SPLASH) && !defined(DISABLE_RGB_MATRIX_MULTISPLASH) -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED +# 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 19ccb256e9..1415bcc0fa 100644 --- a/quantum/rgb_matrix_animations/splash_anim.h +++ b/quantum/rgb_matrix_animations/splash_anim.h @@ -1,37 +1,32 @@ #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED -#if !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH) +# if !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH) -#ifndef DISABLE_RGB_MATRIX_SPLASH +# ifndef DISABLE_RGB_MATRIX_SPLASH RGB_MATRIX_EFFECT(SPLASH) -#endif +# endif -#ifndef DISABLE_RGB_MATRIX_MULTISPLASH +# ifndef DISABLE_RGB_MATRIX_MULTISPLASH RGB_MATRIX_EFFECT(MULTISPLASH) -#endif +# endif -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -HSV SPLASH_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { +HSV SPLASH_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { uint16_t effect = tick - dist; - if (effect > 255) - effect = 255; + if (effect > 255) effect = 255; hsv.h += effect; hsv.v = qadd8(hsv.v, 255 - effect); return hsv; } -#ifndef DISABLE_RGB_MATRIX_SPLASH -bool SPLASH(effect_params_t* params) { - return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SPLASH_math); -} -#endif +# ifndef DISABLE_RGB_MATRIX_SPLASH +bool SPLASH(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SPLASH_math); } +# endif -#ifndef DISABLE_RGB_MATRIX_MULTISPLASH -bool MULTISPLASH(effect_params_t* params) { - return effect_runner_reactive_splash(0, params, &SPLASH_math); -} -#endif +# ifndef DISABLE_RGB_MATRIX_MULTISPLASH +bool MULTISPLASH(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SPLASH_math); } +# endif -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH) -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED +# 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 374b7fea0c..dd313f16a5 100644 --- a/quantum/rgb_matrix_animations/typing_heatmap_anim.h +++ b/quantum/rgb_matrix_animations/typing_heatmap_anim.h @@ -1,74 +1,65 @@ #if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP) RGB_MATRIX_EFFECT(TYPING_HEATMAP) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -void process_rgb_matrix_typing_heatmap(keyrecord_t *record) { - uint8_t row = record->event.key.row; - uint8_t col = record->event.key.col; +void process_rgb_matrix_typing_heatmap(keyrecord_t* record) { + uint8_t row = record->event.key.row; + uint8_t col = record->event.key.col; uint8_t m_row = row - 1; uint8_t p_row = row + 1; uint8_t m_col = col - 1; uint8_t p_col = col + 1; - if (m_col < col) - rgb_frame_buffer[row][m_col] = qadd8(rgb_frame_buffer[row][m_col], 16); + if (m_col < col) rgb_frame_buffer[row][m_col] = qadd8(rgb_frame_buffer[row][m_col], 16); rgb_frame_buffer[row][col] = qadd8(rgb_frame_buffer[row][col], 32); - if (p_col < MATRIX_COLS) - rgb_frame_buffer[row][p_col] = qadd8(rgb_frame_buffer[row][p_col], 16); + if (p_col < MATRIX_COLS) rgb_frame_buffer[row][p_col] = qadd8(rgb_frame_buffer[row][p_col], 16); if (p_row < MATRIX_ROWS) { - if (m_col < col) - rgb_frame_buffer[p_row][m_col] = qadd8(rgb_frame_buffer[p_row][m_col], 13); - rgb_frame_buffer[p_row][col] = qadd8(rgb_frame_buffer[p_row][col], 16); - if (p_col < MATRIX_COLS) - rgb_frame_buffer[p_row][p_col] = qadd8(rgb_frame_buffer[p_row][p_col], 13); + if (m_col < col) rgb_frame_buffer[p_row][m_col] = qadd8(rgb_frame_buffer[p_row][m_col], 13); + rgb_frame_buffer[p_row][col] = qadd8(rgb_frame_buffer[p_row][col], 16); + if (p_col < MATRIX_COLS) rgb_frame_buffer[p_row][p_col] = qadd8(rgb_frame_buffer[p_row][p_col], 13); } if (m_row < row) { - if (m_col < col) - rgb_frame_buffer[m_row][m_col] = qadd8(rgb_frame_buffer[m_row][m_col], 13); - rgb_frame_buffer[m_row][col] = qadd8(rgb_frame_buffer[m_row][col], 16); - if (p_col < MATRIX_COLS) - rgb_frame_buffer[m_row][p_col] = qadd8(rgb_frame_buffer[m_row][p_col], 13); + if (m_col < col) rgb_frame_buffer[m_row][m_col] = qadd8(rgb_frame_buffer[m_row][m_col], 13); + rgb_frame_buffer[m_row][col] = qadd8(rgb_frame_buffer[m_row][col], 16); + if (p_col < MATRIX_COLS) rgb_frame_buffer[m_row][p_col] = qadd8(rgb_frame_buffer[m_row][p_col], 13); } } 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; - if (led_max > sizeof(rgb_frame_buffer)) - led_max = sizeof(rgb_frame_buffer); + // 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; + if (led_max > sizeof(rgb_frame_buffer)) led_max = sizeof(rgb_frame_buffer); - if (params->init) { - rgb_matrix_set_color_all(0, 0, 0); - memset(rgb_frame_buffer, 0, sizeof rgb_frame_buffer); - } + if (params->init) { + rgb_matrix_set_color_all(0, 0, 0); + memset(rgb_frame_buffer, 0, sizeof rgb_frame_buffer); + } - // Render heatmap & decrease - for (int i = led_min; i < led_max; i++) { - uint8_t row = i % MATRIX_ROWS; - uint8_t col = i / MATRIX_ROWS; - uint8_t val = rgb_frame_buffer[row][col]; + // Render heatmap & decrease + for (int i = led_min; i < led_max; i++) { + uint8_t row = i % MATRIX_ROWS; + uint8_t col = i / MATRIX_ROWS; + uint8_t val = rgb_frame_buffer[row][col]; - // set the pixel colour - uint8_t led[LED_HITS_TO_REMEMBER]; - uint8_t led_count = rgb_matrix_map_row_column_to_led(row, col, led); - for (uint8_t j = 0; j < led_count; ++j) - { - if (!HAS_ANY_FLAGS(g_led_config.flags[led[j]], params->flags)) - continue; + // set the pixel colour + uint8_t led[LED_HITS_TO_REMEMBER]; + uint8_t led_count = rgb_matrix_map_row_column_to_led(row, col, led); + for (uint8_t j = 0; j < led_count; ++j) { + if (!HAS_ANY_FLAGS(g_led_config.flags[led[j]], params->flags)) continue; - HSV hsv = { 170 - qsub8(val, 85), rgb_matrix_config.hsv.s, scale8((qadd8(170, val) - 170) * 3, rgb_matrix_config.hsv.v) }; - RGB rgb = hsv_to_rgb(hsv); - rgb_matrix_set_color(led[j], rgb.r, rgb.g, rgb.b); - } + HSV hsv = {170 - qsub8(val, 85), rgb_matrix_config.hsv.s, scale8((qadd8(170, val) - 170) * 3, rgb_matrix_config.hsv.v)}; + RGB rgb = hsv_to_rgb(hsv); + rgb_matrix_set_color(led[j], rgb.r, rgb.g, rgb.b); + } - rgb_frame_buffer[row][col] = qsub8(val, 1); - } + rgb_frame_buffer[row][col] = qsub8(val, 1); + } - return led_max < sizeof(rgb_frame_buffer); + 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) +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP) |