diff options
author | fauxpark <fauxpark@gmail.com> | 2020-01-02 17:45:41 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-02 17:45:41 +1100 |
commit | 2557bc8e6f6e61352fa5875646d861126c42a3b0 (patch) | |
tree | 40ef2cb1a51c31a2eaa9d43414a7e88c83181dd2 /keyboards/mt40 | |
parent | b83e3ae556239b4aa6f2c4db20535c536692eb3b (diff) | |
download | qmk_firmware-2557bc8e6f6e61352fa5875646d861126c42a3b0.tar.gz qmk_firmware-2557bc8e6f6e61352fa5875646d861126c42a3b0.zip |
Remove custom matrix from PS2AVRGB boards (#7396)
* Remove custom matrix from PS2AVRGB boards
* Add custom backlight.c to SRC for bminiex, for now
* Add missing DIODE_DIRECTIONs
Diffstat (limited to 'keyboards/mt40')
-rw-r--r-- | keyboards/mt40/config.h | 8 | ||||
-rw-r--r-- | keyboards/mt40/matrix.c | 128 | ||||
-rw-r--r-- | keyboards/mt40/mt40.h | 1 | ||||
-rw-r--r-- | keyboards/mt40/rules.mk | 4 |
4 files changed, 4 insertions, 137 deletions
diff --git a/keyboards/mt40/config.h b/keyboards/mt40/config.h index 48f707f71..f5038fb54 100644 --- a/keyboards/mt40/config.h +++ b/keyboards/mt40/config.h | |||
@@ -32,7 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
32 | #define DESCRIPTION A Planck clone | 32 | #define DESCRIPTION A Planck clone |
33 | 33 | ||
34 | /* key matrix size */ | 34 | /* key matrix size */ |
35 | #define MATRIX_ROWS 8 | 35 | #define MATRIX_ROWS 7 |
36 | #define MATRIX_COLS 15 | 36 | #define MATRIX_COLS 15 |
37 | 37 | ||
38 | #define NO_UART 1 | 38 | #define NO_UART 1 |
@@ -55,12 +55,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
55 | /* #define CB6 0x37 // B7 */ | 55 | /* #define CB6 0x37 // B7 */ |
56 | /* #define CC7 0x62 // C2 */ | 56 | /* #define CC7 0x62 // C2 */ |
57 | 57 | ||
58 | #define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 } | 58 | #define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B6, B7 } |
59 | #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C2, C3, C4, C5, C6, C7, D7 } | 59 | #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 } |
60 | /* #define UNUSED_PINS */ | 60 | /* #define UNUSED_PINS */ |
61 | 61 | ||
62 | /* COL2ROW, ROW2COL*/ | 62 | /* COL2ROW, ROW2COL*/ |
63 | /* #define DIODE_DIRECTION COL2ROW */ | 63 | #define DIODE_DIRECTION COL2ROW |
64 | 64 | ||
65 | #define BACKLIGHT_PIN D2 | 65 | #define BACKLIGHT_PIN D2 |
66 | 66 | ||
diff --git a/keyboards/mt40/matrix.c b/keyboards/mt40/matrix.c deleted file mode 100644 index d75fcc221..000000000 --- a/keyboards/mt40/matrix.c +++ /dev/null | |||
@@ -1,128 +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 | #include "config.h" | ||
23 | |||
24 | #ifndef DEBOUNCE | ||
25 | # define DEBOUNCE 5 | ||
26 | #endif | ||
27 | |||
28 | static uint8_t debouncing = DEBOUNCE; | ||
29 | |||
30 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
31 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
32 | |||
33 | __attribute__ ((weak)) | ||
34 | void matrix_init_kb(void) { | ||
35 | matrix_init_user(); | ||
36 | } | ||
37 | |||
38 | __attribute__ ((weak)) | ||
39 | void matrix_scan_kb(void) { | ||
40 | matrix_scan_user(); | ||
41 | } | ||
42 | |||
43 | __attribute__ ((weak)) | ||
44 | void matrix_init_user(void) { | ||
45 | } | ||
46 | |||
47 | __attribute__ ((weak)) | ||
48 | void matrix_scan_user(void) { | ||
49 | } | ||
50 | |||
51 | |||
52 | |||
53 | void matrix_init(void) { | ||
54 | // all outputs for rows high | ||
55 | DDRB = 0xFF; | ||
56 | PORTB = 0xFF; | ||
57 | // all inputs for columns | ||
58 | DDRA = 0x00; | ||
59 | DDRC &= ~(0x111111<<2); | ||
60 | DDRD &= ~(1<<PIND7); | ||
61 | // all columns are pulled-up | ||
62 | PORTA = 0xFF; | ||
63 | PORTC |= (0b111111<<2); | ||
64 | PORTD |= (1<<PIND7); | ||
65 | |||
66 | // initialize matrix state: all keys off | ||
67 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
68 | matrix[row] = 0x00; | ||
69 | matrix_debouncing[row] = 0x00; | ||
70 | } | ||
71 | matrix_init_kb(); | ||
72 | } | ||
73 | |||
74 | void matrix_set_row_status(uint8_t row) { | ||
75 | DDRB = (1 << row); | ||
76 | PORTB = ~(1 << row); | ||
77 | } | ||
78 | |||
79 | uint8_t bit_reverse(uint8_t x) { | ||
80 | x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); | ||
81 | x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); | ||
82 | x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); | ||
83 | return x; | ||
84 | } | ||
85 | |||
86 | uint8_t matrix_scan(void) { | ||
87 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
88 | matrix_set_row_status(row); | ||
89 | _delay_us(5); | ||
90 | |||
91 | matrix_row_t cols = ( | ||
92 | // cols 0..7, PORTA 0 -> 7 | ||
93 | (~PINA) & 0xFF | ||
94 | ) | ( | ||
95 | // cols 8..13, PORTC 7 -> 0 | ||
96 | bit_reverse((~PINC) & 0xFF) << 8 | ||
97 | ) | ( | ||
98 | // col 14, PORTD 7 | ||
99 | ((~PIND) & (1 << PIND7)) << 7 | ||
100 | ); | ||
101 | |||
102 | if (matrix_debouncing[row] != cols) { | ||
103 | matrix_debouncing[row] = cols; | ||
104 | debouncing = DEBOUNCE; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | if (debouncing) { | ||
109 | if (--debouncing) { | ||
110 | _delay_ms(1); | ||
111 | } else { | ||
112 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
113 | matrix[i] = matrix_debouncing[i]; | ||
114 | } | ||
115 | } | ||
116 | } | ||
117 | |||
118 | matrix_scan_kb(); | ||
119 | |||
120 | return 1; | ||
121 | } | ||
122 | |||
123 | inline matrix_row_t matrix_get_row(uint8_t row) { | ||
124 | return matrix[row]; | ||
125 | } | ||
126 | |||
127 | void matrix_print(void) { | ||
128 | } | ||
diff --git a/keyboards/mt40/mt40.h b/keyboards/mt40/mt40.h index a53957708..3ff9c89d0 100644 --- a/keyboards/mt40/mt40.h +++ b/keyboards/mt40/mt40.h | |||
@@ -34,7 +34,6 @@ | |||
34 | { K30, K11, K12, K13, K14, K15, KC_NO, KC_NO, KC_NO, KC_NO, K1A, K1B, KC_NO, KC_NO, KC_NO }, \ | 34 | { K30, K11, K12, K13, K14, K15, KC_NO, KC_NO, KC_NO, KC_NO, K1A, K1B, KC_NO, KC_NO, KC_NO }, \ |
35 | { K10, K01, K02, K03, K04, K05, KC_NO, KC_NO, KC_NO, KC_NO, K0A, KC_NO, KC_NO, KC_NO, KC_NO }, \ | 35 | { K10, K01, K02, K03, K04, K05, KC_NO, KC_NO, KC_NO, KC_NO, K0A, KC_NO, KC_NO, KC_NO, KC_NO }, \ |
36 | { K00, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K0B }, \ | 36 | { K00, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K0B }, \ |
37 | { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ | ||
38 | { KC_NO, KC_NO, K06, K16, K26, K35, K38, K3A, K39, K3B, KC_NO, KC_NO, K07, K17, K27 }, \ | 37 | { KC_NO, KC_NO, K06, K16, K26, K35, K38, K3A, K39, K3B, KC_NO, KC_NO, K07, K17, K27 }, \ |
39 | { KC_NO, KC_NO, K09, K19, K29, KC_NO, K2B, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K08, K18, K28 } \ | 38 | { KC_NO, KC_NO, K09, K19, K29, KC_NO, K2B, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K08, K18, K28 } \ |
40 | } | 39 | } |
diff --git a/keyboards/mt40/rules.mk b/keyboards/mt40/rules.mk index 0cbf90c67..338a83cc7 100644 --- a/keyboards/mt40/rules.mk +++ b/keyboards/mt40/rules.mk | |||
@@ -29,9 +29,5 @@ TAP_DANCE_ENABLE = no | |||
29 | 29 | ||
30 | OPT_DEFS = -DDEBUG_LEVEL=0 | 30 | OPT_DEFS = -DDEBUG_LEVEL=0 |
31 | 31 | ||
32 | # custom matrix setup | ||
33 | CUSTOM_MATRIX = yes | ||
34 | SRC = matrix.c | ||
35 | |||
36 | LAYOUTS = planck_mit | 32 | LAYOUTS = planck_mit |
37 | LAYOUTS_HAS_RGB = no | 33 | LAYOUTS_HAS_RGB = no |