diff options
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/rgblight.c | 28 | ||||
| -rw-r--r-- | quantum/rgblight.h | 1 | ||||
| -rw-r--r-- | quantum/split_common/split_util.c | 32 | ||||
| -rw-r--r-- | quantum/split_common/transport.c | 23 |
4 files changed, 55 insertions, 29 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; | |||
| 66 | LED_TYPE led[RGBLED_NUM]; | 66 | LED_TYPE led[RGBLED_NUM]; |
| 67 | bool rgblight_timer_enabled = false; | 67 | bool rgblight_timer_enabled = false; |
| 68 | 68 | ||
| 69 | static uint8_t clipping_start_pos = 0; | ||
| 70 | static uint8_t clipping_num_leds = RGBLED_NUM; | ||
| 71 | |||
| 72 | void 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 | |||
| 69 | void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { | 78 | void 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 | ||
| 623 | static uint8_t get_interval_time(const uint8_t* default_interval_address, uint8_t velocikey_min, uint8_t velocikey_max) { | 632 | static 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 |
| 670 | void rgblight_set(void) { | 679 | void 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 | } |
diff --git a/quantum/rgblight.h b/quantum/rgblight.h index 36e436b89..1769f719d 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h | |||
| @@ -197,6 +197,7 @@ void rgblight_setrgb_master(uint8_t r, uint8_t g, uint8_t b); | |||
| 197 | void rgblight_setrgb_slave(uint8_t r, uint8_t g, uint8_t b); | 197 | void rgblight_setrgb_slave(uint8_t r, uint8_t g, uint8_t b); |
| 198 | void rgblight_sethsv_master(uint16_t hue, uint8_t sat, uint8_t val); | 198 | void rgblight_sethsv_master(uint16_t hue, uint8_t sat, uint8_t val); |
| 199 | void rgblight_sethsv_slave(uint16_t hue, uint8_t sat, uint8_t val); | 199 | void rgblight_sethsv_slave(uint16_t hue, uint8_t sat, uint8_t val); |
| 200 | void rgblight_set_clipping_range(uint8_t start_pos, uint8_t num_leds); | ||
| 200 | 201 | ||
| 201 | uint32_t eeconfig_read_rgblight(void); | 202 | uint32_t eeconfig_read_rgblight(void); |
| 202 | void eeconfig_update_rgblight(uint32_t val); | 203 | void eeconfig_update_rgblight(uint32_t val); |
diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c index da870f877..09a307b8e 100644 --- a/quantum/split_common/split_util.c +++ b/quantum/split_common/split_util.c | |||
| @@ -11,25 +11,25 @@ | |||
| 11 | # include "eeconfig.h" | 11 | # include "eeconfig.h" |
| 12 | #endif | 12 | #endif |
| 13 | 13 | ||
| 14 | #if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT) | ||
| 15 | #include "rgblight.h" | ||
| 16 | #endif | ||
| 17 | |||
| 14 | volatile bool isLeftHand = true; | 18 | volatile bool isLeftHand = true; |
| 15 | 19 | ||
| 16 | __attribute__((weak)) | 20 | __attribute__((weak)) |
| 17 | bool is_keyboard_left(void) { | 21 | bool is_keyboard_left(void) { |
| 18 | #ifdef SPLIT_HAND_PIN | 22 | #if defined(SPLIT_HAND_PIN) |
| 19 | // Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand | 23 | // Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand |
| 20 | setPinInput(SPLIT_HAND_PIN); | 24 | setPinInput(SPLIT_HAND_PIN); |
| 21 | return readPin(SPLIT_HAND_PIN); | 25 | return readPin(SPLIT_HAND_PIN); |
| 22 | #else | 26 | #elif defined(EE_HANDS) |
| 23 | #ifdef EE_HANDS | 27 | return eeprom_read_byte(EECONFIG_HANDEDNESS); |
| 24 | return eeprom_read_byte(EECONFIG_HANDEDNESS); | 28 | #elif defined(MASTER_RIGHT) |
| 25 | #else | 29 | return !is_keyboard_master(); |
| 26 | #ifdef MASTER_RIGHT | ||
| 27 | return !is_keyboard_master(); | ||
| 28 | #else | ||
| 29 | return is_keyboard_master(); | ||
| 30 | #endif | ||
| 31 | #endif | ||
| 32 | #endif | 30 | #endif |
| 31 | |||
| 32 | return is_keyboard_master(); | ||
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | bool is_keyboard_master(void) | 35 | bool is_keyboard_master(void) |
| @@ -71,6 +71,16 @@ void matrix_setup(void) | |||
| 71 | { | 71 | { |
| 72 | isLeftHand = is_keyboard_left(); | 72 | isLeftHand = is_keyboard_left(); |
| 73 | 73 | ||
| 74 | #if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT) | ||
| 75 | uint8_t num_rgb_leds_split[2] = RGBLED_SPLIT; | ||
| 76 | if (isLeftHand) { | ||
| 77 | rgblight_set_clipping_range(0, num_rgb_leds_split[0]); | ||
| 78 | } | ||
| 79 | else { | ||
| 80 | rgblight_set_clipping_range(num_rgb_leds_split[0], num_rgb_leds_split[1]); | ||
| 81 | } | ||
| 82 | #endif | ||
| 83 | |||
| 74 | if (is_keyboard_master()) | 84 | if (is_keyboard_master()) |
| 75 | { | 85 | { |
| 76 | keyboard_master_setup(); | 86 | keyboard_master_setup(); |
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c index 631d913f7..8d408f6fd 100644 --- a/quantum/split_common/transport.c +++ b/quantum/split_common/transport.c | |||
| @@ -92,12 +92,13 @@ typedef struct _Serial_m2s_buffer_t { | |||
| 92 | # ifdef BACKLIGHT_ENABLE | 92 | # ifdef BACKLIGHT_ENABLE |
| 93 | uint8_t backlight_level; | 93 | uint8_t backlight_level; |
| 94 | # endif | 94 | # endif |
| 95 | # if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | 95 | # if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT) |
| 96 | rgblight_config_t rgblight_config; // not yet use | 96 | rgblight_config_t rgblight_config; // not yet use |
| 97 | // | 97 | // |
| 98 | // When MCUs on both sides drive their respective RGB LED chains, | 98 | // When MCUs on both sides drive their respective RGB LED chains, |
| 99 | // it is necessary to synchronize, so it is necessary to communicate RGB | 99 | // it is necessary to synchronize, so it is necessary to communicate RGB |
| 100 | // information. In that case, define the RGBLIGHT_SPLIT macro. | 100 | // information. In that case, define RGBLED_SPLIT with info on the number |
| 101 | // of LEDs on each half. | ||
| 101 | // | 102 | // |
| 102 | // Otherwise, if the master side MCU drives both sides RGB LED chains, | 103 | // Otherwise, if the master side MCU drives both sides RGB LED chains, |
| 103 | // there is no need to communicate. | 104 | // there is no need to communicate. |
| @@ -132,15 +133,20 @@ bool transport_master(matrix_row_t matrix[]) { | |||
| 132 | matrix[i] = serial_s2m_buffer.smatrix[i]; | 133 | matrix[i] = serial_s2m_buffer.smatrix[i]; |
| 133 | } | 134 | } |
| 134 | 135 | ||
| 135 | # if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | ||
| 136 | // Code to send RGB over serial goes here (not implemented yet) | ||
| 137 | # endif | ||
| 138 | |||
| 139 | # ifdef BACKLIGHT_ENABLE | 136 | # ifdef BACKLIGHT_ENABLE |
| 140 | // Write backlight level for slave to read | 137 | // Write backlight level for slave to read |
| 141 | serial_m2s_buffer.backlight_level = backlight_config.enable ? backlight_config.level : 0; | 138 | serial_m2s_buffer.backlight_level = backlight_config.enable ? backlight_config.level : 0; |
| 142 | # endif | 139 | # endif |
| 143 | 140 | ||
| 141 | # if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT) | ||
| 142 | static rgblight_config_t prev_rgb = {~0}; | ||
| 143 | uint32_t rgb = rgblight_read_dword(); | ||
| 144 | if (rgb != prev_rgb.raw) { | ||
| 145 | serial_m2s_buffer.rgblight_config.raw = rgb; | ||
| 146 | prev_rgb.raw = rgb; | ||
| 147 | } | ||
| 148 | # endif | ||
| 149 | |||
| 144 | return true; | 150 | return true; |
| 145 | } | 151 | } |
| 146 | 152 | ||
| @@ -152,8 +158,9 @@ void transport_slave(matrix_row_t matrix[]) { | |||
| 152 | # ifdef BACKLIGHT_ENABLE | 158 | # ifdef BACKLIGHT_ENABLE |
| 153 | backlight_set(serial_m2s_buffer.backlight_level); | 159 | backlight_set(serial_m2s_buffer.backlight_level); |
| 154 | # endif | 160 | # endif |
| 155 | # if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | 161 | # if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT) |
| 156 | // Add serial implementation for RGB here | 162 | // Update RGB config with the new data |
| 163 | rgblight_update_dword(serial_m2s_buffer.rgblight_config.raw); | ||
| 157 | # endif | 164 | # endif |
| 158 | } | 165 | } |
| 159 | 166 | ||
