diff options
| author | Alex Ong <alex.ong@unsw.edu.au> | 2018-08-29 10:19:36 +1000 |
|---|---|---|
| committer | Alex Ong <alex.ong@unsw.edu.au> | 2018-08-29 10:19:36 +1000 |
| commit | 3cf7f7322c24e3cab21d402f1a859b60df857603 (patch) | |
| tree | 08e5f119b2faa8c393dbbad7c085fe83728046c3 /quantum | |
| parent | 9bd6d6112d698ea5823b268983809fe3b8d98b26 (diff) | |
| download | qmk_firmware-3cf7f7322c24e3cab21d402f1a859b60df857603.tar.gz qmk_firmware-3cf7f7322c24e3cab21d402f1a859b60df857603.zip | |
Removed "debounce_algo = manual" in all keyboards with CUSTOM_MATRIX = yes.
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/matrix.c | 79 |
1 files changed, 3 insertions, 76 deletions
diff --git a/quantum/matrix.c b/quantum/matrix.c index 3600d4e7b..bc7eb6b58 100644 --- a/quantum/matrix.c +++ b/quantum/matrix.c | |||
| @@ -27,17 +27,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 27 | #include "timer.h" | 27 | #include "timer.h" |
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | /* Set 0 if debouncing isn't needed */ | ||
| 31 | |||
| 32 | #ifndef DEBOUNCING_DELAY | ||
| 33 | # define DEBOUNCING_DELAY 5 | ||
| 34 | #endif | ||
| 35 | |||
| 36 | #if (DEBOUNCING_DELAY > 0) | ||
| 37 | static uint16_t debouncing_time; | ||
| 38 | static bool debouncing = false; | ||
| 39 | #endif | ||
| 40 | |||
| 41 | #if (MATRIX_COLS <= 8) | 30 | #if (MATRIX_COLS <= 8) |
| 42 | # define print_matrix_header() print("\nr/c 01234567\n") | 31 | # define print_matrix_header() print("\nr/c 01234567\n") |
| 43 | # define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) | 32 | # define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) |
| @@ -67,8 +56,6 @@ static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; | |||
| 67 | /* matrix state(1:on, 0:off) */ | 56 | /* matrix state(1:on, 0:off) */ |
| 68 | static matrix_row_t matrix[MATRIX_ROWS]; | 57 | static matrix_row_t matrix[MATRIX_ROWS]; |
| 69 | 58 | ||
| 70 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
| 71 | |||
| 72 | 59 | ||
| 73 | #if (DIODE_DIRECTION == COL2ROW) | 60 | #if (DIODE_DIRECTION == COL2ROW) |
| 74 | static void init_cols(void); | 61 | static void init_cols(void); |
| @@ -122,30 +109,6 @@ uint8_t matrix_cols(void) { | |||
| 122 | return MATRIX_COLS; | 109 | return MATRIX_COLS; |
| 123 | } | 110 | } |
| 124 | 111 | ||
| 125 | // void matrix_power_up(void) { | ||
| 126 | // #if (DIODE_DIRECTION == COL2ROW) | ||
| 127 | // for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) { | ||
| 128 | // /* DDRxn */ | ||
| 129 | // _SFR_IO8((row_pins[r] >> 4) + 1) |= _BV(row_pins[r] & 0xF); | ||
| 130 | // toggle_row(r); | ||
| 131 | // } | ||
| 132 | // for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) { | ||
| 133 | // /* PORTxn */ | ||
| 134 | // _SFR_IO8((col_pins[c] >> 4) + 2) |= _BV(col_pins[c] & 0xF); | ||
| 135 | // } | ||
| 136 | // #elif (DIODE_DIRECTION == ROW2COL) | ||
| 137 | // for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) { | ||
| 138 | // /* DDRxn */ | ||
| 139 | // _SFR_IO8((col_pins[c] >> 4) + 1) |= _BV(col_pins[c] & 0xF); | ||
| 140 | // toggle_col(c); | ||
| 141 | // } | ||
| 142 | // for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) { | ||
| 143 | // /* PORTxn */ | ||
| 144 | // _SFR_IO8((row_pins[r] >> 4) + 2) |= _BV(row_pins[r] & 0xF); | ||
| 145 | // } | ||
| 146 | // #endif | ||
| 147 | // } | ||
| 148 | |||
| 149 | void matrix_init(void) { | 112 | void matrix_init(void) { |
| 150 | 113 | ||
| 151 | // initialize row and col | 114 | // initialize row and col |
| @@ -160,7 +123,6 @@ void matrix_init(void) { | |||
| 160 | // initialize matrix state: all keys off | 123 | // initialize matrix state: all keys off |
| 161 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | 124 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { |
| 162 | matrix[i] = 0; | 125 | matrix[i] = 0; |
| 163 | matrix_debouncing[i] = 0; | ||
| 164 | } | 126 | } |
| 165 | 127 | ||
| 166 | matrix_init_quantum(); | 128 | matrix_init_quantum(); |
| @@ -170,59 +132,24 @@ uint8_t matrix_scan(void) | |||
| 170 | { | 132 | { |
| 171 | 133 | ||
| 172 | #if (DIODE_DIRECTION == COL2ROW) | 134 | #if (DIODE_DIRECTION == COL2ROW) |
| 173 | |||
| 174 | // Set row, read cols | 135 | // Set row, read cols |
| 175 | for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { | 136 | for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { |
| 176 | # if (DEBOUNCING_DELAY > 0) | 137 | read_cols_on_row(matrix, current_row); |
| 177 | bool matrix_changed = read_cols_on_row(matrix_debouncing, current_row); | ||
| 178 | |||
| 179 | if (matrix_changed) { | ||
| 180 | debouncing = true; | ||
| 181 | debouncing_time = timer_read(); | ||
| 182 | } | ||
| 183 | |||
| 184 | # else | ||
| 185 | read_cols_on_row(matrix, current_row); | ||
| 186 | # endif | ||
| 187 | |||
| 188 | } | 138 | } |
| 189 | |||
| 190 | #elif (DIODE_DIRECTION == ROW2COL) | 139 | #elif (DIODE_DIRECTION == ROW2COL) |
| 191 | |||
| 192 | // Set col, read rows | 140 | // Set col, read rows |
| 193 | for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { | 141 | for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { |
| 194 | # if (DEBOUNCING_DELAY > 0) | 142 | read_rows_on_col(matrix, current_col); |
| 195 | bool matrix_changed = read_rows_on_col(matrix_debouncing, current_col); | ||
| 196 | if (matrix_changed) { | ||
| 197 | debouncing = true; | ||
| 198 | debouncing_time = timer_read(); | ||
| 199 | } | ||
| 200 | # else | ||
| 201 | read_rows_on_col(matrix, current_col); | ||
| 202 | # endif | ||
| 203 | |||
| 204 | } | 143 | } |
| 205 | |||
| 206 | #endif | 144 | #endif |
| 207 | 145 | ||
| 208 | # if (DEBOUNCING_DELAY > 0) | ||
| 209 | if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCING_DELAY)) { | ||
| 210 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 211 | matrix[i] = matrix_debouncing[i]; | ||
| 212 | } | ||
| 213 | debouncing = false; | ||
| 214 | } | ||
| 215 | # endif | ||
| 216 | |||
| 217 | matrix_scan_quantum(); | 146 | matrix_scan_quantum(); |
| 218 | return 1; | 147 | return 1; |
| 219 | } | 148 | } |
| 220 | 149 | ||
| 150 | //Deprecated. | ||
| 221 | bool matrix_is_modified(void) | 151 | bool matrix_is_modified(void) |
| 222 | { | 152 | { |
| 223 | #if (DEBOUNCING_DELAY > 0) | ||
| 224 | if (debouncing) return false; | ||
| 225 | #endif | ||
| 226 | return true; | 153 | return true; |
| 227 | } | 154 | } |
| 228 | 155 | ||
