Skip to content

Commit

Permalink
Allow 30us matrix delay to be keyboard/user overridable (qmk#8216)
Browse files Browse the repository at this point in the history
* Allow 30us matrix delay to be configurable via define

* Move wait logic to matrix_common

* Move wait logic to matrix_common - fix wait includes
  • Loading branch information
zvecr authored Feb 21, 2020
1 parent 6848bfd commit 19e4bbf
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs/config_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ This is a C header file that is one of the first things included, and will persi
* pins of the rows, from top to bottom
* `#define MATRIX_COL_PINS { F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7 }`
* pins of the columns, from left to right
* `#define MATRIX_IO_DELAY 30`
* the delay in microseconds when between changing matrix pin state and reading values
* `#define UNUSED_PINS { D1, D2, D3, B1, B2, B3 }`
* pins unused by the keyboard for reference
* `#define MATRIX_HAS_GHOST`
Expand Down
5 changes: 2 additions & 3 deletions quantum/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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++) {
Expand Down Expand Up @@ -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++) {
Expand Down
7 changes: 7 additions & 0 deletions quantum/matrix_common.c
Original file line number Diff line number Diff line change
@@ -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];
Expand Down Expand Up @@ -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) {}

Expand Down
5 changes: 2 additions & 3 deletions quantum/split_common/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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++) {
Expand Down Expand Up @@ -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++) {
Expand Down
2 changes: 2 additions & 0 deletions tmk_core/common/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 19e4bbf

Please sign in to comment.