diff options
Diffstat (limited to 'quantum/rgb_matrix.c')
-rw-r--r-- | quantum/rgb_matrix.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 558e28dec..f3d012bc3 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c | |||
@@ -324,8 +324,8 @@ void rgb_matrix_raindrops(bool initialize) { | |||
324 | HSV hsv; | 324 | HSV hsv; |
325 | RGB rgb; | 325 | RGB rgb; |
326 | 326 | ||
327 | // Change one LED every tick | 327 | // Change one LED every tick, make sure speed is not 0 |
328 | uint8_t led_to_change = ( g_tick & 0x000 ) == 0 ? rand() % DRIVER_LED_TOTAL : 255; | 328 | uint8_t led_to_change = ( g_tick & ( 0x0A / (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed) ) ) == 0 ? rand() % (DRIVER_LED_TOTAL) : 255; |
329 | 329 | ||
330 | for ( int i=0; i<DRIVER_LED_TOTAL; i++ ) | 330 | for ( int i=0; i<DRIVER_LED_TOTAL; i++ ) |
331 | { | 331 | { |
@@ -432,7 +432,7 @@ void rgb_matrix_rainbow_beacon(void) { | |||
432 | rgb_led led; | 432 | rgb_led led; |
433 | for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { | 433 | for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { |
434 | led = g_rgb_leds[i]; | 434 | led = g_rgb_leds[i]; |
435 | hsv.h = 1.5 * (led.point.y - 32.0)* cos(g_tick * PI / 128) + 1.5 * (led.point.x - 112.0) * sin(g_tick * PI / 128) + rgb_matrix_config.hue; | 435 | 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; |
436 | rgb = hsv_to_rgb( hsv ); | 436 | rgb = hsv_to_rgb( hsv ); |
437 | rgb_matrix_set_color( i, rgb.r, rgb.g, rgb.b ); | 437 | rgb_matrix_set_color( i, rgb.r, rgb.g, rgb.b ); |
438 | } | 438 | } |
@@ -444,7 +444,7 @@ void rgb_matrix_rainbow_pinwheels(void) { | |||
444 | rgb_led led; | 444 | rgb_led led; |
445 | for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { | 445 | for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { |
446 | led = g_rgb_leds[i]; | 446 | led = g_rgb_leds[i]; |
447 | hsv.h = 2 * (led.point.y - 32.0)* cos(g_tick * PI / 128) + 2 * (66 - abs(led.point.x - 112.0)) * sin(g_tick * PI / 128) + rgb_matrix_config.hue; | 447 | 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; |
448 | rgb = hsv_to_rgb( hsv ); | 448 | rgb = hsv_to_rgb( hsv ); |
449 | rgb_matrix_set_color( i, rgb.r, rgb.g, rgb.b ); | 449 | rgb_matrix_set_color( i, rgb.r, rgb.g, rgb.b ); |
450 | } | 450 | } |
@@ -458,7 +458,7 @@ void rgb_matrix_rainbow_moving_chevron(void) { | |||
458 | led = g_rgb_leds[i]; | 458 | led = g_rgb_leds[i]; |
459 | // uint8_t r = g_tick; | 459 | // uint8_t r = g_tick; |
460 | uint8_t r = 32; | 460 | uint8_t r = 32; |
461 | hsv.h = 1.5 * abs(led.point.y - 32.0)* sin(r * PI / 128) + 1.5 * (led.point.x - (g_tick / 256.0 * 224)) * cos(r * PI / 128) + rgb_matrix_config.hue; | 461 | 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; |
462 | rgb = hsv_to_rgb( hsv ); | 462 | rgb = hsv_to_rgb( hsv ); |
463 | rgb_matrix_set_color( i, rgb.r, rgb.g, rgb.b ); | 463 | rgb_matrix_set_color( i, rgb.r, rgb.g, rgb.b ); |
464 | } | 464 | } |
@@ -469,8 +469,8 @@ void rgb_matrix_jellybean_raindrops( bool initialize ) { | |||
469 | HSV hsv; | 469 | HSV hsv; |
470 | RGB rgb; | 470 | RGB rgb; |
471 | 471 | ||
472 | // Change one LED every tick | 472 | // Change one LED every tick, make sure speed is not 0 |
473 | uint8_t led_to_change = ( g_tick & 0x000 ) == 0 ? rand() % DRIVER_LED_TOTAL : 255; | 473 | uint8_t led_to_change = ( g_tick & ( 0x0A / (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed) ) ) == 0 ? rand() % (DRIVER_LED_TOTAL) : 255; |
474 | 474 | ||
475 | for ( int i=0; i<DRIVER_LED_TOTAL; i++ ) | 475 | for ( int i=0; i<DRIVER_LED_TOTAL; i++ ) |
476 | { | 476 | { |
@@ -577,8 +577,10 @@ void rgb_matrix_custom(void) { | |||
577 | } | 577 | } |
578 | 578 | ||
579 | void rgb_matrix_task(void) { | 579 | void rgb_matrix_task(void) { |
580 | static uint8_t toggle_enable_last = 255; | ||
580 | if (!rgb_matrix_config.enable) { | 581 | if (!rgb_matrix_config.enable) { |
581 | rgb_matrix_all_off(); | 582 | rgb_matrix_all_off(); |
583 | toggle_enable_last = rgb_matrix_config.enable; | ||
582 | return; | 584 | return; |
583 | } | 585 | } |
584 | // delay 1 second before driving LEDs or doing anything else | 586 | // delay 1 second before driving LEDs or doing anything else |
@@ -618,8 +620,9 @@ void rgb_matrix_task(void) { | |||
618 | // detect change in effect, so each effect can | 620 | // detect change in effect, so each effect can |
619 | // have an optional initialization. | 621 | // have an optional initialization. |
620 | static uint8_t effect_last = 255; | 622 | static uint8_t effect_last = 255; |
621 | bool initialize = effect != effect_last; | 623 | bool initialize = (effect != effect_last) || (rgb_matrix_config.enable != toggle_enable_last); |
622 | effect_last = effect; | 624 | effect_last = effect; |
625 | toggle_enable_last = rgb_matrix_config.enable; | ||
623 | 626 | ||
624 | // this gets ticked at 20 Hz. | 627 | // this gets ticked at 20 Hz. |
625 | // each effect can opt to do calculations | 628 | // each effect can opt to do calculations |
@@ -628,9 +631,6 @@ void rgb_matrix_task(void) { | |||
628 | case RGB_MATRIX_SOLID_COLOR: | 631 | case RGB_MATRIX_SOLID_COLOR: |
629 | rgb_matrix_solid_color(); | 632 | rgb_matrix_solid_color(); |
630 | break; | 633 | break; |
631 | case RGB_MATRIX_SOLID_REACTIVE: | ||
632 | rgb_matrix_solid_reactive(); | ||
633 | break; | ||
634 | case RGB_MATRIX_ALPHAS_MODS: | 634 | case RGB_MATRIX_ALPHAS_MODS: |
635 | rgb_matrix_alphas_mods(); | 635 | rgb_matrix_alphas_mods(); |
636 | break; | 636 | break; |
@@ -665,6 +665,9 @@ void rgb_matrix_task(void) { | |||
665 | rgb_matrix_jellybean_raindrops( initialize ); | 665 | rgb_matrix_jellybean_raindrops( initialize ); |
666 | break; | 666 | break; |
667 | #ifdef RGB_MATRIX_KEYPRESSES | 667 | #ifdef RGB_MATRIX_KEYPRESSES |
668 | case RGB_MATRIX_SOLID_REACTIVE: | ||
669 | rgb_matrix_solid_reactive(); | ||
670 | break; | ||
668 | case RGB_MATRIX_SPLASH: | 671 | case RGB_MATRIX_SPLASH: |
669 | rgb_matrix_splash(); | 672 | rgb_matrix_splash(); |
670 | break; | 673 | break; |
@@ -830,8 +833,8 @@ void rgblight_step(void) { | |||
830 | 833 | ||
831 | void rgblight_step_reverse(void) { | 834 | void rgblight_step_reverse(void) { |
832 | rgb_matrix_config.mode--; | 835 | rgb_matrix_config.mode--; |
833 | if (rgb_matrix_config.mode <= 1) | 836 | if (rgb_matrix_config.mode < 1) |
834 | rgb_matrix_config.mode = (RGB_MATRIX_EFFECT_MAX - 1); | 837 | rgb_matrix_config.mode = RGB_MATRIX_EFFECT_MAX - 1; |
835 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 838 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); |
836 | } | 839 | } |
837 | 840 | ||