diff options
Diffstat (limited to 'quantum/split_common')
-rw-r--r-- | quantum/split_common/split_util.c | 32 | ||||
-rw-r--r-- | quantum/split_common/transport.c | 23 |
2 files changed, 36 insertions, 19 deletions
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 | ||