summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2020-02-21 03:49:33 +0000
committerDrashna Jael're <drashna@live.com>2020-03-26 00:42:12 -0700
commit583bd29a60abf3e6b94a258e1f7dfa2e63a47bdc (patch)
tree55dacbaeaee370d14f212ad17f2e1e45b3aab144
parent31d15910e7e0ca75a055c9de498bddf7e96d6cc0 (diff)
Allow 30us matrix delay to be keyboard/user overridable (#8216)
* Allow 30us matrix delay to be configurable via define * Move wait logic to matrix_common * Move wait logic to matrix_common - fix wait includes
-rw-r--r--quantum/matrix.c5
-rw-r--r--quantum/matrix_common.c7
-rw-r--r--quantum/split_common/matrix.c5
-rw-r--r--tmk_core/common/matrix.h2
4 files changed, 13 insertions, 6 deletions
diff --git a/quantum/matrix.c b/quantum/matrix.c
index 6bd604bb79..67d8af6ee8 100644
--- a/quantum/matrix.c
+++ b/quantum/matrix.c
@@ -16,7 +16,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdbool.h>
-#include "wait.h"
#include "util.h"
#include "matrix.h"
#include "debounce.h"
@@ -94,7 +93,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
// Select row and wait for row selecton to stabilize
select_row(current_row);
- wait_us(30);
+ matrix_io_delay();
// For each col...
for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
@@ -138,7 +137,7 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
// Select col and wait for col selecton to stabilize
select_col(current_col);
- wait_us(30);
+ matrix_io_delay();
// For each row...
for (uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) {
diff --git a/quantum/matrix_common.c b/quantum/matrix_common.c
index c326e59ca3..de62b80705 100644
--- a/quantum/matrix_common.c
+++ b/quantum/matrix_common.c
@@ -1,8 +1,13 @@
#include "matrix.h"
#include "debounce.h"
+#include "wait.h"
#include "print.h"
#include "debug.h"
+#ifndef MATRIX_IO_DELAY
+# define MATRIX_IO_DELAY 30
+#endif
+
/* matrix state(1:on, 0:off) */
matrix_row_t raw_matrix[MATRIX_ROWS];
matrix_row_t matrix[MATRIX_ROWS];
@@ -78,6 +83,8 @@ uint8_t matrix_key_count(void) {
return count;
}
+__attribute__((weak)) void matrix_io_delay(void) { wait_us(MATRIX_IO_DELAY); }
+
// CUSTOM MATRIX 'LITE'
__attribute__((weak)) void matrix_init_custom(void) {}
diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c
index 2c0e028f7d..a82334128b 100644
--- a/quantum/split_common/matrix.c
+++ b/quantum/split_common/matrix.c
@@ -16,7 +16,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdbool.h>
-#include "wait.h"
#include "util.h"
#include "matrix.h"
#include "debounce.h"
@@ -111,7 +110,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
// Select row and wait for row selecton to stabilize
select_row(current_row);
- wait_us(30);
+ matrix_io_delay();
// For each col...
for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
@@ -155,7 +154,7 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
// Select col and wait for col selecton to stabilize
select_col(current_col);
- wait_us(30);
+ matrix_io_delay();
// For each row...
for (uint8_t row_index = 0; row_index < ROWS_PER_HAND; row_index++) {
diff --git a/tmk_core/common/matrix.h b/tmk_core/common/matrix.h
index a2fedf5ff0..78506059e6 100644
--- a/tmk_core/common/matrix.h
+++ b/tmk_core/common/matrix.h
@@ -66,6 +66,8 @@ bool matrix_is_on(uint8_t row, uint8_t col);
matrix_row_t matrix_get_row(uint8_t row);
/* print matrix for debug */
void matrix_print(void);
+/* delay between changing matrix pin state and reading values */
+void matrix_io_delay(void);
/* power control */
void matrix_power_up(void);