diff options
Diffstat (limited to 'quantum/rgb_matrix.c')
| -rw-r--r-- | quantum/rgb_matrix.c | 170 |
1 files changed, 110 insertions, 60 deletions
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 26ee57f5c..15bd13671 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c | |||
| @@ -55,6 +55,10 @@ rgb_config_t rgb_matrix_config; | |||
| 55 | #define RGB_DIGITAL_RAIN_DROPS 24 | 55 | #define RGB_DIGITAL_RAIN_DROPS 24 |
| 56 | #endif | 56 | #endif |
| 57 | 57 | ||
| 58 | #if !defined(DISABLE_RGB_MATRIX_RAINDROPS) || !defined(DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS) || !defined(DISABLE_RGB_MATRIX_DIGITAL_RAIN) | ||
| 59 | #define TRACK_PREVIOUS_EFFECT | ||
| 60 | #endif | ||
| 61 | |||
| 58 | bool g_suspend_state = false; | 62 | bool g_suspend_state = false; |
| 59 | 63 | ||
| 60 | // Global tick at 20 Hz | 64 | // Global tick at 20 Hz |
| @@ -79,7 +83,12 @@ void eeconfig_update_rgb_matrix(uint32_t val) { | |||
| 79 | void eeconfig_update_rgb_matrix_default(void) { | 83 | void eeconfig_update_rgb_matrix_default(void) { |
| 80 | dprintf("eeconfig_update_rgb_matrix_default\n"); | 84 | dprintf("eeconfig_update_rgb_matrix_default\n"); |
| 81 | rgb_matrix_config.enable = 1; | 85 | rgb_matrix_config.enable = 1; |
| 86 | #ifndef DISABLE_RGB_MATRIX_CYCLE_ALL | ||
| 82 | rgb_matrix_config.mode = RGB_MATRIX_CYCLE_LEFT_RIGHT; | 87 | rgb_matrix_config.mode = RGB_MATRIX_CYCLE_LEFT_RIGHT; |
| 88 | #else | ||
| 89 | // fallback to solid colors if RGB_MATRIX_CYCLE_LEFT_RIGHT is disabled in userspace | ||
| 90 | rgb_matrix_config.mode = RGB_MATRIX_SOLID_COLOR; | ||
| 91 | #endif | ||
| 83 | rgb_matrix_config.hue = 0; | 92 | rgb_matrix_config.hue = 0; |
| 84 | rgb_matrix_config.sat = 255; | 93 | rgb_matrix_config.sat = 255; |
| 85 | rgb_matrix_config.val = RGB_MATRIX_MAXIMUM_BRIGHTNESS; | 94 | rgb_matrix_config.val = RGB_MATRIX_MAXIMUM_BRIGHTNESS; |
| @@ -499,7 +508,7 @@ void rgb_matrix_digital_rain( const bool initialize ) { | |||
| 499 | map_row_column_to_led(row, col, &led, &led_count); | 508 | map_row_column_to_led(row, col, &led, &led_count); |
| 500 | 509 | ||
| 501 | if (map[col][row] > pure_green_intensity) { | 510 | if (map[col][row] > pure_green_intensity) { |
| 502 | const uint8_t boost = (uint8_t) ((uint16_t) max_brightness_boost | 511 | const uint8_t boost = (uint8_t) ((uint16_t) max_brightness_boost |
| 503 | * (map[col][row] - pure_green_intensity) / (max_intensity - pure_green_intensity)); | 512 | * (map[col][row] - pure_green_intensity) / (max_intensity - pure_green_intensity)); |
| 504 | rgb_matrix_set_color(led, boost, max_intensity, boost); | 513 | rgb_matrix_set_color(led, boost, max_intensity, boost); |
| 505 | } | 514 | } |
| @@ -618,12 +627,16 @@ void rgb_matrix_custom(void) { | |||
| 618 | } | 627 | } |
| 619 | 628 | ||
| 620 | void rgb_matrix_task(void) { | 629 | void rgb_matrix_task(void) { |
| 621 | static uint8_t toggle_enable_last = 255; | 630 | #ifdef TRACK_PREVIOUS_EFFECT |
| 631 | static uint8_t toggle_enable_last = 255; | ||
| 632 | #endif | ||
| 622 | if (!rgb_matrix_config.enable) { | 633 | if (!rgb_matrix_config.enable) { |
| 623 | rgb_matrix_all_off(); | 634 | rgb_matrix_all_off(); |
| 624 | rgb_matrix_indicators(); | 635 | rgb_matrix_indicators(); |
| 625 | toggle_enable_last = rgb_matrix_config.enable; | 636 | #ifdef TRACK_PREVIOUS_EFFECT |
| 626 | return; | 637 | toggle_enable_last = rgb_matrix_config.enable; |
| 638 | #endif | ||
| 639 | return; | ||
| 627 | } | 640 | } |
| 628 | // delay 1 second before driving LEDs or doing anything else | 641 | // delay 1 second before driving LEDs or doing anything else |
| 629 | static uint8_t startup_tick = 0; | 642 | static uint8_t startup_tick = 0; |
| @@ -658,13 +671,16 @@ void rgb_matrix_task(void) { | |||
| 658 | (RGB_DISABLE_AFTER_TIMEOUT > 0 && g_any_key_hit > RGB_DISABLE_AFTER_TIMEOUT * 60 * 20)); | 671 | (RGB_DISABLE_AFTER_TIMEOUT > 0 && g_any_key_hit > RGB_DISABLE_AFTER_TIMEOUT * 60 * 20)); |
| 659 | uint8_t effect = suspend_backlight ? 0 : rgb_matrix_config.mode; | 672 | uint8_t effect = suspend_backlight ? 0 : rgb_matrix_config.mode; |
| 660 | 673 | ||
| 661 | // Keep track of the effect used last time, | 674 | #ifdef TRACK_PREVIOUS_EFFECT |
| 662 | // detect change in effect, so each effect can | 675 | // Keep track of the effect used last time, |
| 663 | // have an optional initialization. | 676 | // detect change in effect, so each effect can |
| 664 | static uint8_t effect_last = 255; | 677 | // have an optional initialization. |
| 665 | bool initialize = (effect != effect_last) || (rgb_matrix_config.enable != toggle_enable_last); | 678 | |
| 666 | effect_last = effect; | 679 | static uint8_t effect_last = 255; |
| 667 | toggle_enable_last = rgb_matrix_config.enable; | 680 | bool initialize = (effect != effect_last) || (rgb_matrix_config.enable != toggle_enable_last); |
| 681 | effect_last = effect; | ||
| 682 | toggle_enable_last = rgb_matrix_config.enable; | ||
| 683 | #endif | ||
| 668 | 684 | ||
| 669 | // this gets ticked at 20 Hz. | 685 | // this gets ticked at 20 Hz. |
| 670 | // each effect can opt to do calculations | 686 | // each effect can opt to do calculations |
| @@ -673,59 +689,93 @@ void rgb_matrix_task(void) { | |||
| 673 | case RGB_MATRIX_SOLID_COLOR: | 689 | case RGB_MATRIX_SOLID_COLOR: |
| 674 | rgb_matrix_solid_color(); | 690 | rgb_matrix_solid_color(); |
| 675 | break; | 691 | break; |
| 676 | case RGB_MATRIX_ALPHAS_MODS: | 692 | #ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS |
| 677 | rgb_matrix_alphas_mods(); | 693 | case RGB_MATRIX_ALPHAS_MODS: |
| 678 | break; | 694 | rgb_matrix_alphas_mods(); |
| 679 | case RGB_MATRIX_DUAL_BEACON: | ||
| 680 | rgb_matrix_dual_beacon(); | ||
| 681 | break; | ||
| 682 | case RGB_MATRIX_GRADIENT_UP_DOWN: | ||
| 683 | rgb_matrix_gradient_up_down(); | ||
| 684 | break; | ||
| 685 | case RGB_MATRIX_RAINDROPS: | ||
| 686 | rgb_matrix_raindrops( initialize ); | ||
| 687 | break; | ||
| 688 | case RGB_MATRIX_CYCLE_ALL: | ||
| 689 | rgb_matrix_cycle_all(); | ||
| 690 | break; | ||
| 691 | case RGB_MATRIX_CYCLE_LEFT_RIGHT: | ||
| 692 | rgb_matrix_cycle_left_right(); | ||
| 693 | break; | ||
| 694 | case RGB_MATRIX_CYCLE_UP_DOWN: | ||
| 695 | rgb_matrix_cycle_up_down(); | ||
| 696 | break; | ||
| 697 | case RGB_MATRIX_RAINBOW_BEACON: | ||
| 698 | rgb_matrix_rainbow_beacon(); | ||
| 699 | break; | ||
| 700 | case RGB_MATRIX_RAINBOW_PINWHEELS: | ||
| 701 | rgb_matrix_rainbow_pinwheels(); | ||
| 702 | break; | ||
| 703 | case RGB_MATRIX_RAINBOW_MOVING_CHEVRON: | ||
| 704 | rgb_matrix_rainbow_moving_chevron(); | ||
| 705 | break; | ||
| 706 | case RGB_MATRIX_JELLYBEAN_RAINDROPS: | ||
| 707 | rgb_matrix_jellybean_raindrops( initialize ); | ||
| 708 | break; | ||
| 709 | case RGB_MATRIX_DIGITAL_RAIN: | ||
| 710 | rgb_matrix_digital_rain( initialize ); | ||
| 711 | break; | ||
| 712 | #ifdef RGB_MATRIX_KEYPRESSES | ||
| 713 | case RGB_MATRIX_SOLID_REACTIVE: | ||
| 714 | rgb_matrix_solid_reactive(); | ||
| 715 | break; | 695 | break; |
| 716 | case RGB_MATRIX_SPLASH: | 696 | #endif |
| 717 | rgb_matrix_splash(); | 697 | #ifndef DISABLE_RGB_MATRIX_DUAL_BEACON |
| 698 | case RGB_MATRIX_DUAL_BEACON: | ||
| 699 | rgb_matrix_dual_beacon(); | ||
| 700 | break; | ||
| 701 | #endif | ||
| 702 | #ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN | ||
| 703 | case RGB_MATRIX_GRADIENT_UP_DOWN: | ||
| 704 | rgb_matrix_gradient_up_down(); | ||
| 705 | break; | ||
| 706 | #endif | ||
| 707 | #ifndef DISABLE_RGB_MATRIX_RAINDROPS | ||
| 708 | case RGB_MATRIX_RAINDROPS: | ||
| 709 | rgb_matrix_raindrops( initialize ); | ||
| 710 | break; | ||
| 711 | #endif | ||
| 712 | #ifndef DISABLE_RGB_MATRIX_CYCLE_ALL | ||
| 713 | case RGB_MATRIX_CYCLE_ALL: | ||
| 714 | rgb_matrix_cycle_all(); | ||
| 715 | break; | ||
| 716 | #endif | ||
| 717 | #ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT | ||
| 718 | case RGB_MATRIX_CYCLE_LEFT_RIGHT: | ||
| 719 | rgb_matrix_cycle_left_right(); | ||
| 720 | break; | ||
| 721 | #endif | ||
| 722 | #ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN | ||
| 723 | case RGB_MATRIX_CYCLE_UP_DOWN: | ||
| 724 | rgb_matrix_cycle_up_down(); | ||
| 725 | break; | ||
| 726 | #endif | ||
| 727 | #ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON | ||
| 728 | case RGB_MATRIX_RAINBOW_BEACON: | ||
| 729 | rgb_matrix_rainbow_beacon(); | ||
| 730 | break; | ||
| 731 | #endif | ||
| 732 | #ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS | ||
| 733 | case RGB_MATRIX_RAINBOW_PINWHEELS: | ||
| 734 | rgb_matrix_rainbow_pinwheels(); | ||
| 718 | break; | 735 | break; |
| 719 | case RGB_MATRIX_MULTISPLASH: | 736 | #endif |
| 720 | rgb_matrix_multisplash(); | 737 | #ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON |
| 738 | case RGB_MATRIX_RAINBOW_MOVING_CHEVRON: | ||
| 739 | rgb_matrix_rainbow_moving_chevron(); | ||
| 721 | break; | 740 | break; |
| 722 | case RGB_MATRIX_SOLID_SPLASH: | 741 | #endif |
| 723 | rgb_matrix_solid_splash(); | 742 | #ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS |
| 743 | case RGB_MATRIX_JELLYBEAN_RAINDROPS: | ||
| 744 | rgb_matrix_jellybean_raindrops( initialize ); | ||
| 724 | break; | 745 | break; |
| 725 | case RGB_MATRIX_SOLID_MULTISPLASH: | 746 | #endif |
| 726 | rgb_matrix_solid_multisplash(); | 747 | #ifndef DISABLE_RGB_MATRIX_DIGITAL_RAIN |
| 748 | case RGB_MATRIX_DIGITAL_RAIN: | ||
| 749 | rgb_matrix_digital_rain( initialize ); | ||
| 727 | break; | 750 | break; |
| 728 | #endif | 751 | #endif |
| 752 | #ifdef RGB_MATRIX_KEYPRESSES | ||
| 753 | #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE | ||
| 754 | case RGB_MATRIX_SOLID_REACTIVE: | ||
| 755 | rgb_matrix_solid_reactive(); | ||
| 756 | break; | ||
| 757 | #endif | ||
| 758 | #ifndef DISABLE_RGB_MATRIX_SPLASH | ||
| 759 | case RGB_MATRIX_SPLASH: | ||
| 760 | rgb_matrix_splash(); | ||
| 761 | break; | ||
| 762 | #endif | ||
| 763 | #ifndef DISABLE_RGB_MATRIX_MULTISPLASH | ||
| 764 | case RGB_MATRIX_MULTISPLASH: | ||
| 765 | rgb_matrix_multisplash(); | ||
| 766 | break; | ||
| 767 | #endif | ||
| 768 | #ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH | ||
| 769 | case RGB_MATRIX_SOLID_SPLASH: | ||
| 770 | rgb_matrix_solid_splash(); | ||
| 771 | break; | ||
| 772 | #endif | ||
| 773 | #ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH | ||
| 774 | case RGB_MATRIX_SOLID_MULTISPLASH: | ||
| 775 | rgb_matrix_solid_multisplash(); | ||
| 776 | break; | ||
| 777 | #endif | ||
| 778 | #endif | ||
| 729 | default: | 779 | default: |
| 730 | rgb_matrix_custom(); | 780 | rgb_matrix_custom(); |
| 731 | break; | 781 | break; |
