-
-
Notifications
You must be signed in to change notification settings - Fork 40k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: New RGB Animation "Starlight Smooth" #24137
base: develop
Are you sure you want to change the base?
Conversation
@filterpaper thank you for these change suggestions, and for fixing my embarrassing typo in the effect name...I have made those changes and tested the animation, still works as expected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hbbit-dev Thanks for the new effect, looks nice. The code changes LGTM. There is one remaining suggestion from filterpaper that would be worth including?
Co-authored-by: フィルターペーパー <[email protected]>
The RGB and HSV structs can be updated to #ifdef ENABLE_RGB_MATRIX_STARLIGHT_SMOOTH
RGB_MATRIX_EFFECT(STARLIGHT_SMOOTH)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static uint16_t time_offsets[RGB_MATRIX_LED_COUNT];
hsv_t STARLIGHT_SMOOTH_maths(hsv_t hsv, uint8_t i, uint8_t time) {
uint16_t time = scale16by8((g_rgb_timer / 2) + time_offsets[i], rgb_matrix_config.speed / 16);
hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
return hsv;
}
bool STARLIGHT_SMOOTH(effect_params_t* params) {
if (params->init) {
for (uint8_t i = 0; i < RGB_MATRIX_LED_COUNT; i++) {
time_offsets[i] = random16_max(65000);
}
}
return effect_runner_i(params, &STARLIGHT_SMOOTH_maths);
}
# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // ENABLE_RGB_MATRIX_STARLIGHT_SMOOTH Replacing |
This code block doesn't work, as time is a parameter, so you can't redefine it. (but setting |
Corrected: #ifdef ENABLE_RGB_MATRIX_STARLIGHT_SMOOTH
RGB_MATRIX_EFFECT(STARLIGHT_SMOOTH)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static uint16_t time_offsets[RGB_MATRIX_LED_COUNT];
hsv_t STARLIGHT_SMOOTH_math(hsv_t hsv, uint8_t i, uint8_t time) {
time = scale16by8((g_rgb_timer / 2) + time_offsets[i], rgb_matrix_config.speed / 16);
hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
return hsv;
}
bool STARLIGHT_SMOOTH(effect_params_t* params) {
if (params->init) {
for (uint8_t i = 0; i < RGB_MATRIX_LED_COUNT; i++) {
time_offsets[i] = random16_max(65000);
}
}
return effect_runner_i(params, &STARLIGHT_SMOOTH_math);
}
# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // ENABLE_RGB_MATRIX_STARLIGHT_SMOOTH The existing PR could be merged and it can be refactored with the above later. |
Thank you for your contribution! |
bool STARLIGHT_SMOOTH(effect_params_t* params) { | ||
RGB_MATRIX_USE_LIMITS(led_min, led_max); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool STARLIGHT_SMOOTH(effect_params_t* params) { | |
RGB_MATRIX_USE_LIMITS(led_min, led_max); | |
static uint16_t time_offsets[RGB_MATRIX_LED_COUNT]; |
bool STARLIGHT_SMOOTH(effect_params_t* params) { | ||
RGB_MATRIX_USE_LIMITS(led_min, led_max); | ||
|
||
static uint16_t time_offsets[RGB_MATRIX_LED_COUNT] = {0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static uint16_t time_offsets[RGB_MATRIX_LED_COUNT] = {0}; | |
hsv_t STARLIGHT_SMOOTH_math(hsv_t hsv, uint8_t i, uint8_t time) { | |
time = scale16by8((g_rgb_timer / 2) + time_offsets[i], rgb_matrix_config.speed / 16); | |
hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); | |
return hsv; | |
} | |
bool STARTLIGHT_SMOOTH(effect_params_t *params) { |
for (uint8_t i = led_min; i < led_max; i++) { | ||
RGB_MATRIX_TEST_LED_FLAGS(); | ||
|
||
uint16_t time = scale16by8((g_rgb_timer / 2) + time_offsets[i], rgb_matrix_config.speed / 16); | ||
HSV hsv = rgb_matrix_config.hsv; | ||
hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); | ||
RGB rgb = rgb_matrix_hsv_to_rgb(hsv); | ||
|
||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | ||
} | ||
|
||
return rgb_matrix_check_finished_leds(led_max); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (uint8_t i = led_min; i < led_max; i++) { | |
RGB_MATRIX_TEST_LED_FLAGS(); | |
uint16_t time = scale16by8((g_rgb_timer / 2) + time_offsets[i], rgb_matrix_config.speed / 16); | |
HSV hsv = rgb_matrix_config.hsv; | |
hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); | |
RGB rgb = rgb_matrix_hsv_to_rgb(hsv); | |
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | |
} | |
return rgb_matrix_check_finished_leds(led_max); | |
return effect_runner_i (params, &STARLIGHT_SMOOTH_math); |
Description
New RGB Matrix animation compatible with all keyboards. Will link a video below. I made a previous pull request to add starlight, starlight dual hue, starlight dual sat, and at the last minute I changed the name of starlight smooth to "riverflow" because it didn't have the randomness I was looking for, it was essentially just an angled wave.
I've sat down and tried again this past week and was able to get it to what I originally had in mind for starlight smooth. LEDs randomly raise and lower in brightness, speed and color can be controlled by the user. Updates to the docs as well.
Types of Changes
Issues Fixed or Closed by This PR
Checklist
Supporting Media
output.mp4