diff options
Diffstat (limited to 'quantum/rgblight.c')
-rw-r--r-- | quantum/rgblight.c | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 45d521786..57de56df7 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
@@ -30,6 +30,9 @@ | |||
30 | #include "rgblight.h" | 30 | #include "rgblight.h" |
31 | #include "debug.h" | 31 | #include "debug.h" |
32 | #include "led_tables.h" | 32 | #include "led_tables.h" |
33 | #ifdef VELOCIKEY_ENABLE | ||
34 | #include "velocikey.h" | ||
35 | #endif | ||
33 | 36 | ||
34 | #define _RGBM_SINGLE_STATIC(sym) RGBLIGHT_MODE_ ## sym, | 37 | #define _RGBM_SINGLE_STATIC(sym) RGBLIGHT_MODE_ ## sym, |
35 | #define _RGBM_SINGLE_DYNAMIC(sym) | 38 | #define _RGBM_SINGLE_DYNAMIC(sym) |
@@ -607,6 +610,19 @@ void rgblight_sethsv_at(uint16_t hue, uint8_t sat, uint8_t val, uint8_t index) { | |||
607 | rgblight_setrgb_at(tmp_led.r, tmp_led.g, tmp_led.b, index); | 610 | rgblight_setrgb_at(tmp_led.r, tmp_led.g, tmp_led.b, index); |
608 | } | 611 | } |
609 | 612 | ||
613 | #if defined(RGBLIGHT_EFFECT_BREATHING) || defined(RGBLIGHT_EFFECT_RAINBOW_MOOD) || defined(RGBLIGHT_EFFECT_RAINBOW_SWIRL) \ | ||
614 | || defined(RGBLIGHT_EFFECT_SNAKE) || defined(RGBLIGHT_EFFECT_KNIGHT) | ||
615 | |||
616 | static uint8_t get_interval_time(const uint8_t* default_interval_address, uint8_t velocikey_min, uint8_t velocikey_max) { | ||
617 | return | ||
618 | #ifdef VELOCIKEY_ENABLE | ||
619 | velocikey_enabled() ? velocikey_match_speed(velocikey_min, velocikey_max) : | ||
620 | #endif | ||
621 | pgm_read_byte(default_interval_address); | ||
622 | } | ||
623 | |||
624 | #endif | ||
625 | |||
610 | void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t end) { | 626 | void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t end) { |
611 | if (!rgblight_config.enable || start < 0 || start >= end || end > RGBLED_NUM) { return; } | 627 | if (!rgblight_config.enable || start < 0 || start >= end || end > RGBLED_NUM) { return; } |
612 | 628 | ||
@@ -707,6 +723,7 @@ void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b) { | |||
707 | } | 723 | } |
708 | 724 | ||
709 | void rgblight_task(void) { | 725 | void rgblight_task(void) { |
726 | |||
710 | if (rgblight_timer_enabled) { | 727 | if (rgblight_timer_enabled) { |
711 | // static light mode, do nothing here | 728 | // static light mode, do nothing here |
712 | if ( 1 == 0 ) { //dummy | 729 | if ( 1 == 0 ) { //dummy |
@@ -778,7 +795,9 @@ void rgblight_effect_breathing(uint8_t interval) { | |||
778 | static uint16_t last_timer = 0; | 795 | static uint16_t last_timer = 0; |
779 | float val; | 796 | float val; |
780 | 797 | ||
781 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_BREATHING_INTERVALS[interval])) { | 798 | uint8_t interval_time = get_interval_time(&RGBLED_RAINBOW_SWIRL_INTERVALS[interval / 2], 1, 100); |
799 | |||
800 | if (timer_elapsed(last_timer) < interval_time) { | ||
782 | return; | 801 | return; |
783 | } | 802 | } |
784 | last_timer = timer_read(); | 803 | last_timer = timer_read(); |
@@ -798,7 +817,9 @@ void rgblight_effect_rainbow_mood(uint8_t interval) { | |||
798 | static uint16_t current_hue = 0; | 817 | static uint16_t current_hue = 0; |
799 | static uint16_t last_timer = 0; | 818 | static uint16_t last_timer = 0; |
800 | 819 | ||
801 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_RAINBOW_MOOD_INTERVALS[interval])) { | 820 | uint8_t interval_time = get_interval_time(&RGBLED_RAINBOW_MOOD_INTERVALS[interval], 5, 100); |
821 | |||
822 | if (timer_elapsed(last_timer) < interval_time) { | ||
802 | return; | 823 | return; |
803 | } | 824 | } |
804 | last_timer = timer_read(); | 825 | last_timer = timer_read(); |
@@ -820,7 +841,10 @@ void rgblight_effect_rainbow_swirl(uint8_t interval) { | |||
820 | static uint16_t last_timer = 0; | 841 | static uint16_t last_timer = 0; |
821 | uint16_t hue; | 842 | uint16_t hue; |
822 | uint8_t i; | 843 | uint8_t i; |
823 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_RAINBOW_SWIRL_INTERVALS[interval / 2])) { | 844 | |
845 | uint8_t interval_time = get_interval_time(&RGBLED_RAINBOW_SWIRL_INTERVALS[interval / 2], 1, 100); | ||
846 | |||
847 | if (timer_elapsed(last_timer) < interval_time) { | ||
824 | return; | 848 | return; |
825 | } | 849 | } |
826 | last_timer = timer_read(); | 850 | last_timer = timer_read(); |
@@ -855,7 +879,10 @@ void rgblight_effect_snake(uint8_t interval) { | |||
855 | if (interval % 2) { | 879 | if (interval % 2) { |
856 | increment = -1; | 880 | increment = -1; |
857 | } | 881 | } |
858 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_SNAKE_INTERVALS[interval / 2])) { | 882 | |
883 | uint8_t interval_time = get_interval_time(&RGBLED_SNAKE_INTERVALS[interval / 2], 1, 200); | ||
884 | |||
885 | if (timer_elapsed(last_timer) < interval_time) { | ||
859 | return; | 886 | return; |
860 | } | 887 | } |
861 | last_timer = timer_read(); | 888 | last_timer = timer_read(); |
@@ -892,7 +919,10 @@ const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31}; | |||
892 | 919 | ||
893 | void rgblight_effect_knight(uint8_t interval) { | 920 | void rgblight_effect_knight(uint8_t interval) { |
894 | static uint16_t last_timer = 0; | 921 | static uint16_t last_timer = 0; |
895 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_KNIGHT_INTERVALS[interval])) { | 922 | |
923 | uint8_t interval_time = get_interval_time(&RGBLED_KNIGHT_INTERVALS[interval], 5, 100); | ||
924 | |||
925 | if (timer_elapsed(last_timer) < interval_time) { | ||
896 | return; | 926 | return; |
897 | } | 927 | } |
898 | last_timer = timer_read(); | 928 | last_timer = timer_read(); |