aboutsummaryrefslogtreecommitdiff
path: root/quantum/rgblight.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/rgblight.c')
-rw-r--r--quantum/rgblight.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index 3042ff11e..08515564b 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -66,6 +66,15 @@ bool is_rgblight_initialized = false;
66LED_TYPE led[RGBLED_NUM]; 66LED_TYPE led[RGBLED_NUM];
67bool rgblight_timer_enabled = false; 67bool rgblight_timer_enabled = false;
68 68
69static uint8_t clipping_start_pos = 0;
70static uint8_t clipping_num_leds = RGBLED_NUM;
71
72void rgblight_set_clipping_range(uint8_t start_pos, uint8_t num_leds) {
73 clipping_start_pos = start_pos;
74 clipping_num_leds = num_leds;
75}
76
77
69void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { 78void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) {
70 uint8_t r = 0, g = 0, b = 0, base, color; 79 uint8_t r = 0, g = 0, b = 0, base, color;
71 80
@@ -621,7 +630,7 @@ void rgblight_sethsv_at(uint16_t hue, uint8_t sat, uint8_t val, uint8_t index) {
621 || defined(RGBLIGHT_EFFECT_SNAKE) || defined(RGBLIGHT_EFFECT_KNIGHT) 630 || defined(RGBLIGHT_EFFECT_SNAKE) || defined(RGBLIGHT_EFFECT_KNIGHT)
622 631
623static uint8_t get_interval_time(const uint8_t* default_interval_address, uint8_t velocikey_min, uint8_t velocikey_max) { 632static uint8_t get_interval_time(const uint8_t* default_interval_address, uint8_t velocikey_min, uint8_t velocikey_max) {
624 return 633 return
625#ifdef VELOCIKEY_ENABLE 634#ifdef VELOCIKEY_ENABLE
626 velocikey_enabled() ? velocikey_match_speed(velocikey_min, velocikey_max) : 635 velocikey_enabled() ? velocikey_match_speed(velocikey_min, velocikey_max) :
627#endif 636#endif
@@ -668,21 +677,20 @@ void rgblight_sethsv_slave(uint16_t hue, uint8_t sat, uint8_t val) {
668 677
669#ifndef RGBLIGHT_CUSTOM_DRIVER 678#ifndef RGBLIGHT_CUSTOM_DRIVER
670void rgblight_set(void) { 679void rgblight_set(void) {
680 LED_TYPE *start_led = led + clipping_start_pos;
681 uint16_t num_leds = clipping_num_leds;
671 if (rgblight_config.enable) { 682 if (rgblight_config.enable) {
672 LED_TYPE *ledp;
673 #ifdef RGBLIGHT_LED_MAP 683 #ifdef RGBLIGHT_LED_MAP
674 LED_TYPE led0[RGBLED_NUM]; 684 LED_TYPE led0[RGBLED_NUM];
675 for(uint8_t i = 0; i < RGBLED_NUM; i++) { 685 for(uint8_t i = 0; i < RGBLED_NUM; i++) {
676 led0[i] = led[pgm_read_byte(&led_map[i])]; 686 led0[i] = led[pgm_read_byte(&led_map[i])];
677 } 687 }
678 ledp = led0; 688 start_led = led0 + clipping_start_pos;
679 #else
680 ledp = led;
681 #endif 689 #endif
682 #ifdef RGBW 690 #ifdef RGBW
683 ws2812_setleds_rgbw(ledp, RGBLED_NUM); 691 ws2812_setleds_rgbw(start_led, num_leds);
684 #else 692 #else
685 ws2812_setleds(ledp, RGBLED_NUM); 693 ws2812_setleds(start_led, num_leds);
686 #endif 694 #endif
687 } else { 695 } else {
688 for (uint8_t i = 0; i < RGBLED_NUM; i++) { 696 for (uint8_t i = 0; i < RGBLED_NUM; i++) {
@@ -691,9 +699,9 @@ void rgblight_set(void) {
691 led[i].b = 0; 699 led[i].b = 0;
692 } 700 }
693 #ifdef RGBW 701 #ifdef RGBW
694 ws2812_setleds_rgbw(led, RGBLED_NUM); 702 ws2812_setleds_rgbw(start_led, num_leds);
695 #else 703 #else
696 ws2812_setleds(led, RGBLED_NUM); 704 ws2812_setleds(start_led, num_leds);
697 #endif 705 #endif
698 } 706 }
699} 707}
@@ -813,7 +821,7 @@ void rgblight_effect_breathing(uint8_t interval) {
813 float val; 821 float val;
814 822
815 uint8_t interval_time = get_interval_time(&RGBLED_BREATHING_INTERVALS[interval], 1, 100); 823 uint8_t interval_time = get_interval_time(&RGBLED_BREATHING_INTERVALS[interval], 1, 100);
816 824
817 if (timer_elapsed(last_timer) < interval_time) { 825 if (timer_elapsed(last_timer) < interval_time) {
818 return; 826 return;
819 } 827 }