diff options
| author | MechMerlin <30334081+mechmerlin@users.noreply.github.com> | 2019-04-07 07:30:40 -0700 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2019-04-07 07:30:40 -0700 |
| commit | 0231caa25aa258a79a7fb73cc57723655055b928 (patch) | |
| tree | 90624a1942962dcf78a50a5c13bc355c1f43a321 /keyboards/facew/matrix.c | |
| parent | 5c1ef2bddc0fa5d4753d33a5ec8fed5d9da736c8 (diff) | |
| download | qmk_firmware-0231caa25aa258a79a7fb73cc57723655055b928.tar.gz qmk_firmware-0231caa25aa258a79a7fb73cc57723655055b928.zip | |
[Keyboard] Refactor FaceW for new BMC changes (#5575)
* use #pragma once for guards
* update readme and fix pyusb install instructions
* replace custom i2c code with QMK i2c_master
* remove unneeded code from config.h
* fix keyboard name
* remove custom matrix and i2c driver
* turn off bootmagic, turn on leds
* remove keymap in favor of userspace/community layouts keymap
* remove custom matrix
* update readme
Diffstat (limited to 'keyboards/facew/matrix.c')
| -rw-r--r-- | keyboards/facew/matrix.c | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/keyboards/facew/matrix.c b/keyboards/facew/matrix.c deleted file mode 100644 index 57aa36b5f..000000000 --- a/keyboards/facew/matrix.c +++ /dev/null | |||
| @@ -1,106 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include <avr/io.h> | ||
| 19 | #include <util/delay.h> | ||
| 20 | |||
| 21 | #include "matrix.h" | ||
| 22 | |||
| 23 | #ifndef DEBOUNCE | ||
| 24 | #define DEBOUNCE 5 | ||
| 25 | #endif | ||
| 26 | |||
| 27 | static uint8_t debouncing = DEBOUNCE; | ||
| 28 | |||
| 29 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
| 30 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
| 31 | |||
| 32 | void matrix_init(void) { | ||
| 33 | // all outputs for rows high | ||
| 34 | DDRB = 0xFF; | ||
| 35 | PORTB = 0xFF; | ||
| 36 | // all inputs for columns | ||
| 37 | DDRA = 0x00; | ||
| 38 | DDRC &= ~(0x111111<<2); | ||
| 39 | DDRD &= ~(1<<PIND7); | ||
| 40 | // all columns are pulled-up | ||
| 41 | PORTA = 0xFF; | ||
| 42 | PORTC |= (0b111111<<2); | ||
| 43 | PORTD |= (1<<PIND7); | ||
| 44 | |||
| 45 | // initialize matrix state: all keys off | ||
| 46 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 47 | matrix[row] = 0x00; | ||
| 48 | matrix_debouncing[row] = 0x00; | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | void matrix_set_row_status(uint8_t row) { | ||
| 53 | DDRB = (1 << row); | ||
| 54 | PORTB = ~(1 << row); | ||
| 55 | } | ||
| 56 | |||
| 57 | uint8_t bit_reverse(uint8_t x) { | ||
| 58 | x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); | ||
| 59 | x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); | ||
| 60 | x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); | ||
| 61 | return x; | ||
| 62 | } | ||
| 63 | |||
| 64 | uint8_t matrix_scan(void) { | ||
| 65 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 66 | matrix_set_row_status(row); | ||
| 67 | _delay_us(5); | ||
| 68 | |||
| 69 | matrix_row_t cols = ( | ||
| 70 | // cols 0..7, PORTA 0 -> 7 | ||
| 71 | (~PINA) & 0xFF | ||
| 72 | ) | ( | ||
| 73 | // cols 8..13, PORTC 7 -> 0 | ||
| 74 | bit_reverse((~PINC) & 0xFF) << 8 | ||
| 75 | ) | ( | ||
| 76 | // col 14, PORTD 7 | ||
| 77 | ((~PIND) & (1 << PIND7)) << 7 | ||
| 78 | ); | ||
| 79 | |||
| 80 | if (matrix_debouncing[row] != cols) { | ||
| 81 | matrix_debouncing[row] = cols; | ||
| 82 | debouncing = DEBOUNCE; | ||
| 83 | } | ||
| 84 | } | ||
| 85 | |||
| 86 | if (debouncing) { | ||
| 87 | if (--debouncing) { | ||
| 88 | _delay_ms(1); | ||
| 89 | } else { | ||
| 90 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 91 | matrix[i] = matrix_debouncing[i]; | ||
| 92 | } | ||
| 93 | } | ||
| 94 | } | ||
| 95 | |||
| 96 | matrix_scan_user(); | ||
| 97 | |||
| 98 | return 1; | ||
| 99 | } | ||
| 100 | |||
| 101 | inline matrix_row_t matrix_get_row(uint8_t row) { | ||
| 102 | return matrix[row]; | ||
| 103 | } | ||
| 104 | |||
| 105 | void matrix_print(void) { | ||
| 106 | } | ||
