diff options
Diffstat (limited to 'quantum/rgb_matrix')
46 files changed, 493 insertions, 198 deletions
diff --git a/quantum/rgb_matrix/animations/alpha_mods_anim.h b/quantum/rgb_matrix/animations/alpha_mods_anim.h index d6136f1ba4..59b8381d69 100644 --- a/quantum/rgb_matrix/animations/alpha_mods_anim.h +++ b/quantum/rgb_matrix/animations/alpha_mods_anim.h @@ -22,5 +22,5 @@ bool ALPHAS_MODS(effect_params_t* params) { return rgb_matrix_check_finished_leds(led_max); } -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_ALPHAS_MODS +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_RGB_MATRIX_ALPHAS_MODS diff --git a/quantum/rgb_matrix/animations/breathing_anim.h b/quantum/rgb_matrix/animations/breathing_anim.h index 29187e1543..e9a3c96e1b 100644 --- a/quantum/rgb_matrix/animations/breathing_anim.h +++ b/quantum/rgb_matrix/animations/breathing_anim.h @@ -16,5 +16,5 @@ bool BREATHING(effect_params_t* params) { return rgb_matrix_check_finished_leds(led_max); } -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_BREATHING +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_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 0375d4937d..06aa8b5ed5 100644 --- a/quantum/rgb_matrix/animations/colorband_pinwheel_sat_anim.h +++ b/quantum/rgb_matrix/animations/colorband_pinwheel_sat_anim.h @@ -7,7 +7,9 @@ static HSV BAND_PINWHEEL_SAT_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) 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 // ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_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 e40bf4cd1f..bcbc319498 100644 --- a/quantum/rgb_matrix/animations/colorband_pinwheel_val_anim.h +++ b/quantum/rgb_matrix/animations/colorband_pinwheel_val_anim.h @@ -7,7 +7,9 @@ static HSV BAND_PINWHEEL_VAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) 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 // ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_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 1c4f7de575..cb0897ad3e 100644 --- a/quantum/rgb_matrix/animations/colorband_sat_anim.h +++ b/quantum/rgb_matrix/animations/colorband_sat_anim.h @@ -8,7 +8,9 @@ static HSV BAND_SAT_math(HSV hsv, uint8_t i, uint8_t time) { 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 // ENABLE_RGB_MATRIX_BAND_SAT +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_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 cdd02b3797..d26eb37855 100644 --- a/quantum/rgb_matrix/animations/colorband_spiral_sat_anim.h +++ b/quantum/rgb_matrix/animations/colorband_spiral_sat_anim.h @@ -7,7 +7,9 @@ static HSV BAND_SPIRAL_SAT_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, u 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 // ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_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 e1331eaebe..3ae34bb6f0 100644 --- a/quantum/rgb_matrix/animations/colorband_spiral_val_anim.h +++ b/quantum/rgb_matrix/animations/colorband_spiral_val_anim.h @@ -7,7 +7,9 @@ static HSV BAND_SPIRAL_VAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, u 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 // ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_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 02ee4add67..69c29f53a3 100644 --- a/quantum/rgb_matrix/animations/colorband_val_anim.h +++ b/quantum/rgb_matrix/animations/colorband_val_anim.h @@ -8,7 +8,9 @@ static HSV BAND_VAL_math(HSV hsv, uint8_t i, uint8_t time) { 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 // ENABLE_RGB_MATRIX_BAND_VAL +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_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 3b73b9d385..d8c7220d95 100644 --- a/quantum/rgb_matrix/animations/cycle_all_anim.h +++ b/quantum/rgb_matrix/animations/cycle_all_anim.h @@ -7,7 +7,9 @@ static HSV CYCLE_ALL_math(HSV hsv, uint8_t i, uint8_t 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 // ENABLE_RGB_MATRIX_CYCLE_ALL +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_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 bf6a574069..84c2127aff 100644 --- a/quantum/rgb_matrix/animations/cycle_left_right_anim.h +++ b/quantum/rgb_matrix/animations/cycle_left_right_anim.h @@ -7,7 +7,9 @@ static HSV CYCLE_LEFT_RIGHT_math(HSV hsv, uint8_t i, uint8_t 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 // ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_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 2bdb9d9375..9513fe9593 100644 --- a/quantum/rgb_matrix/animations/cycle_out_in_anim.h +++ b/quantum/rgb_matrix/animations/cycle_out_in_anim.h @@ -7,7 +7,9 @@ static HSV CYCLE_OUT_IN_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint 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 // ENABLE_RGB_MATRIX_CYCLE_OUT_IN +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_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 51979c44fe..3cca45f27a 100644 --- a/quantum/rgb_matrix/animations/cycle_out_in_dual_anim.h +++ b/quantum/rgb_matrix/animations/cycle_out_in_dual_anim.h @@ -9,7 +9,9 @@ static HSV CYCLE_OUT_IN_DUAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t 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 // ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_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 10ba2b7c2c..de5993992c 100644 --- a/quantum/rgb_matrix/animations/cycle_pinwheel_anim.h +++ b/quantum/rgb_matrix/animations/cycle_pinwheel_anim.h @@ -7,7 +7,9 @@ static HSV CYCLE_PINWHEEL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t 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 // ENABLE_RGB_MATRIX_CYCLE_PINWHEEL +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_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 482c7e7da6..904450179e 100644 --- a/quantum/rgb_matrix/animations/cycle_spiral_anim.h +++ b/quantum/rgb_matrix/animations/cycle_spiral_anim.h @@ -7,7 +7,9 @@ static HSV CYCLE_SPIRAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint 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 // ENABLE_RGB_MATRIX_CYCLE_SPIRAL +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_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 277edccb2f..dce05fecff 100644 --- a/quantum/rgb_matrix/animations/cycle_up_down_anim.h +++ b/quantum/rgb_matrix/animations/cycle_up_down_anim.h @@ -7,7 +7,9 @@ static HSV CYCLE_UP_DOWN_math(HSV hsv, uint8_t i, uint8_t 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 // ENABLE_RGB_MATRIX_CYCLE_UP_DOWN +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_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 8ce8fd7039..4633145ff6 100644 --- a/quantum/rgb_matrix/animations/digital_rain_anim.h +++ b/quantum/rgb_matrix/animations/digital_rain_anim.h @@ -71,5 +71,5 @@ bool DIGITAL_RAIN(effect_params_t* params) { return false; } -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(ENABLE_RGB_MATRIX_DIGITAL_RAIN) +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(ENABLE_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 dbe9b3ecf1..5585015b86 100644 --- a/quantum/rgb_matrix/animations/dual_beacon_anim.h +++ b/quantum/rgb_matrix/animations/dual_beacon_anim.h @@ -7,7 +7,9 @@ static HSV DUAL_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t 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 // ENABLE_RGB_MATRIX_DUAL_BEACON +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_RGB_MATRIX_DUAL_BEACON diff --git a/quantum/rgb_matrix/animations/gradient_left_right_anim.h b/quantum/rgb_matrix/animations/gradient_left_right_anim.h index 8bb5e570bd..ebb06f59f2 100644 --- a/quantum/rgb_matrix/animations/gradient_left_right_anim.h +++ b/quantum/rgb_matrix/animations/gradient_left_right_anim.h @@ -18,5 +18,5 @@ bool GRADIENT_LEFT_RIGHT(effect_params_t* params) { return rgb_matrix_check_finished_leds(led_max); } -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT diff --git a/quantum/rgb_matrix/animations/gradient_up_down_anim.h b/quantum/rgb_matrix/animations/gradient_up_down_anim.h index a5674583e3..febc3919a8 100644 --- a/quantum/rgb_matrix/animations/gradient_up_down_anim.h +++ b/quantum/rgb_matrix/animations/gradient_up_down_anim.h @@ -18,5 +18,5 @@ bool GRADIENT_UP_DOWN(effect_params_t* params) { return rgb_matrix_check_finished_leds(led_max); } -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN diff --git a/quantum/rgb_matrix/animations/hue_breathing_anim.h b/quantum/rgb_matrix/animations/hue_breathing_anim.h index 82be1a4424..8537762832 100644 --- a/quantum/rgb_matrix/animations/hue_breathing_anim.h +++ b/quantum/rgb_matrix/animations/hue_breathing_anim.h @@ -18,5 +18,5 @@ bool HUE_BREATHING(effect_params_t* params) { return rgb_matrix_check_finished_leds(led_max); } -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_HUE_BREATHING +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // DISABLE_RGB_HUE_BREATHING diff --git a/quantum/rgb_matrix/animations/hue_pendulum_anim.h b/quantum/rgb_matrix/animations/hue_pendulum_anim.h index a6e1c1074d..7d8cbcdfb2 100644 --- a/quantum/rgb_matrix/animations/hue_pendulum_anim.h +++ b/quantum/rgb_matrix/animations/hue_pendulum_anim.h @@ -11,7 +11,9 @@ static HSV HUE_PENDULUM_math(HSV hsv, uint8_t i, uint8_t time) { return hsv; } -bool HUE_PENDULUM(effect_params_t* params) { return effect_runner_i(params, &HUE_PENDULUM_math); } +bool HUE_PENDULUM(effect_params_t* params) { + return effect_runner_i(params, &HUE_PENDULUM_math); +} -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_HUE_PENDULUM +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // DISABLE_RGB_HUE_PENDULUM diff --git a/quantum/rgb_matrix/animations/hue_wave_anim.h b/quantum/rgb_matrix/animations/hue_wave_anim.h index b1c72b7336..81aa7e139e 100644 --- a/quantum/rgb_matrix/animations/hue_wave_anim.h +++ b/quantum/rgb_matrix/animations/hue_wave_anim.h @@ -11,7 +11,9 @@ static HSV HUE_WAVE_math(HSV hsv, uint8_t i, uint8_t time) { return hsv; } -bool HUE_WAVE(effect_params_t* params) { return effect_runner_i(params, &HUE_WAVE_math); } +bool HUE_WAVE(effect_params_t* params) { + return effect_runner_i(params, &HUE_WAVE_math); +} -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_HUE_WAVE +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // DISABLE_RGB_HUE_WAVE diff --git a/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h b/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h index 3ffb57eb35..31dffcbc5a 100644 --- a/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h +++ b/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h @@ -25,5 +25,5 @@ bool JELLYBEAN_RAINDROPS(effect_params_t* params) { return rgb_matrix_check_finished_leds(led_max); } -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS diff --git a/quantum/rgb_matrix/animations/pixel_flow_anim.h b/quantum/rgb_matrix/animations/pixel_flow_anim.h new file mode 100644 index 0000000000..714f5d174e --- /dev/null +++ b/quantum/rgb_matrix/animations/pixel_flow_anim.h @@ -0,0 +1,51 @@ +// Copyright 2022 @filterpaper +// SPDX-License-Identifier: GPL-2.0+ + +#ifdef ENABLE_RGB_MATRIX_PIXEL_FLOW +RGB_MATRIX_EFFECT(PIXEL_FLOW) +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS + +static bool PIXEL_FLOW(effect_params_t* params) { + // LED state array + static RGB led[DRIVER_LED_TOTAL]; + + static uint32_t wait_timer = 0; + if (wait_timer > g_rgb_timer) { + return false; + } + + inline uint32_t interval(void) { + return 3000 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); + } + + if (params->init) { + // Clear LEDs and fill the state array + rgb_matrix_set_color_all(0, 0, 0); + for (uint8_t j = 0; j < DRIVER_LED_TOTAL; ++j) { + led[j] = (random8() & 2) ? (RGB){0, 0, 0} : hsv_to_rgb((HSV){random8(), qadd8(random8() >> 1, 127), rgb_matrix_config.hsv.v}); + } + } + + RGB_MATRIX_USE_LIMITS(led_min, led_max); + // Light LEDs based on state array + for (uint8_t i = led_min; i < led_max; ++i) { + RGB_MATRIX_TEST_LED_FLAGS(); + rgb_matrix_set_color(i, led[i].r, led[i].g, led[i].b); + } + + if (!rgb_matrix_check_finished_leds(led_max)) { + // Shift LED state forward + for (uint8_t j = 0; j < led_max - 1; ++j) { + led[j] = led[j + 1]; + } + // Fill last LED + led[led_max - 1] = (random8() & 2) ? (RGB){0, 0, 0} : hsv_to_rgb((HSV){random8(), qadd8(random8() >> 1, 127), rgb_matrix_config.hsv.v}); + // Set pulse timer + wait_timer = g_rgb_timer + interval(); + } + + return rgb_matrix_check_finished_leds(led_max); +} + +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_RGB_MATRIX_PIXEL_FLOW diff --git a/quantum/rgb_matrix/animations/pixel_fractal_anim.h b/quantum/rgb_matrix/animations/pixel_fractal_anim.h index 8e25ec402c..906da1a48e 100644 --- a/quantum/rgb_matrix/animations/pixel_fractal_anim.h +++ b/quantum/rgb_matrix/animations/pixel_fractal_anim.h @@ -29,11 +29,17 @@ static bool PIXEL_FRACTAL(effect_params_t* params) { return false; } - inline uint32_t interval(void) { return 3000 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); } + inline uint32_t interval(void) { + return 3000 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); + } + + if (params->init) { + rgb_matrix_set_color_all(0, 0, 0); + } RGB rgb = rgb_matrix_hsv_to_rgb(rgb_matrix_config.hsv); for (uint8_t h = 0; h < MATRIX_ROWS; ++h) { - for (uint8_t l = 0; l < MID_COL - 1; ++l) { // Light and move left columns outwards + for (uint8_t l = 0; l < MID_COL - 1; ++l) { // Light and move left columns outwards if (led[h][l]) { rgb_matrix_set_color(g_led_config.matrix_co[h][l], rgb.r, rgb.g, rgb.b); } else { @@ -42,7 +48,7 @@ static bool PIXEL_FRACTAL(effect_params_t* params) { led[h][l] = led[h][l + 1]; } - for (uint8_t r = MATRIX_COLS - 1; r > MID_COL; --r) { // Light and move right columns outwards + for (uint8_t r = MATRIX_COLS - 1; r > MID_COL; --r) { // Light and move right columns outwards if (led[h][r]) { rgb_matrix_set_color(g_led_config.matrix_co[h][r], rgb.r, rgb.g, rgb.b); } else { @@ -70,5 +76,5 @@ static bool PIXEL_FRACTAL(effect_params_t* params) { wait_timer = g_rgb_timer + interval(); return false; } -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_PIXEL_FRACTAL +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_RGB_MATRIX_PIXEL_FRACTAL diff --git a/quantum/rgb_matrix/animations/pixel_rain_anim.h b/quantum/rgb_matrix/animations/pixel_rain_anim.h index 001649aa6e..03488b43df 100644 --- a/quantum/rgb_matrix/animations/pixel_rain_anim.h +++ b/quantum/rgb_matrix/animations/pixel_rain_anim.h @@ -24,7 +24,9 @@ static bool PIXEL_RAIN(effect_params_t* params) { return false; } - inline uint32_t interval(void) { return 500 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); } + inline uint32_t interval(void) { + return 500 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); + } bool rain_pixel(uint8_t i, effect_params_t * params, bool off) { if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) { @@ -44,5 +46,5 @@ static bool PIXEL_RAIN(effect_params_t* params) { return rain_pixel(mod8(random8(), DRIVER_LED_TOTAL), params, random8() & 2); } -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_PIXEL_RAIN +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_RGB_MATRIX_PIXEL_RAIN diff --git a/quantum/rgb_matrix/animations/rainbow_beacon_anim.h b/quantum/rgb_matrix/animations/rainbow_beacon_anim.h index cd529958db..bdcca5530f 100644 --- a/quantum/rgb_matrix/animations/rainbow_beacon_anim.h +++ b/quantum/rgb_matrix/animations/rainbow_beacon_anim.h @@ -7,7 +7,9 @@ static HSV RAINBOW_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8 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 // ENABLE_RGB_MATRIX_RAINBOW_BEACON +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_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 2f3de64e9d..f7b8f6c2f3 100644 --- a/quantum/rgb_matrix/animations/rainbow_moving_chevron_anim.h +++ b/quantum/rgb_matrix/animations/rainbow_moving_chevron_anim.h @@ -7,7 +7,9 @@ static HSV RAINBOW_MOVING_CHEVRON_math(HSV hsv, uint8_t i, uint8_t 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 // ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_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 dae2b5d190..91e31ea8cc 100644 --- a/quantum/rgb_matrix/animations/rainbow_pinwheels_anim.h +++ b/quantum/rgb_matrix/animations/rainbow_pinwheels_anim.h @@ -7,7 +7,9 @@ static HSV RAINBOW_PINWHEELS_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, ui return hsv; } -bool RAINBOW_PINWHEELS(effect_params_t* params) { return effect_runner_sin_cos_i(params, &RAINBOW_PINWHEELS_math); } +bool RAINBOW_PINWHEELS(effect_params_t* params) { + return effect_runner_sin_cos_i(params, &RAINBOW_PINWHEELS_math); +} -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS diff --git a/quantum/rgb_matrix/animations/raindrops_anim.h b/quantum/rgb_matrix/animations/raindrops_anim.h index 4b1b9dd9ec..2d4b53b7b0 100644 --- a/quantum/rgb_matrix/animations/raindrops_anim.h +++ b/quantum/rgb_matrix/animations/raindrops_anim.h @@ -35,5 +35,5 @@ bool RAINDROPS(effect_params_t* params) { return rgb_matrix_check_finished_leds(led_max); } -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_RAINDROPS +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_RGB_MATRIX_RAINDROPS diff --git a/quantum/rgb_matrix/animations/rgb_matrix_effects.inc b/quantum/rgb_matrix/animations/rgb_matrix_effects.inc index 27ce347235..ac7bac428d 100644 --- a/quantum/rgb_matrix/animations/rgb_matrix_effects.inc +++ b/quantum/rgb_matrix/animations/rgb_matrix_effects.inc @@ -27,6 +27,7 @@ #include "hue_pendulum_anim.h" #include "hue_wave_anim.h" #include "pixel_rain_anim.h" +#include "pixel_flow_anim.h" #include "pixel_fractal_anim.h" #include "typing_heatmap_anim.h" #include "digital_rain_anim.h" diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h b/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h index d5c1a26cef..f9584d7071 100644 --- a/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h +++ b/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h @@ -26,4 +26,4 @@ bool effect_runner_reactive(effect_params_t* params, reactive_f effect_func) { return rgb_matrix_check_finished_leds(led_max); } -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h b/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h index d3a6e4e72f..41020eb47f 100644 --- a/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h +++ b/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h @@ -26,4 +26,4 @@ bool effect_runner_reactive_splash(uint8_t start, effect_params_t* params, react return rgb_matrix_check_finished_leds(led_max); } -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED diff --git a/quantum/rgb_matrix/animations/solid_color_anim.h b/quantum/rgb_matrix/animations/solid_color_anim.h index 4209959468..c8762dcbc2 100644 --- a/quantum/rgb_matrix/animations/solid_color_anim.h +++ b/quantum/rgb_matrix/animations/solid_color_anim.h @@ -12,4 +12,4 @@ bool SOLID_COLOR(effect_params_t* params) { return rgb_matrix_check_finished_leds(led_max); } -#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 360d05a67a..d3a7ebbdf7 100644 --- a/quantum/rgb_matrix/animations/solid_reactive_anim.h +++ b/quantum/rgb_matrix/animations/solid_reactive_anim.h @@ -8,8 +8,10 @@ static HSV SOLID_REACTIVE_math(HSV hsv, uint16_t 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 // ENABLE_RGB_MATRIX_SOLID_REACTIVE -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# endif // ENABLE_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 496651f8a5..043a369b73 100644 --- a/quantum/rgb_matrix/animations/solid_reactive_cross.h +++ b/quantum/rgb_matrix/animations/solid_reactive_cross.h @@ -24,13 +24,17 @@ static HSV SOLID_REACTIVE_CROSS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t di } # ifdef ENABLE_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); } +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 # ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS -bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_CROSS_math); } +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(ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# endif // !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || defined(ENABLE_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 3562e74a72..8d62a49fea 100644 --- a/quantum/rgb_matrix/animations/solid_reactive_nexus.h +++ b/quantum/rgb_matrix/animations/solid_reactive_nexus.h @@ -22,13 +22,17 @@ static HSV SOLID_REACTIVE_NEXUS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t di } # ifdef ENABLE_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); } +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 # ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS -bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_NEXUS_math); } +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(ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# endif // !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(ENABLE_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 69189f636b..0d0a424cf3 100644 --- a/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h +++ b/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h @@ -8,8 +8,10 @@ static HSV SOLID_REACTIVE_SIMPLE_math(HSV hsv, uint16_t offset) { 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 // ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# endif // ENABLE_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 a613c7ff5f..7598796316 100644 --- a/quantum/rgb_matrix/animations/solid_reactive_wide.h +++ b/quantum/rgb_matrix/animations/solid_reactive_wide.h @@ -19,13 +19,17 @@ static HSV SOLID_REACTIVE_WIDE_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dis } # ifdef ENABLE_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); } +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 # ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE -bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_WIDE_math); } +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(ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# endif // !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(ENABLE_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 bd9c1cfe2b..77d6f8c5eb 100644 --- a/quantum/rgb_matrix/animations/solid_splash_anim.h +++ b/quantum/rgb_matrix/animations/solid_splash_anim.h @@ -19,13 +19,17 @@ HSV SOLID_SPLASH_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t ti } # ifdef ENABLE_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); } +bool SOLID_SPLASH(effect_params_t* params) { + return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_SPLASH_math); +} # endif # ifdef ENABLE_RGB_MATRIX_SOLID_MULTISPLASH -bool SOLID_MULTISPLASH(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SOLID_SPLASH_math); } +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(ENABLE_RGB_MATRIX_SPLASH) && !defined(ENABLE_RGB_MATRIX_MULTISPLASH) -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# endif // !defined(ENABLE_RGB_MATRIX_SPLASH) && !defined(ENABLE_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 382355e9ed..06459e1b0a 100644 --- a/quantum/rgb_matrix/animations/splash_anim.h +++ b/quantum/rgb_matrix/animations/splash_anim.h @@ -20,13 +20,17 @@ HSV SPLASH_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { } # ifdef ENABLE_RGB_MATRIX_SPLASH -bool SPLASH(effect_params_t* params) { return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SPLASH_math); } +bool SPLASH(effect_params_t* params) { + return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SPLASH_math); +} # endif # ifdef ENABLE_RGB_MATRIX_MULTISPLASH -bool MULTISPLASH(effect_params_t* params) { return effect_runner_reactive_splash(0, params, &SPLASH_math); } +bool MULTISPLASH(effect_params_t* params) { + return effect_runner_reactive_splash(0, params, &SPLASH_math); +} # endif -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -# endif // !defined(ENABLE_RGB_MATRIX_SPLASH) || !defined(ENABLE_RGB_MATRIX_MULTISPLASH) -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +# endif // !defined(ENABLE_RGB_MATRIX_SPLASH) || !defined(ENABLE_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 b66667b9b8..f3a94280c0 100644 --- a/quantum/rgb_matrix/animations/typing_heatmap_anim.h +++ b/quantum/rgb_matrix/animations/typing_heatmap_anim.h @@ -82,5 +82,5 @@ bool TYPING_HEATMAP(effect_params_t* params) { return led_max < sizeof(g_rgb_frame_buffer); } -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP) +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP) diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c index 51e9554e2d..f721dfc7f2 100644 --- a/quantum/rgb_matrix/rgb_matrix.c +++ b/quantum/rgb_matrix/rgb_matrix.c @@ -31,7 +31,9 @@ const led_point_t k_rgb_matrix_center = {112, 32}; const led_point_t k_rgb_matrix_center = RGB_MATRIX_CENTER; #endif -__attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) { return hsv_to_rgb(hsv); } +__attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) { + return hsv_to_rgb(hsv); +} // Generic effect runners #include "rgb_matrix_runners.inc" @@ -109,14 +111,14 @@ __attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) { return hsv_to_rgb(hsv #endif // globals -rgb_config_t rgb_matrix_config; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr +rgb_config_t rgb_matrix_config; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr uint32_t g_rgb_timer; #ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS uint8_t g_rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}}; -#endif // RGB_MATRIX_FRAMEBUFFER_EFFECTS +#endif // RGB_MATRIX_FRAMEBUFFER_EFFECTS #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED last_hit_t g_last_hit_tracker; -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED // internals static bool suspend_state = false; @@ -126,13 +128,13 @@ static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false}; static rgb_task_states rgb_task_state = SYNCING; #if RGB_DISABLE_TIMEOUT > 0 static uint32_t rgb_anykey_timer; -#endif // RGB_DISABLE_TIMEOUT > 0 +#endif // RGB_DISABLE_TIMEOUT > 0 // double buffers static uint32_t rgb_timer_buffer; #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED static last_hit_t last_hit_buffer; -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED // split rgb matrix #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) @@ -141,7 +143,9 @@ const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; EECONFIG_DEBOUNCE_HELPER(rgb_matrix, EECONFIG_RGB_MATRIX, rgb_matrix_config); -void eeconfig_update_rgb_matrix(void) { eeconfig_flush_rgb_matrix(true); } +void eeconfig_update_rgb_matrix(void) { + eeconfig_flush_rgb_matrix(true); +} void eeconfig_update_rgb_matrix_default(void) { dprintf("eeconfig_update_rgb_matrix_default\n"); @@ -164,7 +168,19 @@ void eeconfig_debug_rgb_matrix(void) { dprintf("rgb_matrix_config.flags = %d\n", rgb_matrix_config.flags); } -__attribute__((weak)) uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { return 0; } +void rgb_matrix_reload_from_eeprom(void) { + rgb_matrix_disable_noeeprom(); + /* Reset back to what we have in eeprom */ + eeconfig_init_rgb_matrix(); + eeconfig_debug_rgb_matrix(); // display current eeprom values + if (rgb_matrix_config.enable) { + rgb_matrix_mode_noeeprom(rgb_matrix_config.mode); + } +} + +__attribute__((weak)) uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { + return 0; +} uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) { uint8_t led_count = rgb_matrix_map_row_column_to_led_kb(row, column, led_i); @@ -176,13 +192,18 @@ uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *l return led_count; } -void rgb_matrix_update_pwm_buffers(void) { rgb_matrix_driver.flush(); } +void rgb_matrix_update_pwm_buffers(void) { + rgb_matrix_driver.flush(); +} -void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { rgb_matrix_driver.set_color(index, red, green, blue); } +void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { + rgb_matrix_driver.set_color(index, red, green, blue); +} void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) - for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) rgb_matrix_set_color(i, red, green, blue); + for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) + rgb_matrix_set_color(i, red, green, blue); #else rgb_matrix_driver.set_color_all(red, green, blue); #endif @@ -194,7 +215,7 @@ void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) { #endif #if RGB_DISABLE_TIMEOUT > 0 rgb_anykey_timer = 0; -#endif // RGB_DISABLE_TIMEOUT > 0 +#endif // RGB_DISABLE_TIMEOUT > 0 #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED uint8_t led[LED_HITS_TO_REMEMBER]; @@ -204,7 +225,7 @@ void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) { if (!pressed) # elif defined(RGB_MATRIX_KEYPRESSES) if (pressed) -# endif // defined(RGB_MATRIX_KEYRELEASES) +# endif // defined(RGB_MATRIX_KEYRELEASES) { led_count = rgb_matrix_map_row_column_to_led(row, col, led); } @@ -212,7 +233,7 @@ void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) { if (last_hit_buffer.count + led_count > LED_HITS_TO_REMEMBER) { memcpy(&last_hit_buffer.x[0], &last_hit_buffer.x[led_count], LED_HITS_TO_REMEMBER - led_count); memcpy(&last_hit_buffer.y[0], &last_hit_buffer.y[led_count], LED_HITS_TO_REMEMBER - led_count); - memcpy(&last_hit_buffer.tick[0], &last_hit_buffer.tick[led_count], (LED_HITS_TO_REMEMBER - led_count) * 2); // 16 bit + memcpy(&last_hit_buffer.tick[0], &last_hit_buffer.tick[led_count], (LED_HITS_TO_REMEMBER - led_count) * 2); // 16 bit memcpy(&last_hit_buffer.index[0], &last_hit_buffer.index[led_count], LED_HITS_TO_REMEMBER - led_count); last_hit_buffer.count = LED_HITS_TO_REMEMBER - led_count; } @@ -225,13 +246,13 @@ void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) { last_hit_buffer.tick[index] = 0; last_hit_buffer.count++; } -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED #if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP) if (rgb_matrix_config.mode == RGB_MATRIX_TYPING_HEATMAP) { process_rgb_matrix_typing_heatmap(row, col); } -#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP) +#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP) } void rgb_matrix_test(void) { @@ -270,7 +291,7 @@ static bool rgb_matrix_none(effect_params_t *params) { static void rgb_task_timers(void) { #if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0 uint32_t deltaTime = sync_timer_elapsed32(rgb_timer_buffer); -#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0 +#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0 rgb_timer_buffer = sync_timer_read32(); // Update double buffer timers @@ -278,7 +299,7 @@ static void rgb_task_timers(void) { if (rgb_anykey_timer + deltaTime <= UINT32_MAX) { rgb_anykey_timer += deltaTime; } -#endif // RGB_DISABLE_TIMEOUT > 0 +#endif // RGB_DISABLE_TIMEOUT > 0 // Update double buffer last hit timers #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED @@ -290,7 +311,7 @@ static void rgb_task_timers(void) { } last_hit_buffer.tick[i] += deltaTime; } -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED } static void rgb_task_sync(void) { @@ -307,7 +328,7 @@ static void rgb_task_start(void) { g_rgb_timer = rgb_timer_buffer; #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED g_last_hit_tracker = last_hit_buffer; -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED // next task rgb_task_state = RENDERING; @@ -393,7 +414,7 @@ void rgb_matrix_task(void) { bool suspend_backlight = suspend_state || #if RGB_DISABLE_TIMEOUT > 0 (rgb_anykey_timer > (uint32_t)RGB_DISABLE_TIMEOUT) || -#endif // RGB_DISABLE_TIMEOUT > 0 +#endif // RGB_DISABLE_TIMEOUT > 0 false; uint8_t effect = suspend_backlight || !rgb_matrix_config.enable ? 0 : rgb_matrix_config.mode; @@ -462,7 +483,7 @@ void rgb_matrix_init(void) { for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) { last_hit_buffer.tick[i] = UINT16_MAX; } -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED if (!eeconfig_is_enabled()) { dprintf("rgb_matrix_init_drivers eeconfig is not enabled.\n"); @@ -475,20 +496,22 @@ void rgb_matrix_init(void) { dprintf("rgb_matrix_init_drivers rgb_matrix_config.mode = 0. Write default values to EEPROM.\n"); eeconfig_update_rgb_matrix_default(); } - eeconfig_debug_rgb_matrix(); // display current eeprom values + eeconfig_debug_rgb_matrix(); // display current eeprom values } void rgb_matrix_set_suspend_state(bool state) { #ifdef RGB_DISABLE_WHEN_USB_SUSPENDED - if (state && !suspend_state) { // only run if turning off, and only once - rgb_task_render(0); // turn off all LEDs when suspending - rgb_task_flush(0); // and actually flash led state to LEDs + if (state && !suspend_state) { // only run if turning off, and only once + rgb_task_render(0); // turn off all LEDs when suspending + rgb_task_flush(0); // and actually flash led state to LEDs } suspend_state = state; #endif } -bool rgb_matrix_get_suspend_state(void) { return suspend_state; } +bool rgb_matrix_get_suspend_state(void) { + return suspend_state; +} void rgb_matrix_toggle_eeprom_helper(bool write_to_eeprom) { rgb_matrix_config.enable ^= 1; @@ -496,8 +519,12 @@ void rgb_matrix_toggle_eeprom_helper(bool write_to_eeprom) { eeconfig_flag_rgb_matrix(write_to_eeprom); dprintf("rgb matrix toggle [%s]: rgb_matrix_config.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.enable); } -void rgb_matrix_toggle_noeeprom(void) { rgb_matrix_toggle_eeprom_helper(false); } -void rgb_matrix_toggle(void) { rgb_matrix_toggle_eeprom_helper(true); } +void rgb_matrix_toggle_noeeprom(void) { + rgb_matrix_toggle_eeprom_helper(false); +} +void rgb_matrix_toggle(void) { + rgb_matrix_toggle_eeprom_helper(true); +} void rgb_matrix_enable(void) { rgb_matrix_enable_noeeprom(); @@ -519,7 +546,9 @@ void rgb_matrix_disable_noeeprom(void) { rgb_matrix_config.enable = 0; } -uint8_t rgb_matrix_is_enabled(void) { return rgb_matrix_config.enable; } +uint8_t rgb_matrix_is_enabled(void) { + return rgb_matrix_config.enable; +} void rgb_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { if (!rgb_matrix_config.enable) { @@ -536,24 +565,38 @@ void rgb_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { eeconfig_flag_rgb_matrix(write_to_eeprom); dprintf("rgb matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.mode); } -void rgb_matrix_mode_noeeprom(uint8_t mode) { rgb_matrix_mode_eeprom_helper(mode, false); } -void rgb_matrix_mode(uint8_t mode) { rgb_matrix_mode_eeprom_helper(mode, true); } +void rgb_matrix_mode_noeeprom(uint8_t mode) { + rgb_matrix_mode_eeprom_helper(mode, false); +} +void rgb_matrix_mode(uint8_t mode) { + rgb_matrix_mode_eeprom_helper(mode, true); +} -uint8_t rgb_matrix_get_mode(void) { return rgb_matrix_config.mode; } +uint8_t rgb_matrix_get_mode(void) { + return rgb_matrix_config.mode; +} void rgb_matrix_step_helper(bool write_to_eeprom) { uint8_t mode = rgb_matrix_config.mode + 1; rgb_matrix_mode_eeprom_helper((mode < RGB_MATRIX_EFFECT_MAX) ? mode : 1, write_to_eeprom); } -void rgb_matrix_step_noeeprom(void) { rgb_matrix_step_helper(false); } -void rgb_matrix_step(void) { rgb_matrix_step_helper(true); } +void rgb_matrix_step_noeeprom(void) { + rgb_matrix_step_helper(false); +} +void rgb_matrix_step(void) { + rgb_matrix_step_helper(true); +} void rgb_matrix_step_reverse_helper(bool write_to_eeprom) { uint8_t mode = rgb_matrix_config.mode - 1; rgb_matrix_mode_eeprom_helper((mode < 1) ? RGB_MATRIX_EFFECT_MAX - 1 : mode, write_to_eeprom); } -void rgb_matrix_step_reverse_noeeprom(void) { rgb_matrix_step_reverse_helper(false); } -void rgb_matrix_step_reverse(void) { rgb_matrix_step_reverse_helper(true); } +void rgb_matrix_step_reverse_noeeprom(void) { + rgb_matrix_step_reverse_helper(false); +} +void rgb_matrix_step_reverse(void) { + rgb_matrix_step_reverse_helper(true); +} void rgb_matrix_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) { if (!rgb_matrix_config.enable) { @@ -565,56 +608,126 @@ void rgb_matrix_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, boo eeconfig_flag_rgb_matrix(write_to_eeprom); dprintf("rgb matrix set hsv [%s]: %u,%u,%u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v); } -void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { rgb_matrix_sethsv_eeprom_helper(hue, sat, val, false); } -void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { rgb_matrix_sethsv_eeprom_helper(hue, sat, val, true); } +void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { + rgb_matrix_sethsv_eeprom_helper(hue, sat, val, false); +} +void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { + rgb_matrix_sethsv_eeprom_helper(hue, sat, val, true); +} -HSV rgb_matrix_get_hsv(void) { return rgb_matrix_config.hsv; } -uint8_t rgb_matrix_get_hue(void) { return rgb_matrix_config.hsv.h; } -uint8_t rgb_matrix_get_sat(void) { return rgb_matrix_config.hsv.s; } -uint8_t rgb_matrix_get_val(void) { return rgb_matrix_config.hsv.v; } +HSV rgb_matrix_get_hsv(void) { + return rgb_matrix_config.hsv; +} +uint8_t rgb_matrix_get_hue(void) { + return rgb_matrix_config.hsv.h; +} +uint8_t rgb_matrix_get_sat(void) { + return rgb_matrix_config.hsv.s; +} +uint8_t rgb_matrix_get_val(void) { + return rgb_matrix_config.hsv.v; +} -void rgb_matrix_increase_hue_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h + RGB_MATRIX_HUE_STEP, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, write_to_eeprom); } -void rgb_matrix_increase_hue_noeeprom(void) { rgb_matrix_increase_hue_helper(false); } -void rgb_matrix_increase_hue(void) { rgb_matrix_increase_hue_helper(true); } +void rgb_matrix_increase_hue_helper(bool write_to_eeprom) { + rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h + RGB_MATRIX_HUE_STEP, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, write_to_eeprom); +} +void rgb_matrix_increase_hue_noeeprom(void) { + rgb_matrix_increase_hue_helper(false); +} +void rgb_matrix_increase_hue(void) { + rgb_matrix_increase_hue_helper(true); +} -void rgb_matrix_decrease_hue_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h - RGB_MATRIX_HUE_STEP, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, write_to_eeprom); } -void rgb_matrix_decrease_hue_noeeprom(void) { rgb_matrix_decrease_hue_helper(false); } -void rgb_matrix_decrease_hue(void) { rgb_matrix_decrease_hue_helper(true); } +void rgb_matrix_decrease_hue_helper(bool write_to_eeprom) { + rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h - RGB_MATRIX_HUE_STEP, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, write_to_eeprom); +} +void rgb_matrix_decrease_hue_noeeprom(void) { + rgb_matrix_decrease_hue_helper(false); +} +void rgb_matrix_decrease_hue(void) { + rgb_matrix_decrease_hue_helper(true); +} -void rgb_matrix_increase_sat_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, qadd8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP), rgb_matrix_config.hsv.v, write_to_eeprom); } -void rgb_matrix_increase_sat_noeeprom(void) { rgb_matrix_increase_sat_helper(false); } -void rgb_matrix_increase_sat(void) { rgb_matrix_increase_sat_helper(true); } +void rgb_matrix_increase_sat_helper(bool write_to_eeprom) { + rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, qadd8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP), rgb_matrix_config.hsv.v, write_to_eeprom); +} +void rgb_matrix_increase_sat_noeeprom(void) { + rgb_matrix_increase_sat_helper(false); +} +void rgb_matrix_increase_sat(void) { + rgb_matrix_increase_sat_helper(true); +} -void rgb_matrix_decrease_sat_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, qsub8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP), rgb_matrix_config.hsv.v, write_to_eeprom); } -void rgb_matrix_decrease_sat_noeeprom(void) { rgb_matrix_decrease_sat_helper(false); } -void rgb_matrix_decrease_sat(void) { rgb_matrix_decrease_sat_helper(true); } +void rgb_matrix_decrease_sat_helper(bool write_to_eeprom) { + rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, qsub8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP), rgb_matrix_config.hsv.v, write_to_eeprom); +} +void rgb_matrix_decrease_sat_noeeprom(void) { + rgb_matrix_decrease_sat_helper(false); +} +void rgb_matrix_decrease_sat(void) { + rgb_matrix_decrease_sat_helper(true); +} -void rgb_matrix_increase_val_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, qadd8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP), write_to_eeprom); } -void rgb_matrix_increase_val_noeeprom(void) { rgb_matrix_increase_val_helper(false); } -void rgb_matrix_increase_val(void) { rgb_matrix_increase_val_helper(true); } +void rgb_matrix_increase_val_helper(bool write_to_eeprom) { + rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, qadd8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP), write_to_eeprom); +} +void rgb_matrix_increase_val_noeeprom(void) { + rgb_matrix_increase_val_helper(false); +} +void rgb_matrix_increase_val(void) { + rgb_matrix_increase_val_helper(true); +} -void rgb_matrix_decrease_val_helper(bool write_to_eeprom) { rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, qsub8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP), write_to_eeprom); } -void rgb_matrix_decrease_val_noeeprom(void) { rgb_matrix_decrease_val_helper(false); } -void rgb_matrix_decrease_val(void) { rgb_matrix_decrease_val_helper(true); } +void rgb_matrix_decrease_val_helper(bool write_to_eeprom) { + rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, qsub8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP), write_to_eeprom); +} +void rgb_matrix_decrease_val_noeeprom(void) { + rgb_matrix_decrease_val_helper(false); +} +void rgb_matrix_decrease_val(void) { + rgb_matrix_decrease_val_helper(true); +} void rgb_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { rgb_matrix_config.speed = speed; eeconfig_flag_rgb_matrix(write_to_eeprom); dprintf("rgb matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.speed); } -void rgb_matrix_set_speed_noeeprom(uint8_t speed) { rgb_matrix_set_speed_eeprom_helper(speed, false); } -void rgb_matrix_set_speed(uint8_t speed) { rgb_matrix_set_speed_eeprom_helper(speed, true); } +void rgb_matrix_set_speed_noeeprom(uint8_t speed) { + rgb_matrix_set_speed_eeprom_helper(speed, false); +} +void rgb_matrix_set_speed(uint8_t speed) { + rgb_matrix_set_speed_eeprom_helper(speed, true); +} -uint8_t rgb_matrix_get_speed(void) { return rgb_matrix_config.speed; } +uint8_t rgb_matrix_get_speed(void) { + return rgb_matrix_config.speed; +} -void rgb_matrix_increase_speed_helper(bool write_to_eeprom) { rgb_matrix_set_speed_eeprom_helper(qadd8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP), write_to_eeprom); } -void rgb_matrix_increase_speed_noeeprom(void) { rgb_matrix_increase_speed_helper(false); } -void rgb_matrix_increase_speed(void) { rgb_matrix_increase_speed_helper(true); } +void rgb_matrix_increase_speed_helper(bool write_to_eeprom) { + rgb_matrix_set_speed_eeprom_helper(qadd8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP), write_to_eeprom); +} +void rgb_matrix_increase_speed_noeeprom(void) { + rgb_matrix_increase_speed_helper(false); +} +void rgb_matrix_increase_speed(void) { + rgb_matrix_increase_speed_helper(true); +} -void rgb_matrix_decrease_speed_helper(bool write_to_eeprom) { rgb_matrix_set_speed_eeprom_helper(qsub8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP), write_to_eeprom); } -void rgb_matrix_decrease_speed_noeeprom(void) { rgb_matrix_decrease_speed_helper(false); } -void rgb_matrix_decrease_speed(void) { rgb_matrix_decrease_speed_helper(true); } +void rgb_matrix_decrease_speed_helper(bool write_to_eeprom) { + rgb_matrix_set_speed_eeprom_helper(qsub8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP), write_to_eeprom); +} +void rgb_matrix_decrease_speed_noeeprom(void) { + rgb_matrix_decrease_speed_helper(false); +} +void rgb_matrix_decrease_speed(void) { + rgb_matrix_decrease_speed_helper(true); +} -led_flags_t rgb_matrix_get_flags(void) { return rgb_matrix_config.flags; } +led_flags_t rgb_matrix_get_flags(void) { + return rgb_matrix_config.flags; +} -void rgb_matrix_set_flags(led_flags_t flags) { rgb_matrix_config.flags = flags; } +void rgb_matrix_set_flags(led_flags_t flags) { + rgb_matrix_config.flags = flags; +} diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h index a804d99abc..359d507a4d 100644 --- a/quantum/rgb_matrix/rgb_matrix.h +++ b/quantum/rgb_matrix/rgb_matrix.h @@ -32,6 +32,8 @@ # include "is31fl3737.h" #elif defined(IS31FL3741) # include "is31fl3741.h" +#elif defined(IS31FLCOMMON) +# include "is31flcommon.h" #elif defined(CKLED2001) # include "ckled2001.h" #elif defined(AW20216) @@ -136,6 +138,8 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max); void rgb_matrix_init(void); +void rgb_matrix_reload_from_eeprom(void); + void rgb_matrix_set_suspend_state(bool state); bool rgb_matrix_get_suspend_state(void); void rgb_matrix_toggle(void); @@ -182,6 +186,7 @@ void rgb_matrix_set_flags(led_flags_t flags); #ifndef RGBLIGHT_ENABLE # define eeconfig_update_rgblight_current eeconfig_update_rgb_matrix +# define rgblight_reload_from_eeprom rgb_matrix_reload_from_eeprom # define rgblight_toggle rgb_matrix_toggle # define rgblight_toggle_noeeprom rgb_matrix_toggle_noeeprom # define rgblight_enable rgb_matrix_enable diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c index 130ca47a63..27fa7369bf 100644 --- a/quantum/rgb_matrix/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix/rgb_matrix_drivers.c @@ -23,7 +23,7 @@ * be here if shared between boards. */ -#if defined(IS31FL3731) || defined(IS31FL3733) || defined(IS31FL3737) || defined(IS31FL3741) || defined(CKLED2001) +#if defined(IS31FL3731) || defined(IS31FL3733) || defined(IS31FL3737) || defined(IS31FL3741) || defined(IS31FLCOMMON) || defined(CKLED2001) # include "i2c_master.h" // TODO: Remove this at some later date @@ -81,6 +81,18 @@ static void init(void) { # elif defined(IS31FL3741) IS31FL3741_init(DRIVER_ADDR_1); +# elif defined(IS31FLCOMMON) + IS31FL_common_init(DRIVER_ADDR_1, ISSI_SSR_1); +# if defined(DRIVER_ADDR_2) + IS31FL_common_init(DRIVER_ADDR_2, ISSI_SSR_2); +# if defined(DRIVER_ADDR_3) + IS31FL_common_init(DRIVER_ADDR_3, ISSI_SSR_3); +# if defined(DRIVER_ADDR_4) + IS31FL_common_init(DRIVER_ADDR_4, ISSI_SSR_4); +# endif +# endif +# endif + # elif defined(CKLED2001) CKLED2001_init(DRIVER_ADDR_1); # if defined(DRIVER_ADDR_2) @@ -106,6 +118,8 @@ static void init(void) { IS31FL3737_set_led_control_register(index, enabled, enabled, enabled); # elif defined(IS31FL3741) IS31FL3741_set_led_control_register(index, enabled, enabled, enabled); +# elif defined(IS31FLCOMMON) + IS31FL_RGB_set_scaling_buffer(index, enabled, enabled, enabled); # elif defined(CKLED2001) CKLED2001_set_led_control_register(index, enabled, enabled, enabled); # endif @@ -145,6 +159,21 @@ static void init(void) { # elif defined(IS31FL3741) IS31FL3741_update_led_control_registers(DRIVER_ADDR_1, 0); +# elif defined(IS31FLCOMMON) +# ifdef ISSI_MANUAL_SCALING + IS31FL_set_manual_scaling_buffer(); +# endif + IS31FL_common_update_scaling_register(DRIVER_ADDR_1, 0); +# if defined(DRIVER_ADDR_2) + IS31FL_common_update_scaling_register(DRIVER_ADDR_2, 1); +# if defined(DRIVER_ADDR_3) + IS31FL_common_update_scaling_register(DRIVER_ADDR_3, 2); +# if defined(DRIVER_ADDR_4) + IS31FL_common_update_scaling_register(DRIVER_ADDR_4, 3); +# endif +# endif +# endif + # elif defined(CKLED2001) CKLED2001_update_led_control_registers(DRIVER_ADDR_1, 0); # if defined(DRIVER_ADDR_2) @@ -231,6 +260,27 @@ const rgb_matrix_driver_t rgb_matrix_driver = { .set_color_all = IS31FL3741_set_color_all, }; +# elif defined(IS31FLCOMMON) +static void flush(void) { + IS31FL_common_update_pwm_register(DRIVER_ADDR_1, 0); +# if defined(DRIVER_ADDR_2) + IS31FL_common_update_pwm_register(DRIVER_ADDR_2, 1); +# if defined(DRIVER_ADDR_3) + IS31FL_common_update_pwm_register(DRIVER_ADDR_3, 2); +# if defined(DRIVER_ADDR_4) + IS31FL_common_update_pwm_register(DRIVER_ADDR_4, 3); +# endif +# endif +# endif +} + +const rgb_matrix_driver_t rgb_matrix_driver = { + .init = init, + .flush = flush, + .set_color = IS31FL_RGB_set_color, + .set_color_all = IS31FL_RGB_set_color_all, +}; + # elif defined(CKLED2001) static void flush(void) { CKLED2001_update_pwm_buffers(DRIVER_ADDR_1, 0); @@ -299,10 +349,15 @@ static void flush(void) { static inline void setled(int i, uint8_t r, uint8_t g, uint8_t b) { # if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; - if (!is_keyboard_left() && (i >= k_rgb_matrix_split[0])) { - i -= k_rgb_matrix_split[0]; - } else if (is_keyboard_left() && (i >= k_rgb_matrix_split[0])) + if (!is_keyboard_left()) { + if (i >= k_rgb_matrix_split[0]) { + i -= k_rgb_matrix_split[0]; + } else { + return; + } + } else if (i >= k_rgb_matrix_split[0]) { return; + } # endif rgb_matrix_ws2812_array[i].r = r; diff --git a/quantum/rgb_matrix/rgb_matrix_types.h b/quantum/rgb_matrix/rgb_matrix_types.h index df575d6577..d0ac4e4466 100644 --- a/quantum/rgb_matrix/rgb_matrix_types.h +++ b/quantum/rgb_matrix/rgb_matrix_types.h @@ -37,7 +37,7 @@ // Last led hit #ifndef LED_HITS_TO_REMEMBER # define LED_HITS_TO_REMEMBER 8 -#endif // LED_HITS_TO_REMEMBER +#endif // LED_HITS_TO_REMEMBER #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED typedef struct PACKED { @@ -47,7 +47,7 @@ typedef struct PACKED { uint8_t index[LED_HITS_TO_REMEMBER]; uint16_t tick[LED_HITS_TO_REMEMBER]; } last_hit_t; -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED typedef enum rgb_task_states { STARTING, RENDERING, FLUSHING, SYNCING } rgb_task_states; @@ -88,7 +88,7 @@ typedef union { uint8_t enable : 2; uint8_t mode : 6; HSV hsv; - uint8_t speed; // EECONFIG needs to be increased to support this + uint8_t speed; // EECONFIG needs to be increased to support this led_flags_t flags; }; } rgb_config_t; |