aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi ISHII <2170248+mtei@users.noreply.github.com>2019-04-20 07:25:08 +0900
committerDrashna Jaelre <drashna@live.com>2019-04-19 15:25:08 -0700
commit7e67bd791b1804e1e362d8c1e90232440c274cee (patch)
tree625d0f867d59380de6b48df5e8b2e2f832856cfe
parentdfab177f889fd6701e5f898c869be1bf3a2d0ef9 (diff)
downloadqmk_firmware-7e67bd791b1804e1e362d8c1e90232440c274cee.tar.gz
qmk_firmware-7e67bd791b1804e1e362d8c1e90232440c274cee.zip
Change split_common to use RGBLIGHT_SPLIT (#5509)
* add I2C_slave_buffer_t to quantum/split_common/transport.c Improvements to ease the maintenance of the I2C slave buffer layout. And this commit does not change the compilation results. * add temporary pdhelix(Patched Helix) code * temporary cherry-pick from #5020 add new version(#5020) quantum/rgblight.[ch], quantum/rgblight_modes.h * add post_config.h support to build_keyboard.mk * add quantum/rgblight_post_config.h, quantum/split_common/post_config.h Add quantum/rgblight_post_config.h and quantum/split_common/post_config.h using POST_CONFIG_H variable of build_keyboard.mk. quantum/rgblight_post_config.h additionally defines RGBLIGHT_SPLIT if RGBLED_SPIT is defined. quantum/split_common/post_config.h defines RGBLIGHT_SPLIT additionally when master-slave communication is I2C. * Change split_common's transport.c I2C to use the synchronization feature of rgblight.c * Change split_common's transport.c serial to use the synchronization feature of rgblight.c * test RGBLIGHT_SPLIT on keyboards/handwired/pdhelix * Test End Revert "test RGBLIGHT_SPLIT on keyboards/handwired/pdhelix" This reverts commit 80118a6bbd3d9fc4c7797fef0c34bc67aa73aa98. [x] make RGBLIGHT_TEST=1 handwired/pdhelix/i2c:default [x] make RGBLIGHT_TEST=2 handwired/pdhelix/i2c:default (same RGBLIGHT_TEST=3) [x] make RGBLIGHT_TEST=3 handwired/pdhelix/i2c:default [x] make RGBLIGHT_TEST=1 handwired/pdhelix/pd2:default [x] make RGBLIGHT_TEST=2 handwired/pdhelix/pd2:default [x] make RGBLIGHT_TEST=3 handwired/pdhelix/pd2:default [x] make RGBLIGHT_TEST=1 handwired/pdhelix/pd2_2oled:default [x] make RGBLIGHT_TEST=2 handwired/pdhelix/pd2_2oled:default [x] make RGBLIGHT_TEST=3 handwired/pdhelix/pd2_2oled:default * Test End, Revert "temporary cherry-pick from #5020" This reverts commit d35069f68bda0c50370442a5c7aae60c2f4ce5c0. * Test End, Revert "add temporary pdhelix(Patched Helix) code" This reverts commit aebddfc1a879796afae297ef0723a4fe73af3660. * temporarily cherry-pick from #5020 to see if it passes the travis-ci test. add new version(#5020) quantum/rgblight.[ch], quantum/rgblight_modes.h * Passed the travis-ci test. Revert "temporarily cherry-pick from #5020 to see if it passes the travis-ci test." This reverts commit 647c0a9755eb6a05f76d09b2d59bce67b85a841f. * update docs/config_options.md * update split_common/transport.c, improves maintainability of serial transaction IDs. No change in build result. * temporary cherry-pick from #5020 * fix build fail keebio/iris/rev3:default * fix build fail lets_split_eh/eh:default * Revert "temporary cherry-pick from #5020" This reverts commit be48ca1b4515366a097af8dd1cd7b28b7ee09947. * temporary cherry-pick from #5020 (0.6.336) * Revert "temporary cherry-pick from #5020 (0.6.336)" This reverts commit 978d26a8b3cf0acc485838a7d76d6128b77c630c. * temporary cherry-pick from #5020 (0.6.336)
-rw-r--r--build_keyboard.mk18
-rw-r--r--common_features.mk2
-rw-r--r--docs/config_options.md4
-rw-r--r--quantum/rgblight_post_config.h5
-rw-r--r--quantum/split_common/post_config.h15
-rw-r--r--quantum/split_common/transport.c184
6 files changed, 153 insertions, 75 deletions
diff --git a/build_keyboard.mk b/build_keyboard.mk
index ee6a69fc7..5d633f271 100644
--- a/build_keyboard.mk
+++ b/build_keyboard.mk
@@ -280,6 +280,23 @@ ifneq ("$(wildcard $(KEYBOARD_PATH_1)/config.h)","")
280 CONFIG_H += $(KEYBOARD_PATH_1)/config.h 280 CONFIG_H += $(KEYBOARD_PATH_1)/config.h
281endif 281endif
282 282
283POST_CONFIG_H :=
284ifneq ("$(wildcard $(KEYBOARD_PATH_1)/post_config.h)","")
285 POST_CONFIG_H += $(KEYBOARD_PATH_1)/post_config.h
286endif
287ifneq ("$(wildcard $(KEYBOARD_PATH_2)/post_config.h)","")
288 POST_CONFIG_H += $(KEYBOARD_PATH_2)/post_config.h
289endif
290ifneq ("$(wildcard $(KEYBOARD_PATH_3)/post_config.h)","")
291 POST_CONFIG_H += $(KEYBOARD_PATH_3)/post_config.h
292endif
293ifneq ("$(wildcard $(KEYBOARD_PATH_4)/post_config.h)","")
294 POST_CONFIG_H += $(KEYBOARD_PATH_4)/post_config.h
295endif
296ifneq ("$(wildcard $(KEYBOARD_PATH_5)/post_config.h)","")
297 POST_CONFIG_H += $(KEYBOARD_PATH_5)/post_config.h
298endif
299
283# Save the defines and includes here, so we don't include any keymap specific ones 300# Save the defines and includes here, so we don't include any keymap specific ones
284PROJECT_DEFS := $(OPT_DEFS) 301PROJECT_DEFS := $(OPT_DEFS)
285PROJECT_INC := $(VPATH) $(EXTRAINCDIRS) $(KEYBOARD_PATHS) 302PROJECT_INC := $(VPATH) $(EXTRAINCDIRS) $(KEYBOARD_PATHS)
@@ -355,6 +372,7 @@ ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
355 include $(VISUALIZER_PATH)/visualizer.mk 372 include $(VISUALIZER_PATH)/visualizer.mk
356endif 373endif
357 374
375CONFIG_H += $(POST_CONFIG_H)
358ALL_CONFIGS := $(PROJECT_CONFIG) $(CONFIG_H) 376ALL_CONFIGS := $(PROJECT_CONFIG) $(CONFIG_H)
359 377
360OUTPUTS := $(KEYMAP_OUTPUT) $(KEYBOARD_OUTPUT) 378OUTPUTS := $(KEYMAP_OUTPUT) $(KEYBOARD_OUTPUT)
diff --git a/common_features.mk b/common_features.mk
index bd1685869..eb623d18f 100644
--- a/common_features.mk
+++ b/common_features.mk
@@ -103,6 +103,7 @@ ifeq ($(strip $(UNICODE_COMMON)), yes)
103endif 103endif
104 104
105ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) 105ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
106 POST_CONFIG_H += $(QUANTUM_DIR)/rgblight_post_config.h
106 OPT_DEFS += -DRGBLIGHT_ENABLE 107 OPT_DEFS += -DRGBLIGHT_ENABLE
107 SRC += $(QUANTUM_DIR)/rgblight.c 108 SRC += $(QUANTUM_DIR)/rgblight.c
108 CIE1931_CURVE = yes 109 CIE1931_CURVE = yes
@@ -318,6 +319,7 @@ ifneq ($(strip $(DEBOUNCE_TYPE)), custom)
318endif 319endif
319 320
320ifeq ($(strip $(SPLIT_KEYBOARD)), yes) 321ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
322 POST_CONFIG_H += $(QUANTUM_DIR)/split_common/post_config.h
321 OPT_DEFS += -DSPLIT_KEYBOARD 323 OPT_DEFS += -DSPLIT_KEYBOARD
322 324
323 # Include files used by all split keyboards 325 # Include files used by all split keyboards
diff --git a/docs/config_options.md b/docs/config_options.md
index bc2a89058..8f229a2cb 100644
--- a/docs/config_options.md
+++ b/docs/config_options.md
@@ -180,10 +180,12 @@ If you define these options you will enable the associated feature, which may in
180 * run RGB animations 180 * run RGB animations
181* `#define RGBLED_NUM 12` 181* `#define RGBLED_NUM 12`
182 * number of LEDs 182 * number of LEDs
183* `#define RGBLIGHT_SPLIT`
184 * Needed if both halves of the board have RGB LEDs wired directly to the RGB output pin on the controllers instead of passing the output of the left half to the input of the right half
183* `#define RGBLED_SPLIT { 6, 6 }` 185* `#define RGBLED_SPLIT { 6, 6 }`
184 * number of LEDs connected that are directly wired to `RGB_DI_PIN` on each half of a split keyboard 186 * number of LEDs connected that are directly wired to `RGB_DI_PIN` on each half of a split keyboard
185 * First value indicates number of LEDs for left half, second value is for the right half 187 * First value indicates number of LEDs for left half, second value is for the right half
186 * Needed if both halves of the board have RGB LEDs wired directly to the RGB output pin on the controllers instead of passing the output of the left half to the input of the right half 188 * When RGBLED_SPLIT is defined, RGBLIGHT_SPLIT is implicitly defined.
187* `#define RGBLIGHT_HUE_STEP 12` 189* `#define RGBLIGHT_HUE_STEP 12`
188 * units to step when in/decreasing hue 190 * units to step when in/decreasing hue
189* `#define RGBLIGHT_SAT_STEP 25` 191* `#define RGBLIGHT_SAT_STEP 25`
diff --git a/quantum/rgblight_post_config.h b/quantum/rgblight_post_config.h
new file mode 100644
index 000000000..048746c4b
--- /dev/null
+++ b/quantum/rgblight_post_config.h
@@ -0,0 +1,5 @@
1#if defined(RGBLED_SPLIT) && !defined(RGBLIGHT_SPLIT)
2 // When RGBLED_SPLIT is defined,
3 // it is considered that RGBLIGHT_SPLIT is defined implicitly.
4 #define RGBLIGHT_SPLIT
5#endif
diff --git a/quantum/split_common/post_config.h b/quantum/split_common/post_config.h
new file mode 100644
index 000000000..0e59df3d0
--- /dev/null
+++ b/quantum/split_common/post_config.h
@@ -0,0 +1,15 @@
1#if defined(USE_I2C) || defined(EH)
2 // When using I2C, using rgblight implicitly involves split support.
3 #if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_SPLIT)
4 #define RGBLIGHT_SPLIT
5 #endif
6
7#else // use serial
8 // When using serial, the user must define RGBLIGHT_SPLIT explicitly
9 // in config.h as needed.
10 // see quantum/rgblight_post_config.h
11 #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
12 // When using serial and RGBLIGHT_SPLIT need separate transaction
13 #define SERIAL_USE_MULTI_TRANSACTION
14 #endif
15#endif
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c
index ab055ee65..7ea1a9cec 100644
--- a/quantum/split_common/transport.c
+++ b/quantum/split_common/transport.c
@@ -25,36 +25,23 @@ extern backlight_config_t backlight_config;
25# include "i2c_master.h" 25# include "i2c_master.h"
26# include "i2c_slave.h" 26# include "i2c_slave.h"
27 27
28typedef struct __attribute__ ((__packed__)) { 28typedef struct _I2C_slave_buffer_t {
29#ifdef BACKLIGHT_ENABLE 29 matrix_row_t smatrix[ROWS_PER_HAND];
30 uint8_t backlight_level; 30 uint8_t backlight_level;
31#endif 31#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
32#ifdef RGBLIGHT_ENABLE 32 rgblight_syncinfo_t rgblight_sync;
33 uint32_t rgb_settings;
34#endif 33#endif
35#ifdef ENCODER_ENABLE 34#ifdef ENCODER_ENABLE
36 uint8_t encoder_state[NUMBER_OF_ENCODERS]; 35 uint8_t encoder_state[NUMBER_OF_ENCODERS];
37#endif
38 // Keep matrix last, we are only using this for it's offset
39 uint8_t matrix_start[0];
40} transport_values_t;
41
42__attribute__ ((unused))
43static transport_values_t transport_values;
44
45#ifdef BACKLIGHT_ENABLE
46# define I2C_BACKLIT_START (uint8_t)offsetof(transport_values_t, backlight_level)
47#endif
48
49#ifdef RGBLIGHT_ENABLE
50# define I2C_RGB_START (uint8_t)offsetof(transport_values_t, rgb_settings)
51#endif 36#endif
37} I2C_slave_buffer_t;
52 38
53#ifdef ENCODER_ENABLE 39static I2C_slave_buffer_t * const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg;
54# define I2C_ENCODER_START (uint8_t)offsetof(transport_values_t, encoder_state)
55#endif
56 40
57#define I2C_KEYMAP_START (uint8_t)offsetof(transport_values_t, matrix_start) 41# define I2C_BACKLIGHT_START offsetof(I2C_slave_buffer_t, backlight_level)
42# define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync)
43# define I2C_KEYMAP_START offsetof(I2C_slave_buffer_t, smatrix)
44# define I2C_ENCODER_START offsetof(I2C_slave_buffer_t, encoder_state)
58 45
59# define TIMEOUT 100 46# define TIMEOUT 100
60 47
@@ -64,30 +51,32 @@ static transport_values_t transport_values;
64 51
65// Get rows from other half over i2c 52// Get rows from other half over i2c
66bool transport_master(matrix_row_t matrix[]) { 53bool transport_master(matrix_row_t matrix[]) {
67 i2c_readReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_START, (void *)matrix, ROWS_PER_HAND * sizeof(matrix_row_t), TIMEOUT); 54 i2c_readReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_START, (void *)matrix, sizeof(i2c_buffer->smatrix), TIMEOUT);
68 55
69 // write backlight info 56 // write backlight info
70# ifdef BACKLIGHT_ENABLE 57# ifdef BACKLIGHT_ENABLE
71 uint8_t level = get_backlight_level(); 58 uint8_t level = get_backlight_level();
72 if (level != transport_values.backlight_level) { 59 if (level != i2c_buffer->backlight_level) {
73 if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_BACKLIT_START, (void *)&level, sizeof(level), TIMEOUT) >= 0) { 60 if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_BACKLIGHT_START, (void *)&level, sizeof(level), TIMEOUT) >= 0) {
74 transport_values.backlight_level = level; 61 i2c_buffer->backlight_level = level;
75 } 62 }
76 } 63 }
77# endif 64# endif
78 65
79# ifdef RGBLIGHT_ENABLE 66# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
80 uint32_t rgb = rgblight_read_dword(); 67 if (rgblight_get_change_flags()) {
81 if (rgb != transport_values.rgb_settings) { 68 rgblight_syncinfo_t rgblight_sync;
82 if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_START, (void *)&rgb, sizeof(rgb), TIMEOUT) >= 0) { 69 rgblight_get_syncinfo(&rgblight_sync);
83 transport_values.rgb_settings = rgb; 70 if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_START,
71 (void *)&rgblight_sync, sizeof(rgblight_sync), TIMEOUT) >= 0) {
72 rgblight_clear_change_flags();
84 } 73 }
85 } 74 }
86# endif 75# endif
87 76
88# ifdef ENCODER_ENABLE 77# ifdef ENCODER_ENABLE
89 i2c_readReg(SLAVE_I2C_ADDRESS, I2C_ENCODER_START, (void *)transport_values.encoder_state, sizeof(transport_values.encoder_state), TIMEOUT); 78 i2c_readReg(SLAVE_I2C_ADDRESS, I2C_ENCODER_START, (void *)i2c_buffer->encoder_state, sizeof(I2C_slave_buffer_t.encoder_state), TIMEOUT);
90 encoder_update_raw(&transport_values.encoder_state[0]); 79 encoder_update_raw(i2c_buffer->encoder_state);
91# endif 80# endif
92 81
93 return true; 82 return true;
@@ -95,21 +84,23 @@ bool transport_master(matrix_row_t matrix[]) {
95 84
96void transport_slave(matrix_row_t matrix[]) { 85void transport_slave(matrix_row_t matrix[]) {
97 // Copy matrix to I2C buffer 86 // Copy matrix to I2C buffer
98 memcpy((void*)(i2c_slave_reg + I2C_KEYMAP_START), (void *)matrix, ROWS_PER_HAND * sizeof(matrix_row_t) ); 87 memcpy((void*)i2c_buffer->smatrix, (void *)matrix, sizeof(i2c_buffer->smatrix));
99 88
100// Read Backlight Info 89// Read Backlight Info
101# ifdef BACKLIGHT_ENABLE 90# ifdef BACKLIGHT_ENABLE
102 backlight_set(i2c_slave_reg[I2C_BACKLIT_START]); 91 backlight_set(i2c_buffer->backlight_level);
103# endif 92# endif
104 93
105# ifdef RGBLIGHT_ENABLE 94# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
106 uint32_t rgb = *(uint32_t *)(i2c_slave_reg + I2C_RGB_START);
107 // Update the RGB with the new data 95 // Update the RGB with the new data
108 rgblight_update_dword(rgb); 96 if (i2c_buffer->rgblight_sync.status.change_flags != 0) {
97 rgblight_update_sync(&i2c_buffer->rgblight_sync, false);
98 i2c_buffer->rgblight_sync.status.change_flags = 0;
99 }
109# endif 100# endif
110 101
111# ifdef ENCODER_ENABLE 102# ifdef ENCODER_ENABLE
112 encoder_state_raw((uint8_t*)(i2c_slave_reg + I2C_ENCODER_START)); 103 encoder_state_raw(i2c_buffer->encoder_state);
113# endif 104# endif
114} 105}
115 106
@@ -121,53 +112,109 @@ void transport_slave_init(void) { i2c_slave_init(SLAVE_I2C_ADDRESS); }
121 112
122# include "serial.h" 113# include "serial.h"
123 114
124typedef struct __attribute__ ((__packed__)) { 115typedef struct _Serial_s2m_buffer_t {
116 // TODO: if MATRIX_COLS > 8 change to uint8_t packed_matrix[] for pack/unpack
117 matrix_row_t smatrix[ROWS_PER_HAND];
118
125# ifdef ENCODER_ENABLE 119# ifdef ENCODER_ENABLE
126 uint8_t encoder_state[NUMBER_OF_ENCODERS]; 120 uint8_t encoder_state[NUMBER_OF_ENCODERS];
127# endif 121# endif
128 // TODO: if MATRIX_COLS > 8 change to uint8_t packed_matrix[] for pack/unpack 122
129 matrix_row_t smatrix[ROWS_PER_HAND];
130} Serial_s2m_buffer_t; 123} Serial_s2m_buffer_t;
131 124
132typedef struct __attribute__ ((__packed__)) { 125typedef struct _Serial_m2s_buffer_t {
133# ifdef BACKLIGHT_ENABLE 126# ifdef BACKLIGHT_ENABLE
134 uint8_t backlight_level; 127 uint8_t backlight_level;
135# endif 128# endif
136# if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT)
137 rgblight_config_t rgblight_config; // not yet use
138 //
139 // When MCUs on both sides drive their respective RGB LED chains,
140 // it is necessary to synchronize, so it is necessary to communicate RGB
141 // information. In that case, define RGBLED_SPLIT with info on the number
142 // of LEDs on each half.
143 //
144 // Otherwise, if the master side MCU drives both sides RGB LED chains,
145 // there is no need to communicate.
146# endif
147} Serial_m2s_buffer_t; 129} Serial_m2s_buffer_t;
148 130
131#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
132// When MCUs on both sides drive their respective RGB LED chains,
133// it is necessary to synchronize, so it is necessary to communicate RGB
134// information. In that case, define RGBLIGHT_SPLIT with info on the number
135// of LEDs on each half.
136//
137// Otherwise, if the master side MCU drives both sides RGB LED chains,
138// there is no need to communicate.
139
140typedef struct _Serial_rgblight_t {
141 rgblight_syncinfo_t rgblight_sync;
142} Serial_rgblight_t;
143
144volatile Serial_rgblight_t serial_rgblight = {};
145uint8_t volatile status_rgblight = 0;
146#endif
147
149volatile Serial_s2m_buffer_t serial_s2m_buffer = {}; 148volatile Serial_s2m_buffer_t serial_s2m_buffer = {};
150volatile Serial_m2s_buffer_t serial_m2s_buffer = {}; 149volatile Serial_m2s_buffer_t serial_m2s_buffer = {};
151uint8_t volatile status0 = 0; 150uint8_t volatile status0 = 0;
152 151
152enum serial_transaction_id {
153 GET_SLAVE_MATRIX = 0,
154#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
155 PUT_RGBLIGHT,
156#endif
157};
158
153SSTD_t transactions[] = { 159SSTD_t transactions[] = {
154 { 160 [GET_SLAVE_MATRIX] = {
155 (uint8_t *)&status0, 161 (uint8_t *)&status0,
156 sizeof(serial_m2s_buffer), 162 sizeof(serial_m2s_buffer),
157 (uint8_t *)&serial_m2s_buffer, 163 (uint8_t *)&serial_m2s_buffer,
158 sizeof(serial_s2m_buffer), 164 sizeof(serial_s2m_buffer),
159 (uint8_t *)&serial_s2m_buffer, 165 (uint8_t *)&serial_s2m_buffer,
160 }, 166 },
167#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
168 [PUT_RGBLIGHT] = {
169 (uint8_t *)&status_rgblight,
170 sizeof(serial_rgblight),
171 (uint8_t *)&serial_rgblight,
172 0, NULL // no slave to master transfer
173 },
174#endif
161}; 175};
162 176
163void transport_master_init(void) { soft_serial_initiator_init(transactions, TID_LIMIT(transactions)); } 177void transport_master_init(void) { soft_serial_initiator_init(transactions, TID_LIMIT(transactions)); }
164 178
165void transport_slave_init(void) { soft_serial_target_init(transactions, TID_LIMIT(transactions)); } 179void transport_slave_init(void) { soft_serial_target_init(transactions, TID_LIMIT(transactions)); }
166 180
181#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
182
183// rgblight synchronization information communication.
184
185void transport_rgblight_master(void) {
186 if (rgblight_get_change_flags()) {
187 rgblight_get_syncinfo((rgblight_syncinfo_t *)&serial_rgblight.rgblight_sync);
188 if (soft_serial_transaction(PUT_RGBLIGHT) == TRANSACTION_END) {
189 rgblight_clear_change_flags();
190 }
191 }
192}
193
194void transport_rgblight_slave(void) {
195 if (status_rgblight == TRANSACTION_ACCEPTED) {
196 rgblight_update_sync((rgblight_syncinfo_t *)&serial_rgblight.rgblight_sync,
197 false);
198 status_rgblight = TRANSACTION_END;
199 }
200}
201
202#else
203#define transport_rgblight_master()
204#define transport_rgblight_slave()
205#endif
206
167bool transport_master(matrix_row_t matrix[]) { 207bool transport_master(matrix_row_t matrix[]) {
168 if (soft_serial_transaction()) { 208#ifndef SERIAL_USE_MULTI_TRANSACTION
209 if (soft_serial_transaction() != TRANSACTION_END) {
169 return false; 210 return false;
170 } 211 }
212#else
213 transport_rgblight_master();
214 if (soft_serial_transaction(GET_SLAVE_MATRIX) != TRANSACTION_END) {
215 return false;
216 }
217#endif
171 218
172 // TODO: if MATRIX_COLS > 8 change to unpack() 219 // TODO: if MATRIX_COLS > 8 change to unpack()
173 for (int i = 0; i < ROWS_PER_HAND; ++i) { 220 for (int i = 0; i < ROWS_PER_HAND; ++i) {
@@ -179,23 +226,15 @@ bool transport_master(matrix_row_t matrix[]) {
179 serial_m2s_buffer.backlight_level = backlight_config.enable ? backlight_config.level : 0; 226 serial_m2s_buffer.backlight_level = backlight_config.enable ? backlight_config.level : 0;
180# endif 227# endif
181 228
182# if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT)
183 static rgblight_config_t prev_rgb = {~0};
184 uint32_t rgb = rgblight_read_dword();
185 if (rgb != prev_rgb.raw) {
186 serial_m2s_buffer.rgblight_config.raw = rgb;
187 prev_rgb.raw = rgb;
188 }
189# endif
190
191# ifdef ENCODER_ENABLE 229# ifdef ENCODER_ENABLE
192 encoder_update_raw((uint8_t*)&serial_s2m_buffer.encoder_state); 230 encoder_update_raw((uint8_t *)serial_s2m_buffer.encoder_state);
193# endif 231# endif
194 232
195 return true; 233 return true;
196} 234}
197 235
198void transport_slave(matrix_row_t matrix[]) { 236void transport_slave(matrix_row_t matrix[]) {
237 transport_rgblight_slave();
199 // TODO: if MATRIX_COLS > 8 change to pack() 238 // TODO: if MATRIX_COLS > 8 change to pack()
200 for (int i = 0; i < ROWS_PER_HAND; ++i) { 239 for (int i = 0; i < ROWS_PER_HAND; ++i) {
201 serial_s2m_buffer.smatrix[i] = matrix[i]; 240 serial_s2m_buffer.smatrix[i] = matrix[i];
@@ -203,14 +242,11 @@ void transport_slave(matrix_row_t matrix[]) {
203# ifdef BACKLIGHT_ENABLE 242# ifdef BACKLIGHT_ENABLE
204 backlight_set(serial_m2s_buffer.backlight_level); 243 backlight_set(serial_m2s_buffer.backlight_level);
205# endif 244# endif
206# if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT)
207 // Update RGB config with the new data
208 rgblight_update_dword(serial_m2s_buffer.rgblight_config.raw);
209# endif
210 245
211# ifdef ENCODER_ENABLE 246# ifdef ENCODER_ENABLE
212 encoder_state_raw((uint8_t*)&serial_s2m_buffer.encoder_state); 247 encoder_state_raw((uint8_t *)serial_s2m_buffer.encoder_state);
213# endif 248# endif
249
214} 250}
215 251
216#endif 252#endif