From 79d1db332477963555416d9fff82ecac4399bd52 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Tue, 12 Jan 2021 19:48:24 +1100 Subject: Keep track of last matrix activity (#10730) * Allow recording of the last matrix activity time, to simplify implementation of display timeouts and the like. * Add requested changes from code review. * Simplify split matrix last changed. --- quantum/split_common/matrix.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'quantum/split_common/matrix.c') diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c index 51bf8b1095..06bab734e7 100644 --- a/quantum/split_common/matrix.c +++ b/quantum/split_common/matrix.c @@ -245,48 +245,59 @@ void matrix_init(void) { split_post_init(); } -void matrix_post_scan(void) { +bool matrix_post_scan(void) { + bool changed = false; if (is_keyboard_master()) { static uint8_t error_count; - if (!transport_master(matrix + thatHand)) { + matrix_row_t slave_matrix[ROWS_PER_HAND] = {0}; + if (!transport_master(slave_matrix)) { error_count++; if (error_count > ERROR_DISCONNECT_COUNT) { // reset other half if disconnected for (int i = 0; i < ROWS_PER_HAND; ++i) { - matrix[thatHand + i] = 0; + slave_matrix[i] = 0; } } } else { error_count = 0; } + for (int i = 0; i < ROWS_PER_HAND; ++i) { + if (matrix[thatHand + i] != slave_matrix[i]) { + matrix[thatHand + i] = slave_matrix[i]; + changed = true; + } + } + matrix_scan_quantum(); } else { transport_slave(matrix + thisHand); matrix_slave_scan_user(); } + + return changed; } uint8_t matrix_scan(void) { - bool changed = false; + bool local_changed = false; #if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW) // Set row, read cols for (uint8_t current_row = 0; current_row < ROWS_PER_HAND; current_row++) { - changed |= read_cols_on_row(raw_matrix, current_row); + local_changed |= read_cols_on_row(raw_matrix, current_row); } #elif (DIODE_DIRECTION == ROW2COL) // Set col, read rows for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { - changed |= read_rows_on_col(raw_matrix, current_col); + local_changed |= read_rows_on_col(raw_matrix, current_col); } #endif - debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, changed); + debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, local_changed); - matrix_post_scan(); - return (uint8_t)changed; + bool remote_changed = matrix_post_scan(); + return (uint8_t)(local_changed || remote_changed); } -- cgit v1.2.3 From 302b35c2a0ac90208e523944e8cc4b44a793d8d5 Mon Sep 17 00:00:00 2001 From: Takeshi ISHII <2170248+mtei@users.noreply.github.com> Date: Wed, 13 Jan 2021 10:46:22 +0900 Subject: fix matrix_io_delay() timing in quantum/matrix.c (#9603) * fix matrix_io_delay() timing in quantum/matrix.c * Updated comments explaining the need for matrix_io_delay() in quantum/matrix.c * fix matrix_io_delay() timing in quantum/split_common/matrix.c * Update quantum/matrix.c Co-authored-by: Ryan * Update quantum/split_common/matrix.c Co-authored-by: Ryan * Update quantum/matrix.c Co-authored-by: Ryan * Update quantum/split_common/matrix.c Co-authored-by: Ryan * add waitOutputPinValid() and wait_cpuclock() into quantum/quantum.h and tmk_core/common/wait.h * add matrix_output_select_delay() and matrix_output_unselect_delay() * fix quantum/matrix_common.c, tmk_core/common/matrix.h * fix tmk_core/common/wait.h * fix quantum/quantum.h, tmk_core/common/wait.h * waitOutputPinValid() rename to waitInputPinDelay() in quantum/quantum.h. * waitOutputPinValid() rename to waitInputPinDelay() in quantum/matrix_common.c * update tmk_core/common/wait.h * update comment in quantum/matrix.c, quantum/split_common/matrix.c * update quantum/quantum.h: Make more margin in the GPIO_INPUT_PIN_DELAY default value. Co-authored-by: Ryan --- quantum/split_common/matrix.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'quantum/split_common/matrix.c') diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c index 06bab734e7..067815c991 100644 --- a/quantum/split_common/matrix.c +++ b/quantum/split_common/matrix.c @@ -114,9 +114,9 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) // Start with a clear matrix row matrix_row_t current_row_value = 0; - // Select row and wait for row selecton to stabilize + // Select row select_row(current_row); - matrix_io_delay(); + matrix_output_select_delay(); // For each col... for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) { @@ -129,6 +129,9 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) // Unselect row unselect_row(current_row); + if (current_row + 1 < MATRIX_ROWS) { + matrix_output_unselect_delay(); // wait for row signal to go HIGH + } // If the row has changed, store the row and return the changed flag. if (current_matrix[current_row] != current_row_value) { @@ -160,9 +163,9 @@ static void init_pins(void) { static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) { bool matrix_changed = false; - // Select col and wait for col selecton to stabilize + // Select col select_col(current_col); - matrix_io_delay(); + matrix_output_select_delay(); // For each row... for (uint8_t row_index = 0; row_index < ROWS_PER_HAND; row_index++) { @@ -188,6 +191,9 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) // Unselect col unselect_col(current_col); + if (current_col + 1 < MATRIX_COLS) { + matrix_output_unselect_delay(); // wait for col signal to go HIGH + } return matrix_changed; } -- cgit v1.2.3 From ab375d3d075c105f09a1ddd0e155f178225518bc Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Fri, 15 Jan 2021 06:55:07 +1100 Subject: Revert "Keep track of last matrix activity (#10730)" This reverts commit 79d1db332477963555416d9fff82ecac4399bd52. --- quantum/split_common/matrix.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) (limited to 'quantum/split_common/matrix.c') diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c index 067815c991..22ff89bfc6 100644 --- a/quantum/split_common/matrix.c +++ b/quantum/split_common/matrix.c @@ -251,59 +251,48 @@ void matrix_init(void) { split_post_init(); } -bool matrix_post_scan(void) { - bool changed = false; +void matrix_post_scan(void) { if (is_keyboard_master()) { static uint8_t error_count; - matrix_row_t slave_matrix[ROWS_PER_HAND] = {0}; - if (!transport_master(slave_matrix)) { + if (!transport_master(matrix + thatHand)) { error_count++; if (error_count > ERROR_DISCONNECT_COUNT) { // reset other half if disconnected for (int i = 0; i < ROWS_PER_HAND; ++i) { - slave_matrix[i] = 0; + matrix[thatHand + i] = 0; } } } else { error_count = 0; } - for (int i = 0; i < ROWS_PER_HAND; ++i) { - if (matrix[thatHand + i] != slave_matrix[i]) { - matrix[thatHand + i] = slave_matrix[i]; - changed = true; - } - } - matrix_scan_quantum(); } else { transport_slave(matrix + thisHand); matrix_slave_scan_user(); } - - return changed; } uint8_t matrix_scan(void) { - bool local_changed = false; + bool changed = false; #if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW) // Set row, read cols for (uint8_t current_row = 0; current_row < ROWS_PER_HAND; current_row++) { - local_changed |= read_cols_on_row(raw_matrix, current_row); + changed |= read_cols_on_row(raw_matrix, current_row); } #elif (DIODE_DIRECTION == ROW2COL) // Set col, read rows for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { - local_changed |= read_rows_on_col(raw_matrix, current_col); + changed |= read_rows_on_col(raw_matrix, current_col); } #endif - debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, local_changed); + debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, changed); - bool remote_changed = matrix_post_scan(); - return (uint8_t)(local_changed || remote_changed); + matrix_post_scan(); + return (uint8_t)changed; } -- cgit v1.2.3 From e702c7f1b4cfa8fe1579498ef2877994baa64056 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Mon, 18 Jan 2021 05:01:38 +1100 Subject: Keep track of last matrix activity. (#11552) Co-authored-by: Dasky Co-authored-by: Dasky --- quantum/split_common/matrix.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'quantum/split_common/matrix.c') diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c index 22ff89bfc6..631e960ead 100644 --- a/quantum/split_common/matrix.c +++ b/quantum/split_common/matrix.c @@ -251,21 +251,33 @@ void matrix_init(void) { split_post_init(); } -void matrix_post_scan(void) { +bool matrix_post_scan(void) { + bool changed = false; if (is_keyboard_master()) { static uint8_t error_count; - if (!transport_master(matrix + thatHand)) { + matrix_row_t slave_matrix[ROWS_PER_HAND] = {0}; + if (!transport_master(slave_matrix)) { error_count++; if (error_count > ERROR_DISCONNECT_COUNT) { // reset other half if disconnected for (int i = 0; i < ROWS_PER_HAND; ++i) { matrix[thatHand + i] = 0; + slave_matrix[i] = 0; } + + changed = true; } } else { error_count = 0; + + for (int i = 0; i < ROWS_PER_HAND; ++i) { + if (matrix[thatHand + i] != slave_matrix[i]) { + matrix[thatHand + i] = slave_matrix[i]; + changed = true; + } + } } matrix_scan_quantum(); @@ -274,25 +286,27 @@ void matrix_post_scan(void) { matrix_slave_scan_user(); } + + return changed; } uint8_t matrix_scan(void) { - bool changed = false; + bool local_changed = false; #if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW) // Set row, read cols for (uint8_t current_row = 0; current_row < ROWS_PER_HAND; current_row++) { - changed |= read_cols_on_row(raw_matrix, current_row); + local_changed |= read_cols_on_row(raw_matrix, current_row); } #elif (DIODE_DIRECTION == ROW2COL) // Set col, read rows for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { - changed |= read_rows_on_col(raw_matrix, current_col); + local_changed |= read_rows_on_col(raw_matrix, current_col); } #endif - debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, changed); + debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, local_changed); - matrix_post_scan(); - return (uint8_t)changed; + bool remote_changed = matrix_post_scan(); + return (uint8_t)(local_changed || remote_changed); } -- cgit v1.2.3 From 31c57aab35e6fd49c4c8336f449419afe7630e93 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Mon, 18 Jan 2021 05:12:15 +1100 Subject: `qmk cformat` --- quantum/split_common/matrix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quantum/split_common/matrix.c') diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c index 631e960ead..bad762b493 100644 --- a/quantum/split_common/matrix.c +++ b/quantum/split_common/matrix.c @@ -264,7 +264,7 @@ bool matrix_post_scan(void) { // reset other half if disconnected for (int i = 0; i < ROWS_PER_HAND; ++i) { matrix[thatHand + i] = 0; - slave_matrix[i] = 0; + slave_matrix[i] = 0; } changed = true; -- cgit v1.2.3 From d1806a26e4ad75fa0e0405283803eba22c1a49ba Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Mon, 15 Feb 2021 18:30:33 -0600 Subject: Split transport mirror (#11046) * Split transport mirror support * Updated RGB Matrix to respond to electrical events instead of key events * split matrix slave fix --- quantum/split_common/matrix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'quantum/split_common/matrix.c') diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c index bad762b493..d6636b886a 100644 --- a/quantum/split_common/matrix.c +++ b/quantum/split_common/matrix.c @@ -257,7 +257,7 @@ bool matrix_post_scan(void) { static uint8_t error_count; matrix_row_t slave_matrix[ROWS_PER_HAND] = {0}; - if (!transport_master(slave_matrix)) { + if (!transport_master(matrix + thisHand, slave_matrix)) { error_count++; if (error_count > ERROR_DISCONNECT_COUNT) { @@ -282,7 +282,7 @@ bool matrix_post_scan(void) { matrix_scan_quantum(); } else { - transport_slave(matrix + thisHand); + transport_slave(matrix + thatHand, matrix + thisHand); matrix_slave_scan_user(); } -- cgit v1.2.3