Skip to content
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

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/features/rgb_matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ enum rgb_matrix_effects {
RGB_MATRIX_STARLIGHT, // LEDs turn on and off at random at varying brightness, maintaining user set color
RGB_MATRIX_STARLIGHT_DUAL_HUE, // LEDs turn on and off at random at varying brightness, modifies user set hue by +- 30
RGB_MATRIX_STARLIGHT_DUAL_SAT, // LEDs turn on and off at random at varying brightness, modifies user set saturation by +- 30
RGB_MATRIX_STARLIGHT_SMOOTH, // LEDs randomly and smoothly increase and decrease in brightness to create a starlight effect, speed adjustable
RGB_MATRIX_RIVERFLOW, // Modification to breathing animation, offset's animation depending on key location to simulate a river flowing
RGB_MATRIX_EFFECT_MAX
};
Expand Down Expand Up @@ -720,6 +721,7 @@ You can enable a single effect by defining `ENABLE_[EFFECT_NAME]` in your `confi
|`#define ENABLE_RGB_MATRIX_STARLIGHT` |Enables `RGB_MATRIX_STARLIGHT` |
|`#define ENABLE_RGB_MATRIX_STARLIGHT_DUAL_HUE` |Enables `RGB_MATRIX_STARLIGHT_DUAL_HUE` |
|`#define ENABLE_RGB_MATRIX_STARLIGHT_DUAL_SAT` |Enables `RGB_MATRIX_STARLIGHT_DUAL_SAT` |
|`#define ENABLE_RGB_MATRIX_STARLIGHT_SMOOTH` |Enables `RGB_MATRIX_STARLIGHT_SMOOTH` |
zvecr marked this conversation as resolved.
Show resolved Hide resolved
|`#define ENABLE_RGB_MATRIX_RIVERFLOW` |Enables `RGB_MATRIX_RIVERFLOW` |

|Framebuffer Defines |Description |
Expand Down
1 change: 1 addition & 0 deletions quantum/rgb_matrix/animations/rgb_matrix_effects.inc
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@
#include "starlight_anim.h"
#include "starlight_dual_sat_anim.h"
#include "starlight_dual_hue_anim.h"
#include "starlight_smooth_anim.h"
#include "riverflow_anim.h"
31 changes: 31 additions & 0 deletions quantum/rgb_matrix/animations/starlight_smooth_anim.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifdef ENABLE_RGB_MATRIX_STARLIGHT_SMOOTH
RGB_MATRIX_EFFECT(STARLIGHT_SMOOTH)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS

bool STARLIGHT_SMOOTH(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
Comment on lines +5 to +6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool STARLIGHT_SMOOTH(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
static uint16_t time_offsets[RGB_MATRIX_LED_COUNT];


static uint16_t time_offsets[RGB_MATRIX_LED_COUNT] = {0};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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) {


if (params->init) {
for (uint8_t i = 0; i < RGB_MATRIX_LED_COUNT; i++) {
time_offsets[i] = random16_max(65000);
}
}

for (uint8_t i = led_min; i < led_max; i++) {
HSV hsv = rgb_matrix_config.hsv;

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);

RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
RGB_MATRIX_TEST_LED_FLAGS();
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
drashna marked this conversation as resolved.
Show resolved Hide resolved

return rgb_matrix_check_finished_leds(led_max);
}

# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
#endif // ENABLE_RGB_MATRIX_STARLIGHT_SMOOTH