mirror of
https://github.com/firewalkwithm3/qmk_firmware.git
synced 2024-11-22 11:30:30 +08:00
Moves animation calculation logic out of the for loops
This commit is contained in:
parent
96648a133d
commit
c7ce0d21dc
|
@ -438,10 +438,12 @@ void rgb_matrix_cycle_up_down(void) {
|
|||
void rgb_matrix_dual_beacon(void) {
|
||||
HSV hsv = { .h = rgb_matrix_config.hue, .s = rgb_matrix_config.sat, .v = rgb_matrix_config.val };
|
||||
RGB rgb;
|
||||
rgb_led led;
|
||||
Point point;
|
||||
double cos_value = cos(g_tick * PI / 128) / 32;
|
||||
double sin_value = sin(g_tick * PI / 128) / 112;
|
||||
for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
|
||||
led = g_rgb_leds[i];
|
||||
hsv.h = ((led.point.y - 32.0)* cos(g_tick * PI / 128) / 32 + (led.point.x - 112.0) * sin(g_tick * PI / 128) / (112)) * (180) + rgb_matrix_config.hue;
|
||||
point = g_rgb_leds[i].point;
|
||||
hsv.h = ((point.y - 32.0)* cos_value + (point.x - 112.0) * sin_value) * (180) + rgb_matrix_config.hue;
|
||||
rgb = hsv_to_rgb( hsv );
|
||||
rgb_matrix_set_color( i, rgb.r, rgb.g, rgb.b );
|
||||
}
|
||||
|
@ -450,10 +452,12 @@ void rgb_matrix_dual_beacon(void) {
|
|||
void rgb_matrix_rainbow_beacon(void) {
|
||||
HSV hsv = { .h = rgb_matrix_config.hue, .s = rgb_matrix_config.sat, .v = rgb_matrix_config.val };
|
||||
RGB rgb;
|
||||
rgb_led led;
|
||||
Point point;
|
||||
double cos_value = cos(g_tick * PI / 128);
|
||||
double sin_value = sin(g_tick * PI / 128);
|
||||
for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
|
||||
led = g_rgb_leds[i];
|
||||
hsv.h = (1.5 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * (led.point.y - 32.0)* cos(g_tick * PI / 128) + (1.5 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * (led.point.x - 112.0) * sin(g_tick * PI / 128) + rgb_matrix_config.hue;
|
||||
point = g_rgb_leds[i].point;
|
||||
hsv.h = (1.5 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * (point.y - 32.0)* cos_value + (1.5 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * (point.x - 112.0) * sin_value + rgb_matrix_config.hue;
|
||||
rgb = hsv_to_rgb( hsv );
|
||||
rgb_matrix_set_color( i, rgb.r, rgb.g, rgb.b );
|
||||
}
|
||||
|
@ -462,10 +466,12 @@ void rgb_matrix_rainbow_beacon(void) {
|
|||
void rgb_matrix_rainbow_pinwheels(void) {
|
||||
HSV hsv = { .h = rgb_matrix_config.hue, .s = rgb_matrix_config.sat, .v = rgb_matrix_config.val };
|
||||
RGB rgb;
|
||||
rgb_led led;
|
||||
Point point;
|
||||
double cos_value = cos(g_tick * PI / 128);
|
||||
double sin_value = sin(g_tick * PI / 128);
|
||||
for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
|
||||
led = g_rgb_leds[i];
|
||||
hsv.h = (2 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * (led.point.y - 32.0)* cos(g_tick * PI / 128) + (2 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * (66 - abs(led.point.x - 112.0)) * sin(g_tick * PI / 128) + rgb_matrix_config.hue;
|
||||
point = g_rgb_leds[i].point;
|
||||
hsv.h = (2 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * (point.y - 32.0)* cos_value + (2 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * (66 - abs(point.x - 112.0)) * sin_value + rgb_matrix_config.hue;
|
||||
rgb = hsv_to_rgb( hsv );
|
||||
rgb_matrix_set_color( i, rgb.r, rgb.g, rgb.b );
|
||||
}
|
||||
|
@ -474,12 +480,14 @@ void rgb_matrix_rainbow_pinwheels(void) {
|
|||
void rgb_matrix_rainbow_moving_chevron(void) {
|
||||
HSV hsv = { .h = rgb_matrix_config.hue, .s = rgb_matrix_config.sat, .v = rgb_matrix_config.val };
|
||||
RGB rgb;
|
||||
rgb_led led;
|
||||
Point point;
|
||||
uint8_t r = 128;
|
||||
double cos_value = cos(r * PI / 128);
|
||||
double sin_value = sin(r * PI / 128);
|
||||
double multiplier = (g_tick / 256.0 * 224);
|
||||
for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
|
||||
led = g_rgb_leds[i];
|
||||
// uint8_t r = g_tick;
|
||||
uint8_t r = 128;
|
||||
hsv.h = (1.5 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * abs(led.point.y - 32.0)* sin(r * PI / 128) + (1.5 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * (led.point.x - (g_tick / 256.0 * 224)) * cos(r * PI / 128) + rgb_matrix_config.hue;
|
||||
point = g_rgb_leds[i].point;
|
||||
hsv.h = (1.5 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * abs(point.y - 32.0)* sin_value + (1.5 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * (point.x - multiplier) * cos_value + rgb_matrix_config.hue;
|
||||
rgb = hsv_to_rgb( hsv );
|
||||
rgb_matrix_set_color( i, rgb.r, rgb.g, rgb.b );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue