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/ |