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 | |
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
69 files changed, 81 insertions, 1782 deletions
diff --git a/keyboards/bfake/bfake.c b/keyboards/bfake/bfake.c index f7d006576..9039fe546 100644 --- a/keyboards/bfake/bfake.c +++ b/keyboards/bfake/bfake.c | |||
@@ -17,9 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
17 | 17 | ||
18 | #include "bfake.h" | 18 | #include "bfake.h" |
19 | 19 | ||
20 | __attribute__ ((weak)) | ||
21 | void matrix_scan_user(void) {} | ||
22 | |||
23 | void backlight_init_ports(void) { | 20 | void backlight_init_ports(void) { |
24 | setPinOutput(D0); | 21 | setPinOutput(D0); |
25 | setPinOutput(D1); | 22 | setPinOutput(D1); |
diff --git a/keyboards/bfake/config.h b/keyboards/bfake/config.h index 0a8911b09..65f1f3a75 100644 --- a/keyboards/bfake/config.h +++ b/keyboards/bfake/config.h | |||
@@ -32,7 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
32 | #define MATRIX_COLS 11 | 32 | #define MATRIX_COLS 11 |
33 | 33 | ||
34 | #define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 } | 34 | #define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 } |
35 | #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6} | 35 | #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5 } |
36 | #define UNUSED_PINS | 36 | #define UNUSED_PINS |
37 | 37 | ||
38 | #define DIODE_DIRECTION COL2ROW | 38 | #define DIODE_DIRECTION COL2ROW |
diff --git a/keyboards/bfake/matrix.c b/keyboards/bfake/matrix.c deleted file mode 100644 index 57aa36b5f..000000000 --- a/keyboards/bfake/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 | } | ||
diff --git a/keyboards/bfake/rules.mk b/keyboards/bfake/rules.mk index 5963c9810..107bb4fa9 100644 --- a/keyboards/bfake/rules.mk +++ b/keyboards/bfake/rules.mk | |||
@@ -22,7 +22,3 @@ RGBLIGHT_ENABLE = no | |||
22 | WS2812_DRIVER = i2c | 22 | WS2812_DRIVER = i2c |
23 | 23 | ||
24 | OPT_DEFS = -DDEBUG_LEVEL=0 | 24 | OPT_DEFS = -DDEBUG_LEVEL=0 |
25 | |||
26 | # custom matrix setup | ||
27 | CUSTOM_MATRIX = yes | ||
28 | SRC = matrix.c | ||
diff --git a/keyboards/coseyfannitutti/discipad/discipad.c b/keyboards/coseyfannitutti/discipad/discipad.c index c8f6e0a17..4bdb1c6c2 100644 --- a/keyboards/coseyfannitutti/discipad/discipad.c +++ b/keyboards/coseyfannitutti/discipad/discipad.c | |||
@@ -14,11 +14,3 @@ | |||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | */ | 15 | */ |
16 | #include "discipad.h" | 16 | #include "discipad.h" |
17 | |||
18 | |||
19 | void matrix_init_kb(void) { | ||
20 | // put your keyboard start-up code here | ||
21 | // runs once when the firmware starts up | ||
22 | |||
23 | matrix_init_user(); | ||
24 | } | ||
diff --git a/keyboards/coseyfannitutti/discipline/discipline.c b/keyboards/coseyfannitutti/discipline/discipline.c index 6a788ce0e..50ba0bae5 100644 --- a/keyboards/coseyfannitutti/discipline/discipline.c +++ b/keyboards/coseyfannitutti/discipline/discipline.c | |||
@@ -14,11 +14,3 @@ | |||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | */ | 15 | */ |
16 | #include "discipline.h" | 16 | #include "discipline.h" |
17 | |||
18 | |||
19 | void matrix_init_kb(void) { | ||
20 | // put your keyboard start-up code here | ||
21 | // runs once when the firmware starts up | ||
22 | |||
23 | matrix_init_user(); | ||
24 | } | ||
diff --git a/keyboards/exclusive/e6v2/le_bmc/keymaps/default/keymap.c b/keyboards/exclusive/e6v2/le_bmc/keymaps/default/keymap.c index 730041917..6d9209e48 100644 --- a/keyboards/exclusive/e6v2/le_bmc/keymaps/default/keymap.c +++ b/keyboards/exclusive/e6v2/le_bmc/keymaps/default/keymap.c | |||
@@ -60,15 +60,3 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
60 | } | 60 | } |
61 | return true; | 61 | return true; |
62 | } | 62 | } |
63 | |||
64 | void matrix_init_user(void) { | ||
65 | |||
66 | } | ||
67 | |||
68 | void matrix_scan_user(void) { | ||
69 | |||
70 | } | ||
71 | |||
72 | void led_set_user(uint8_t usb_led) { | ||
73 | |||
74 | } | ||
diff --git a/keyboards/exclusive/e6v2/oe_bmc/keymaps/default/keymap.c b/keyboards/exclusive/e6v2/oe_bmc/keymaps/default/keymap.c index 730041917..6d9209e48 100644 --- a/keyboards/exclusive/e6v2/oe_bmc/keymaps/default/keymap.c +++ b/keyboards/exclusive/e6v2/oe_bmc/keymaps/default/keymap.c | |||
@@ -60,15 +60,3 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
60 | } | 60 | } |
61 | return true; | 61 | return true; |
62 | } | 62 | } |
63 | |||
64 | void matrix_init_user(void) { | ||
65 | |||
66 | } | ||
67 | |||
68 | void matrix_scan_user(void) { | ||
69 | |||
70 | } | ||
71 | |||
72 | void led_set_user(uint8_t usb_led) { | ||
73 | |||
74 | } | ||
diff --git a/keyboards/ft/mars80/keymaps/default/keymap.c b/keyboards/ft/mars80/keymaps/default/keymap.c index ba7ef83d9..010102d72 100644 --- a/keyboards/ft/mars80/keymaps/default/keymap.c +++ b/keyboards/ft/mars80/keymaps/default/keymap.c | |||
@@ -61,15 +61,3 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
61 | } | 61 | } |
62 | return true; | 62 | return true; |
63 | } | 63 | } |
64 | |||
65 | void matrix_init_user(void) { | ||
66 | |||
67 | } | ||
68 | |||
69 | void matrix_scan_user(void) { | ||
70 | |||
71 | } | ||
72 | |||
73 | void led_set_user(uint8_t usb_led) { | ||
74 | |||
75 | } | ||
diff --git a/keyboards/jc65/v32a/config.h b/keyboards/jc65/v32a/config.h index 444ebad07..5439dbe39 100644 --- a/keyboards/jc65/v32a/config.h +++ b/keyboards/jc65/v32a/config.h | |||
@@ -26,8 +26,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
26 | #define PRODUCT JC65 PS2AVRGB | 26 | #define PRODUCT JC65 PS2AVRGB |
27 | 27 | ||
28 | /* matrix size */ | 28 | /* matrix size */ |
29 | #define MATRIX_ROWS 8 | 29 | #define MATRIX_ROWS 7 |
30 | #define MATRIX_COLS 16 | 30 | #define MATRIX_COLS 15 |
31 | #define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B6, B7 } | ||
32 | #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 } | ||
33 | #define DIODE_DIRECTION COL2ROW | ||
31 | 34 | ||
32 | #define BACKLIGHT_LEVELS 1 | 35 | #define BACKLIGHT_LEVELS 1 |
33 | #define RGBLED_NUM 16 | 36 | #define RGBLED_NUM 16 |
diff --git a/keyboards/jc65/v32a/matrix.c b/keyboards/jc65/v32a/matrix.c deleted file mode 100644 index 57aa36b5f..000000000 --- a/keyboards/jc65/v32a/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 | } | ||
diff --git a/keyboards/jc65/v32a/rules.mk b/keyboards/jc65/v32a/rules.mk index 18e7f1de9..a8fea7efa 100644 --- a/keyboards/jc65/v32a/rules.mk +++ b/keyboards/jc65/v32a/rules.mk | |||
@@ -22,7 +22,3 @@ RGBLIGHT_ENABLE = yes | |||
22 | WS2812_DRIVER = i2c | 22 | WS2812_DRIVER = i2c |
23 | 23 | ||
24 | OPT_DEFS = -DDEBUG_LEVEL=0 | 24 | OPT_DEFS = -DDEBUG_LEVEL=0 |
25 | |||
26 | # custom matrix setup | ||
27 | CUSTOM_MATRIX = yes | ||
28 | SRC = matrix.c | ||
diff --git a/keyboards/jc65/v32a/v32a.c b/keyboards/jc65/v32a/v32a.c index 9b1e07274..2a289872f 100644 --- a/keyboards/jc65/v32a/v32a.c +++ b/keyboards/jc65/v32a/v32a.c | |||
@@ -17,9 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
17 | 17 | ||
18 | #include "v32a.h" | 18 | #include "v32a.h" |
19 | 19 | ||
20 | __attribute__ ((weak)) | ||
21 | void matrix_scan_user(void) {} | ||
22 | |||
23 | #ifdef BACKLIGHT_ENABLE | 20 | #ifdef BACKLIGHT_ENABLE |
24 | void backlight_init_ports(void) { | 21 | void backlight_init_ports(void) { |
25 | setPinOutput(D0); | 22 | setPinOutput(D0); |
diff --git a/keyboards/jc65/v32a/v32a.h b/keyboards/jc65/v32a/v32a.h index ba91d80a6..b319ba80a 100644 --- a/keyboards/jc65/v32a/v32a.h +++ b/keyboards/jc65/v32a/v32a.h | |||
@@ -27,14 +27,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
27 | K01,K30,K11,K21,K31,K41,K51,K46,KE6,KE7,K47,KA1, KB1,K86,K77, \ | 27 | K01,K30,K11,K21,K31,K41,K51,K46,KE6,KE7,K47,KA1, KB1,K86,K77, \ |
28 | K00,K10,K20, K40,K56,K50, K57,KB0,KC0,K96,K76,K66 \ | 28 | K00,K10,K20, K40,K56,K50, K57,KB0,KC0,K96,K76,K66 \ |
29 | ){ \ | 29 | ){ \ |
30 | { K00, K10, K20, K30, K40, K50,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO, KB0, KC0, KD0,KC_NO,KC_NO }, \ | 30 | { K00, K10, K20, K30, K40, K50,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO, KB0, KC0, KD0,KC_NO }, \ |
31 | { K01, K11, K21, K31, K41, K51,KC_NO,KC_NO,KC_NO,KC_NO, KA1, KB1,KC_NO,KC_NO,KC_NO,KC_NO }, \ | 31 | { K01, K11, K21, K31, K41, K51,KC_NO,KC_NO,KC_NO,KC_NO, KA1, KB1,KC_NO,KC_NO,KC_NO }, \ |
32 | { K02, K12, K22, K32, K42, K52,KC_NO,KC_NO,KC_NO,KC_NO, KA2, KB2, KC2, KD2,KC_NO,KC_NO }, \ | 32 | { K02, K12, K22, K32, K42, K52,KC_NO,KC_NO,KC_NO,KC_NO, KA2, KB2, KC2, KD2,KC_NO }, \ |
33 | { K03, K13, K23, K33, K43, K53,KC_NO,KC_NO,KC_NO,KC_NO, KA3, KB3, KC3, KD3,KC_NO,KC_NO }, \ | 33 | { K03, K13, K23, K33, K43, K53,KC_NO,KC_NO,KC_NO,KC_NO, KA3, KB3, KC3, KD3,KC_NO }, \ |
34 | { K04, K14, K24, K34, K44, K54,KC_NO,KC_NO,KC_NO,KC_NO, KA4, KB4, KC4, KD4, KE4,KC_NO }, \ | 34 | { K04, K14, K24, K34, K44, K54,KC_NO,KC_NO,KC_NO,KC_NO, KA4, KB4, KC4, KD4, KE4 }, \ |
35 | { 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,KC_NO }, \ | 35 | { KC_NO, K16, K26, K36, K46, K56, K66, K76, K86, K96,KC_NO, KB6, KC6, KD6, KE6 }, \ |
36 | { KC_NO, K16, K26, K36, K46, K56, K66, K76, K86, K96,KC_NO, KB6, KC6, KD6, KE6,KC_NO }, \ | 36 | { KC_NO, K17, K27, K37, K47, K57, K67, K77, K87,KC_NO,KC_NO, KB7, KC7, KD7, KE7 } \ |
37 | { KC_NO, K17, K27, K37, K47, K57, K67, K77, K87,KC_NO,KC_NO, KB7, KC7, KD7, KE7,KC_NO } \ | ||
38 | } | 37 | } |
39 | 38 | ||
40 | #define LAYOUT_kc( \ | 39 | #define LAYOUT_kc( \ |
@@ -45,14 +44,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
45 | K00,K10,K20, K40,K56,K50, K57,KB0,KC0,K96,K76,K66 \ | 44 | K00,K10,K20, K40,K56,K50, K57,KB0,KC0,K96,K76,K66 \ |
46 | ) \ | 45 | ) \ |
47 | { \ | 46 | { \ |
48 | { KC_##K00,KC_##K10,KC_##K20,KC_##K30,KC_##K40,KC_##K50, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,KC_##KB0,KC_##KC0,KC_##KD0, KC_NO,KC_NO }, \ | 47 | { KC_##K00,KC_##K10,KC_##K20,KC_##K30,KC_##K40,KC_##K50, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,KC_##KB0,KC_##KC0,KC_##KD0, KC_NO }, \ |
49 | { KC_##K01,KC_##K11,KC_##K21,KC_##K31,KC_##K41,KC_##K51, KC_NO, KC_NO, KC_NO, KC_NO,KC_##KA1,KC_##KB1, KC_NO, KC_NO, KC_NO,KC_NO }, \ | 48 | { KC_##K01,KC_##K11,KC_##K21,KC_##K31,KC_##K41,KC_##K51, KC_NO, KC_NO, KC_NO, KC_NO,KC_##KA1,KC_##KB1, KC_NO, KC_NO, KC_NO }, \ |
50 | { KC_##K02,KC_##K12,KC_##K22,KC_##K32,KC_##K42,KC_##K52, KC_NO, KC_NO, KC_NO, KC_NO,KC_##KA2,KC_##KB2,KC_##KC2,KC_##KD2, KC_NO,KC_NO }, \ | 49 | { KC_##K02,KC_##K12,KC_##K22,KC_##K32,KC_##K42,KC_##K52, KC_NO, KC_NO, KC_NO, KC_NO,KC_##KA2,KC_##KB2,KC_##KC2,KC_##KD2, KC_NO }, \ |
51 | { KC_##K03,KC_##K13,KC_##K23,KC_##K33,KC_##K43,KC_##K53, KC_NO, KC_NO, KC_NO, KC_NO,KC_##KA3,KC_##KB3,KC_##KC3,KC_##KD3, KC_NO,KC_NO }, \ | 50 | { KC_##K03,KC_##K13,KC_##K23,KC_##K33,KC_##K43,KC_##K53, KC_NO, KC_NO, KC_NO, KC_NO,KC_##KA3,KC_##KB3,KC_##KC3,KC_##KD3, KC_NO }, \ |
52 | { KC_##K04,KC_##K14,KC_##K24,KC_##K34,KC_##K44,KC_##K54, KC_NO, KC_NO, KC_NO, KC_NO,KC_##KA4,KC_##KB4,KC_##KC4,KC_##KD4,KC_##KE4,KC_NO }, \ | 51 | { KC_##K04,KC_##K14,KC_##K24,KC_##K34,KC_##K44,KC_##K54, KC_NO, KC_NO, KC_NO, KC_NO,KC_##KA4,KC_##KB4,KC_##KC4,KC_##KD4,KC_##KE4 }, \ |
53 | { 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,KC_NO }, \ | 52 | { KC_NO,KC_##K16,KC_##K26,KC_##K36,KC_##K46,KC_##K56,KC_##K66,KC_##K76,KC_##K86,KC_##K96, KC_NO,KC_##KB6,KC_##KC6,KC_##KD6,KC_##KE6 }, \ |
54 | { KC_NO,KC_##K16,KC_##K26,KC_##K36,KC_##K46,KC_##K56,KC_##K66,KC_##K76,KC_##K86,KC_##K96, KC_NO,KC_##KB6,KC_##KC6,KC_##KD6,KC_##KE6,KC_NO }, \ | 53 | { KC_NO,KC_##K17,KC_##K27,KC_##K37,KC_##K47,KC_##K57,KC_##K67,KC_##K77,KC_##K87, KC_NO, KC_NO,KC_##KB7,KC_##KC7,KC_##KD7,KC_##KE7 } \ |
55 | { KC_NO,KC_##K17,KC_##K27,KC_##K37,KC_##K47,KC_##K57,KC_##K67,KC_##K77,KC_##K87, KC_NO, KC_NO,KC_##KB7,KC_##KC7,KC_##KD7,KC_##KE7,KC_NO } \ | ||
56 | } | 54 | } |
57 | 55 | ||
58 | #endif | 56 | #endif |
diff --git a/keyboards/jj40/rules.mk b/keyboards/jj40/rules.mk index 8e0e8c864..c53a6804c 100644 --- a/keyboards/jj40/rules.mk +++ b/keyboards/jj40/rules.mk | |||
@@ -1,18 +1,3 @@ | |||
1 | # Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> | ||
2 | # | ||
3 | # This program is free software: you can redistribute it and/or modify | ||
4 | # it under the terms of the GNU General Public License as published by | ||
5 | # the Free Software Foundation, either version 2 of the License, or | ||
6 | # (at your option) any later version. | ||
7 | # | ||
8 | # This program is distributed in the hope that it will be useful, | ||
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | # GNU General Public License for more details. | ||
12 | # | ||
13 | # You should have received a copy of the GNU General Public License | ||
14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | |||
16 | # MCU name | 1 | # MCU name |
17 | MCU = atmega32a | 2 | MCU = atmega32a |
18 | 3 | ||
diff --git a/keyboards/jj50/config.h b/keyboards/jj50/config.h index dfd8a4a8f..884a28d50 100644 --- a/keyboards/jj50/config.h +++ b/keyboards/jj50/config.h | |||
@@ -32,9 +32,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
32 | #define DESCRIPTION Preonic-like clone | 32 | #define DESCRIPTION Preonic-like clone |
33 | 33 | ||
34 | /* matrix size */ | 34 | /* matrix size */ |
35 | #define MATRIX_ROWS 8 | 35 | #define MATRIX_ROWS 5 |
36 | #define MATRIX_COLS 15 | 36 | #define MATRIX_COLS 12 |
37 | #define DIODE_DIRECTION ROW2COL | 37 | #define MATRIX_ROW_PINS { B0, B1, B2, B3, B4 } |
38 | #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4 } | ||
39 | #define DIODE_DIRECTION COL2ROW | ||
38 | 40 | ||
39 | //#define BACKLIGHT_PIN D4 | 41 | //#define BACKLIGHT_PIN D4 |
40 | #define BACKLIGHT_LEVELS 12 | 42 | #define BACKLIGHT_LEVELS 12 |
diff --git a/keyboards/jj50/jj50.c b/keyboards/jj50/jj50.c index 7c3cee95d..a302adf40 100644 --- a/keyboards/jj50/jj50.c +++ b/keyboards/jj50/jj50.c | |||
@@ -20,16 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
20 | #include "backlight.h" | 20 | #include "backlight.h" |
21 | #include "backlight_custom.h" | 21 | #include "backlight_custom.h" |
22 | 22 | ||
23 | void matrix_init_kb(void) { matrix_init_user(); } | ||
24 | |||
25 | __attribute__ ((weak)) | ||
26 | void matrix_init_user(void) {} | ||
27 | |||
28 | void matrix_scan_kb(void) { matrix_scan_user(); } | ||
29 | |||
30 | __attribute__ ((weak)) | ||
31 | void matrix_scan_user(void) {} | ||
32 | |||
33 | #ifdef BACKLIGHT_ENABLE | 23 | #ifdef BACKLIGHT_ENABLE |
34 | void backlight_init_ports(void) { | 24 | void backlight_init_ports(void) { |
35 | b_led_init_ports(); | 25 | b_led_init_ports(); |
diff --git a/keyboards/jj50/jj50.h b/keyboards/jj50/jj50.h index 8a904897e..6b1c7eacf 100644 --- a/keyboards/jj50/jj50.h +++ b/keyboards/jj50/jj50.h | |||
@@ -25,8 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
25 | #include "keycode.h" | 25 | #include "keycode.h" |
26 | #include "action.h" | 26 | #include "action.h" |
27 | 27 | ||
28 | void matrix_init_user(void); | ||
29 | |||
30 | #define LAYOUT_ortho_5x12( \ | 28 | #define LAYOUT_ortho_5x12( \ |
31 | K011, K010, K009, K008, K004, K005, K006, K007, K003, K002, K201, K000, \ | 29 | K011, K010, K009, K008, K004, K005, K006, K007, K003, K002, K201, K000, \ |
32 | K111, K110, K109, K108, K104, K105, K106, K107, K103, K102, K001, K100, \ | 30 | K111, K110, K109, K108, K104, K105, K106, K107, K103, K102, K001, K100, \ |
diff --git a/keyboards/jj50/matrix.c b/keyboards/jj50/matrix.c deleted file mode 100644 index 95c6057e7..000000000 --- a/keyboards/jj50/matrix.c +++ /dev/null | |||
@@ -1,107 +0,0 @@ | |||
1 | /* | ||
2 | Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> | ||
3 | Modified 2018 by Wayne K Jones <github.com/WarmCatUK> | ||
4 | |||
5 | This program is free software: you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation, either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #include <avr/io.h> | ||
20 | #include <util/delay.h> | ||
21 | |||
22 | #include "matrix.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 | void matrix_init(void) { | ||
34 | // all outputs for rows high | ||
35 | DDRB = 0xFF; | ||
36 | PORTB = 0xFF; | ||
37 | // all inputs for columns | ||
38 | DDRA = 0x00; | ||
39 | DDRC &= ~(0x111111<<2); | ||
40 | //----> DDRD &= ~(1<<PIND7); | ||
41 | // Port D not used on this keyboard | ||
42 | // all columns are pulled-up | ||
43 | PORTA = 0xFF; | ||
44 | PORTC |= (0b111111<<2); | ||
45 | //PORTD |= (1<<PIND7); | ||
46 | // Port D not used on this keyboard | ||
47 | |||
48 | // initialize matrix state: all keys off | ||
49 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
50 | matrix[row] = 0x00; | ||
51 | matrix_debouncing[row] = 0x00; | ||
52 | } | ||
53 | matrix_init_quantum(); // missing from original port by Luiz | ||
54 | } | ||
55 | |||
56 | void matrix_set_row_status(uint8_t row) { | ||
57 | DDRB = (1 << row); | ||
58 | PORTB = ~(1 << row); | ||
59 | } | ||
60 | |||
61 | uint8_t bit_reverse(uint8_t x) { | ||
62 | x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); | ||
63 | x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); | ||
64 | x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); | ||
65 | return x; | ||
66 | } | ||
67 | |||
68 | uint8_t matrix_scan(void) { | ||
69 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
70 | matrix_set_row_status(row); | ||
71 | _delay_us(5); | ||
72 | |||
73 | matrix_row_t cols = ( | ||
74 | // cols 0..7, PORTA 0 -> 7 | ||
75 | (~PINA) & 0xFF | ||
76 | ) | ( | ||
77 | // cols 8..13, PORTC 7 -> 0 | ||
78 | bit_reverse((~PINC) & 0xFF) << 8 | ||
79 | ); | ||
80 | |||
81 | if (matrix_debouncing[row] != cols) { | ||
82 | matrix_debouncing[row] = cols; | ||
83 | debouncing = DEBOUNCE; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | if (debouncing) { | ||
88 | if (--debouncing) { | ||
89 | _delay_ms(1); | ||
90 | } else { | ||
91 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
92 | matrix[i] = matrix_debouncing[i]; | ||
93 | } | ||
94 | } | ||
95 | } | ||
96 | matrix_scan_quantum(); // also missing in original PS2AVRGB implementation | ||
97 | //matrix_scan_user(); | ||
98 | |||
99 | return 1; | ||
100 | } | ||
101 | |||
102 | inline matrix_row_t matrix_get_row(uint8_t row) { | ||
103 | return matrix[row]; | ||
104 | } | ||
105 | |||
106 | void matrix_print(void) { | ||
107 | } | ||
diff --git a/keyboards/jj50/rules.mk b/keyboards/jj50/rules.mk index 40473e6ec..62b21e4df 100644 --- a/keyboards/jj50/rules.mk +++ b/keyboards/jj50/rules.mk | |||
@@ -29,8 +29,6 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | |||
29 | 29 | ||
30 | #OPT_DEFS = -DDEBUG_LEVEL=0 | 30 | #OPT_DEFS = -DDEBUG_LEVEL=0 |
31 | 31 | ||
32 | # custom matrix setup | 32 | SRC = backlight.c |
33 | CUSTOM_MATRIX = yes | ||
34 | SRC = matrix.c backlight.c | ||
35 | 33 | ||
36 | LAYOUTS = ortho_5x12 | 34 | LAYOUTS = ortho_5x12 |
diff --git a/keyboards/leeku/finger65/config.h b/keyboards/leeku/finger65/config.h index 3e6eebb32..584db4ad3 100644 --- a/keyboards/leeku/finger65/config.h +++ b/keyboards/leeku/finger65/config.h | |||
@@ -37,6 +37,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
37 | #define MATRIX_ROW_PINS { C3, C4, C5, C6, C7 } | 37 | #define MATRIX_ROW_PINS { C3, C4, C5, C6, C7 } |
38 | #define UNUSED_PINS | 38 | #define UNUSED_PINS |
39 | 39 | ||
40 | #define DIODE_DIRECTION COL2ROW | ||
41 | |||
40 | /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ | 42 | /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ |
41 | #define DEBOUNCE 5 | 43 | #define DEBOUNCE 5 |
42 | 44 | ||
diff --git a/keyboards/mechmini/v1/config.h b/keyboards/mechmini/v1/config.h index 9355a6dc3..eb15a368a 100644 --- a/keyboards/mechmini/v1/config.h +++ b/keyboards/mechmini/v1/config.h | |||
@@ -30,8 +30,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
30 | #define DESCRIPTION 40% modular keyboard | 30 | #define DESCRIPTION 40% modular keyboard |
31 | 31 | ||
32 | /* matrix size */ | 32 | /* matrix size */ |
33 | #define MATRIX_ROWS 8 | 33 | #define MATRIX_ROWS 4 |
34 | #define MATRIX_COLS 15 | 34 | #define MATRIX_COLS 12 |
35 | #define MATRIX_ROW_PINS { B0, B1, B2, B3 } | ||
36 | #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4 } | ||
37 | #define DIODE_DIRECTION COL2ROW | ||
35 | 38 | ||
36 | #define NO_UART 1 | 39 | #define NO_UART 1 |
37 | 40 | ||
diff --git a/keyboards/mechmini/v1/matrix.c b/keyboards/mechmini/v1/matrix.c deleted file mode 100644 index 245813dfd..000000000 --- a/keyboards/mechmini/v1/matrix.c +++ /dev/null | |||
@@ -1,112 +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_set_row_status(uint8_t row); | ||
33 | uint8_t bit_reverse(uint8_t x); | ||
34 | |||
35 | void matrix_init(void) { | ||
36 | // all outputs for rows high | ||
37 | DDRB = 0xFF; | ||
38 | PORTB = 0xFF; | ||
39 | // all inputs for columns | ||
40 | DDRA = 0x00; | ||
41 | DDRC &= ~(0x111111<<2); | ||
42 | DDRD &= ~(1<<PIND7); | ||
43 | // all columns are pulled-up | ||
44 | PORTA = 0xFF; | ||
45 | PORTC |= (0b111111<<2); | ||
46 | PORTD |= (1<<PIND7); | ||
47 | |||
48 | // initialize matrix state: all keys off | ||
49 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
50 | matrix[row] = 0x00; | ||
51 | matrix_debouncing[row] = 0x00; | ||
52 | } | ||
53 | |||
54 | matrix_init_quantum(); | ||
55 | } | ||
56 | |||
57 | uint8_t matrix_scan(void) { | ||
58 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
59 | matrix_set_row_status(row); | ||
60 | _delay_us(5); | ||
61 | |||
62 | matrix_row_t cols = ( | ||
63 | // cols 0..7, PORTA 0 -> 7 | ||
64 | (~PINA) & 0xFF | ||
65 | ) | ( | ||
66 | // cols 8..13, PORTC 7 -> 0 | ||
67 | bit_reverse((~PINC) & 0xFF) << 8 | ||
68 | ) | ( | ||
69 | // col 14, PORTD 7 | ||
70 | ((~PIND) & (1 << PIND7)) << 7 | ||
71 | ); | ||
72 | |||
73 | if (matrix_debouncing[row] != cols) { | ||
74 | matrix_debouncing[row] = cols; | ||
75 | debouncing = DEBOUNCE; | ||
76 | } | ||
77 | } | ||
78 | |||
79 | if (debouncing) { | ||
80 | if (--debouncing) { | ||
81 | _delay_ms(1); | ||
82 | } else { | ||
83 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
84 | matrix[i] = matrix_debouncing[i]; | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | |||
89 | matrix_scan_quantum(); | ||
90 | |||
91 | return 1; | ||
92 | } | ||
93 | |||
94 | // declarations | ||
95 | void matrix_set_row_status(uint8_t row) { | ||
96 | DDRB = (1 << row); | ||
97 | PORTB = ~(1 << row); | ||
98 | } | ||
99 | |||
100 | uint8_t bit_reverse(uint8_t x) { | ||
101 | x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); | ||
102 | x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); | ||
103 | x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); | ||
104 | return x; | ||
105 | } | ||
106 | |||
107 | inline matrix_row_t matrix_get_row(uint8_t row) { | ||
108 | return matrix[row]; | ||
109 | } | ||
110 | |||
111 | void matrix_print(void) { | ||
112 | } | ||
diff --git a/keyboards/mechmini/v1/rules.mk b/keyboards/mechmini/v1/rules.mk index ee023b43b..1c6252c59 100644 --- a/keyboards/mechmini/v1/rules.mk +++ b/keyboards/mechmini/v1/rules.mk | |||
@@ -22,7 +22,3 @@ RGBLIGHT_ENABLE = yes | |||
22 | WS2812_DRIVER = i2c | 22 | WS2812_DRIVER = i2c |
23 | 23 | ||
24 | OPT_DEFS = -DDEBUG_LEVEL=0 | 24 | OPT_DEFS = -DDEBUG_LEVEL=0 |
25 | |||
26 | # custom matrix setup | ||
27 | CUSTOM_MATRIX = yes | ||
28 | SRC = matrix.c | ||
diff --git a/keyboards/mechmini/v1/v1.c b/keyboards/mechmini/v1/v1.c index 2c910d965..ba0e09520 100644 --- a/keyboards/mechmini/v1/v1.c +++ b/keyboards/mechmini/v1/v1.c | |||
@@ -16,13 +16,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include "v1.h" | 18 | #include "v1.h" |
19 | |||
20 | void matrix_init_kb(void) { matrix_init_user(); } | ||
21 | |||
22 | __attribute__ ((weak)) | ||
23 | void matrix_init_user(void) {} | ||
24 | |||
25 | void matrix_scan_kb(void) { matrix_scan_user(); } | ||
26 | |||
27 | __attribute__ ((weak)) | ||
28 | void matrix_scan_user(void) {} | ||
diff --git a/keyboards/mechmini/v1/v1.h b/keyboards/mechmini/v1/v1.h index 1e392b353..acdad5c6d 100644 --- a/keyboards/mechmini/v1/v1.h +++ b/keyboards/mechmini/v1/v1.h | |||
@@ -30,14 +30,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
30 | K00, K10, K20, K56, K57, KB0, KC0, K66 \ | 30 | K00, K10, K20, K56, K57, KB0, KC0, K66 \ |
31 | ) \ | 31 | ) \ |
32 | { \ | 32 | { \ |
33 | { K00, K10, K20, K56, KC_NO, K57, KC_NO, KC_NO, KB0, KC0, K66, KC_NO, KC_NO, KC_NO, KC_NO }, \ | 33 | { K00, K10, K20, K56, KC_NO, K57, KC_NO, KC_NO, KB0, KC0, K66, KC_NO }, \ |
34 | { K01, K11, K21, K31, K41, K51, K46, KE6, KE7, K47, KA1, KC_NO, KC_NO, KC_NO, KC_NO }, \ | 34 | { K01, K11, K21, K31, K41, K51, K46, KE6, KE7, K47, KA1, KC_NO }, \ |
35 | { K02, K12, K22, K32, K42, K52, K36, KD6, KD7, K37, KA2, KC_NO, KC_NO, KC_NO, KC_NO }, \ | 35 | { K02, K12, K22, K32, K42, K52, K36, KD6, KD7, K37, KA2, KC_NO }, \ |
36 | { K03, K13, K23, K33, K43, K53, K26, KC6, KC7, K27, KA3, KB3, KC_NO, KC_NO, KC_NO }, \ | 36 | { K03, K13, K23, K33, K43, K53, K26, KC6, KC7, K27, KA3, KB3 } \ |
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, 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 }, \ | ||
39 | { 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 }, \ | ||
40 | { 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 } \ | ||
41 | } | 37 | } |
42 | 38 | ||
43 | #define LAYOUT_split_space( \ | 39 | #define LAYOUT_split_space( \ |
@@ -47,14 +43,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
47 | K00, K10, K20, K56, K57, KB0, KC0, K66 \ | 43 | K00, K10, K20, K56, K57, KB0, KC0, K66 \ |
48 | ) \ | 44 | ) \ |
49 | { \ | 45 | { \ |
50 | { K00, K10, K20, K56, KC_NO, KC_NO, K57, KC_NO, KB0, KC0, K66, KC_NO, KC_NO, KC_NO, KC_NO }, \ | 46 | { K00, K10, K20, K56, KC_NO, KC_NO, K57, KC_NO, KB0, KC0, K66, KC_NO }, \ |
51 | { K01, K11, K21, K31, K41, K51, K46, KE6, KE7, K47, KA1, KC_NO, KC_NO, KC_NO, KC_NO }, \ | 47 | { K01, K11, K21, K31, K41, K51, K46, KE6, KE7, K47, KA1, KC_NO }, \ |
52 | { K02, K12, K22, K32, K42, K52, K36, KD6, KD7, K37, KA2, KC_NO, KC_NO, KC_NO, KC_NO }, \ | 48 | { K02, K12, K22, K32, K42, K52, K36, KD6, KD7, K37, KA2, KC_NO }, \ |
53 | { K03, K13, K23, K33, K43, K53, K26, KC6, KC7, K27, KA3, KB3, KC_NO, KC_NO, KC_NO }, \ | 49 | { K03, K13, K23, K33, K43, K53, K26, KC6, KC7, K27, KA3, KB3 } \ |
54 | { 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 }, \ | ||
55 | { 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 }, \ | ||
56 | { 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 }, \ | ||
57 | { 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 } \ | ||
58 | } | 50 | } |
59 | 51 | ||
60 | #endif | 52 | #endif |
diff --git a/keyboards/mehkee96/config.h b/keyboards/mehkee96/config.h index 4adfcc86b..d506626d1 100644 --- a/keyboards/mehkee96/config.h +++ b/keyboards/mehkee96/config.h | |||
@@ -12,6 +12,9 @@ | |||
12 | /* matrix size */ | 12 | /* matrix size */ |
13 | #define MATRIX_ROWS 8 | 13 | #define MATRIX_ROWS 8 |
14 | #define MATRIX_COLS 15 | 14 | #define MATRIX_COLS 15 |
15 | #define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 } | ||
16 | #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 } | ||
17 | #define DIODE_DIRECTION COL2ROW | ||
15 | 18 | ||
16 | #define RGBLED_NUM 16 | 19 | #define RGBLED_NUM 16 |
17 | #define RGBLIGHT_ANIMATIONS | 20 | #define RGBLIGHT_ANIMATIONS |
diff --git a/keyboards/mehkee96/keymaps/default/keymap.c b/keyboards/mehkee96/keymaps/default/keymap.c index cd69fb2fe..46ee4d19c 100644 --- a/keyboards/mehkee96/keymaps/default/keymap.c +++ b/keyboards/mehkee96/keymaps/default/keymap.c | |||
@@ -68,13 +68,3 @@ BL_TOGG, BL_DEC, BL_INC changes the in-switch LEDs | |||
68 | _______ , _______, _______, BL_DEC, BL_TOGG, BL_INC, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | 68 | _______ , _______, _______, BL_DEC, BL_TOGG, BL_INC, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, |
69 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), | 69 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), |
70 | }; | 70 | }; |
71 | |||
72 | void matrix_init_user(void) { | ||
73 | } | ||
74 | |||
75 | void matrix_scan_user(void) { | ||
76 | } | ||
77 | |||
78 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
79 | return true; | ||
80 | } | ||
diff --git a/keyboards/mehkee96/matrix.c b/keyboards/mehkee96/matrix.c deleted file mode 100644 index bbb84e52e..000000000 --- a/keyboards/mehkee96/matrix.c +++ /dev/null | |||
@@ -1,130 +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_set_row_status(uint8_t row); | ||
33 | uint8_t bit_reverse(uint8_t x); | ||
34 | |||
35 | __attribute__ ((weak)) | ||
36 | void matrix_init_kb(void) { | ||
37 | matrix_init_user(); | ||
38 | } | ||
39 | |||
40 | __attribute__ ((weak)) | ||
41 | void matrix_scan_kb(void) { | ||
42 | matrix_scan_user(); | ||
43 | } | ||
44 | |||
45 | __attribute__ ((weak)) | ||
46 | void matrix_init_user(void) { | ||
47 | } | ||
48 | |||
49 | __attribute__ ((weak)) | ||
50 | void matrix_scan_user(void) { | ||
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 | |||
72 | matrix_init_quantum(); | ||
73 | } | ||
74 | |||
75 | uint8_t matrix_scan(void) { | ||
76 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
77 | matrix_set_row_status(row); | ||
78 | _delay_us(5); | ||
79 | |||
80 | matrix_row_t cols = ( | ||
81 | // cols 0..7, PORTA 0 -> 7 | ||
82 | (~PINA) & 0xFF | ||
83 | ) | ( | ||
84 | // cols 8..13, PORTC 7 -> 0 | ||
85 | bit_reverse((~PINC) & 0xFF) << 8 | ||
86 | ) | ( | ||
87 | // col 14, PORTD 7 | ||
88 | ((~PIND) & (1 << PIND7)) << 7 | ||
89 | ); | ||
90 | |||
91 | if (matrix_debouncing[row] != cols) { | ||
92 | matrix_debouncing[row] = cols; | ||
93 | debouncing = DEBOUNCE; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | if (debouncing) { | ||
98 | if (--debouncing) { | ||
99 | _delay_ms(1); | ||
100 | } else { | ||
101 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
102 | matrix[i] = matrix_debouncing[i]; | ||
103 | } | ||
104 | } | ||
105 | } | ||
106 | |||
107 | matrix_scan_quantum(); | ||
108 | |||
109 | return 1; | ||
110 | } | ||
111 | |||
112 | // declarations | ||
113 | void matrix_set_row_status(uint8_t row) { | ||
114 | DDRB = (1 << row); | ||
115 | PORTB = ~(1 << row); | ||
116 | } | ||
117 | |||
118 | uint8_t bit_reverse(uint8_t x) { | ||
119 | x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); | ||
120 | x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); | ||
121 | x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); | ||
122 | return x; | ||
123 | } | ||
124 | |||
125 | inline matrix_row_t matrix_get_row(uint8_t row) { | ||
126 | return matrix[row]; | ||
127 | } | ||
128 | |||
129 | void matrix_print(void) { | ||
130 | } | ||
diff --git a/keyboards/mehkee96/mehkee96.c b/keyboards/mehkee96/mehkee96.c index 46427ec93..d9e2bac7a 100644 --- a/keyboards/mehkee96/mehkee96.c +++ b/keyboards/mehkee96/mehkee96.c | |||
@@ -16,13 +16,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include "mehkee96.h" | 18 | #include "mehkee96.h" |
19 | |||
20 | void matrix_init_kb(void) { matrix_init_user(); } | ||
21 | |||
22 | __attribute__ ((weak)) | ||
23 | void matrix_init_user(void) {} | ||
24 | |||
25 | void matrix_scan_kb(void) { matrix_scan_user(); } | ||
26 | |||
27 | __attribute__ ((weak)) | ||
28 | void matrix_scan_user(void) {} | ||
diff --git a/keyboards/mehkee96/rules.mk b/keyboards/mehkee96/rules.mk index 1cbd02948..a7d36548f 100644 --- a/keyboards/mehkee96/rules.mk +++ b/keyboards/mehkee96/rules.mk | |||
@@ -24,7 +24,3 @@ RGBLIGHT_ENABLE = yes | |||
24 | WS2812_DRIVER = i2c | 24 | WS2812_DRIVER = i2c |
25 | 25 | ||
26 | OPT_DEFS = -DDEBUG_LEVEL=0 | 26 | OPT_DEFS = -DDEBUG_LEVEL=0 |
27 | |||
28 | # custom matrix setup | ||
29 | CUSTOM_MATRIX = yes | ||
30 | SRC = matrix.c | ||
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 |
diff --git a/keyboards/percent/canoe/canoe.c b/keyboards/percent/canoe/canoe.c index e59b0dd7b..79c6330fe 100644 --- a/keyboards/percent/canoe/canoe.c +++ b/keyboards/percent/canoe/canoe.c | |||
@@ -17,16 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
17 | 17 | ||
18 | #include "canoe.h" | 18 | #include "canoe.h" |
19 | 19 | ||
20 | void matrix_init_kb(void) { matrix_init_user(); } | ||
21 | |||
22 | __attribute__ ((weak)) | ||
23 | void matrix_init_user(void) {} | ||
24 | |||
25 | void matrix_scan_kb(void) { matrix_scan_user(); } | ||
26 | |||
27 | __attribute__ ((weak)) | ||
28 | void matrix_scan_user(void) {} | ||
29 | |||
30 | #ifdef BACKLIGHT_ENABLE | 20 | #ifdef BACKLIGHT_ENABLE |
31 | void backlight_set(uint8_t level) { | 21 | void backlight_set(uint8_t level) { |
32 | if (level == 0) { | 22 | if (level == 0) { |
diff --git a/keyboards/percent/canoe/canoe.h b/keyboards/percent/canoe/canoe.h index 9e1e3e3d6..83d7c08bb 100644 --- a/keyboards/percent/canoe/canoe.h +++ b/keyboards/percent/canoe/canoe.h | |||
@@ -32,10 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
32 | { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E }, \ | 32 | { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E }, \ |
33 | { _x_, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E }, \ | 33 | { _x_, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E }, \ |
34 | { K30, _x_, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3E }, \ | 34 | { K30, _x_, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3E }, \ |
35 | { K40, _x_, K42, K43, K44, _x_, _x_, _x_, K48, _x_, K4A, K4B, K4C, K4D, K4E }, \ | 35 | { K40, _x_, K42, K43, K44, _x_, _x_, _x_, K48, _x_, K4A, K4B, K4C, K4D, K4E } \ |
36 | { _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_ }, \ | ||
37 | { _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_ }, \ | ||
38 | { _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_ } \ | ||
39 | } | 36 | } |
40 | 37 | ||
41 | #define LAYOUT_65_ansi_blocker( \ | 38 | #define LAYOUT_65_ansi_blocker( \ |
@@ -49,10 +46,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
49 | { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E }, \ | 46 | { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E }, \ |
50 | { _x_, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E }, \ | 47 | { _x_, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E }, \ |
51 | { K30, _x_, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3E }, \ | 48 | { K30, _x_, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3E }, \ |
52 | { K40, _x_, K42, K43, K44, _x_, _x_, _x_, K48, _x_, _x_, K4B, K4C, K4D, K4E }, \ | 49 | { K40, _x_, K42, K43, K44, _x_, _x_, _x_, K48, _x_, _x_, K4B, K4C, K4D, K4E } \ |
53 | { _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_ }, \ | ||
54 | { _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_ }, \ | ||
55 | { _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_ } \ | ||
56 | } | 50 | } |
57 | 51 | ||
58 | #define LAYOUT LAYOUT_65_ansi_blocker // added to not break existing checked in keymaps | 52 | #define LAYOUT LAYOUT_65_ansi_blocker // added to not break existing checked in keymaps |
diff --git a/keyboards/percent/canoe/config.h b/keyboards/percent/canoe/config.h index bae6ed20f..950e0806e 100644 --- a/keyboards/percent/canoe/config.h +++ b/keyboards/percent/canoe/config.h | |||
@@ -28,11 +28,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
28 | 28 | ||
29 | #define RGBLED_NUM 2 | 29 | #define RGBLED_NUM 2 |
30 | 30 | ||
31 | #define MATRIX_ROWS 8 | 31 | #define MATRIX_ROWS 5 |
32 | #define MATRIX_COLS 15 | 32 | #define MATRIX_COLS 15 |
33 | 33 | ||
34 | #define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 } | 34 | #define MATRIX_ROW_PINS { B0, B1, B2, B3, B4 } |
35 | #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, C1 } | 35 | #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 } |
36 | #define UNUSED_PINS | 36 | #define UNUSED_PINS |
37 | 37 | ||
38 | #define DIODE_DIRECTION COL2ROW | 38 | #define DIODE_DIRECTION COL2ROW |
diff --git a/keyboards/percent/canoe/matrix.c b/keyboards/percent/canoe/matrix.c deleted file mode 100644 index 245813dfd..000000000 --- a/keyboards/percent/canoe/matrix.c +++ /dev/null | |||
@@ -1,112 +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_set_row_status(uint8_t row); | ||
33 | uint8_t bit_reverse(uint8_t x); | ||
34 | |||
35 | void matrix_init(void) { | ||
36 | // all outputs for rows high | ||
37 | DDRB = 0xFF; | ||
38 | PORTB = 0xFF; | ||
39 | // all inputs for columns | ||
40 | DDRA = 0x00; | ||
41 | DDRC &= ~(0x111111<<2); | ||
42 | DDRD &= ~(1<<PIND7); | ||
43 | // all columns are pulled-up | ||
44 | PORTA = 0xFF; | ||
45 | PORTC |= (0b111111<<2); | ||
46 | PORTD |= (1<<PIND7); | ||
47 | |||
48 | // initialize matrix state: all keys off | ||
49 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
50 | matrix[row] = 0x00; | ||
51 | matrix_debouncing[row] = 0x00; | ||
52 | } | ||
53 | |||
54 | matrix_init_quantum(); | ||
55 | } | ||
56 | |||
57 | uint8_t matrix_scan(void) { | ||
58 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
59 | matrix_set_row_status(row); | ||
60 | _delay_us(5); | ||
61 | |||
62 | matrix_row_t cols = ( | ||
63 | // cols 0..7, PORTA 0 -> 7 | ||
64 | (~PINA) & 0xFF | ||
65 | ) | ( | ||
66 | // cols 8..13, PORTC 7 -> 0 | ||
67 | bit_reverse((~PINC) & 0xFF) << 8 | ||
68 | ) | ( | ||
69 | // col 14, PORTD 7 | ||
70 | ((~PIND) & (1 << PIND7)) << 7 | ||
71 | ); | ||
72 | |||
73 | if (matrix_debouncing[row] != cols) { | ||
74 | matrix_debouncing[row] = cols; | ||
75 | debouncing = DEBOUNCE; | ||
76 | } | ||
77 | } | ||
78 | |||
79 | if (debouncing) { | ||
80 | if (--debouncing) { | ||
81 | _delay_ms(1); | ||
82 | } else { | ||
83 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
84 | matrix[i] = matrix_debouncing[i]; | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | |||
89 | matrix_scan_quantum(); | ||
90 | |||
91 | return 1; | ||
92 | } | ||
93 | |||
94 | // declarations | ||
95 | void matrix_set_row_status(uint8_t row) { | ||
96 | DDRB = (1 << row); | ||
97 | PORTB = ~(1 << row); | ||
98 | } | ||
99 | |||
100 | uint8_t bit_reverse(uint8_t x) { | ||
101 | x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); | ||
102 | x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); | ||
103 | x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); | ||
104 | return x; | ||
105 | } | ||
106 | |||
107 | inline matrix_row_t matrix_get_row(uint8_t row) { | ||
108 | return matrix[row]; | ||
109 | } | ||
110 | |||
111 | void matrix_print(void) { | ||
112 | } | ||
diff --git a/keyboards/percent/canoe/rules.mk b/keyboards/percent/canoe/rules.mk index f2f6ee4e5..6340c8122 100644 --- a/keyboards/percent/canoe/rules.mk +++ b/keyboards/percent/canoe/rules.mk | |||
@@ -23,8 +23,4 @@ WS2812_DRIVER = i2c | |||
23 | 23 | ||
24 | OPT_DEFS = -DDEBUG_LEVEL=0 | 24 | OPT_DEFS = -DDEBUG_LEVEL=0 |
25 | 25 | ||
26 | # custom matrix setup | ||
27 | CUSTOM_MATRIX = yes | ||
28 | SRC = matrix.c | ||
29 | |||
30 | LAYOUTS = 65_ansi_blocker 65_iso_blocker | 26 | LAYOUTS = 65_ansi_blocker 65_iso_blocker |
diff --git a/keyboards/percent/skog/config.h b/keyboards/percent/skog/config.h index 7c68d797d..7a0c703ec 100644 --- a/keyboards/percent/skog/config.h +++ b/keyboards/percent/skog/config.h | |||
@@ -26,9 +26,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
26 | #define PRODUCT Skog TKL | 26 | #define PRODUCT Skog TKL |
27 | 27 | ||
28 | /* matrix size */ | 28 | /* matrix size */ |
29 | #define MATRIX_ROWS 8 | 29 | #define MATRIX_ROWS 7 |
30 | #define MATRIX_COLS 14 | 30 | #define MATRIX_COLS 14 |
31 | 31 | ||
32 | #define MATRIX_ROW_PINS { B0, B1, B2, B3, B5, B6, B7 } | ||
33 | #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2 } | ||
34 | #define DIODE_DIRECTION COL2ROW | ||
35 | |||
32 | #define RGBLED_NUM 2 | 36 | #define RGBLED_NUM 2 |
33 | #define RGBLIGHT_ANIMATIONS | 37 | #define RGBLIGHT_ANIMATIONS |
34 | 38 | ||
diff --git a/keyboards/percent/skog/keymaps/default/keymap.c b/keyboards/percent/skog/keymaps/default/keymap.c index eefc24cb0..282ce39a5 100644 --- a/keyboards/percent/skog/keymaps/default/keymap.c +++ b/keyboards/percent/skog/keymaps/default/keymap.c | |||
@@ -27,11 +27,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
27 | KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, KC_MENU, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT | 27 | KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, KC_MENU, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT |
28 | ) | 28 | ) |
29 | }; | 29 | }; |
30 | |||
31 | void matrix_init_user(void) { | ||
32 | |||
33 | } | ||
34 | |||
35 | void matrix_scan_user(void) { | ||
36 | |||
37 | } | ||
diff --git a/keyboards/percent/skog/matrix.c b/keyboards/percent/skog/matrix.c deleted file mode 100644 index 245813dfd..000000000 --- a/keyboards/percent/skog/matrix.c +++ /dev/null | |||
@@ -1,112 +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_set_row_status(uint8_t row); | ||
33 | uint8_t bit_reverse(uint8_t x); | ||
34 | |||
35 | void matrix_init(void) { | ||
36 | // all outputs for rows high | ||
37 | DDRB = 0xFF; | ||
38 | PORTB = 0xFF; | ||
39 | // all inputs for columns | ||
40 | DDRA = 0x00; | ||
41 | DDRC &= ~(0x111111<<2); | ||
42 | DDRD &= ~(1<<PIND7); | ||
43 | // all columns are pulled-up | ||
44 | PORTA = 0xFF; | ||
45 | PORTC |= (0b111111<<2); | ||
46 | PORTD |= (1<<PIND7); | ||
47 | |||
48 | // initialize matrix state: all keys off | ||
49 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
50 | matrix[row] = 0x00; | ||
51 | matrix_debouncing[row] = 0x00; | ||
52 | } | ||
53 | |||
54 | matrix_init_quantum(); | ||
55 | } | ||
56 | |||
57 | uint8_t matrix_scan(void) { | ||
58 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
59 | matrix_set_row_status(row); | ||
60 | _delay_us(5); | ||
61 | |||
62 | matrix_row_t cols = ( | ||
63 | // cols 0..7, PORTA 0 -> 7 | ||
64 | (~PINA) & 0xFF | ||
65 | ) | ( | ||
66 | // cols 8..13, PORTC 7 -> 0 | ||
67 | bit_reverse((~PINC) & 0xFF) << 8 | ||
68 | ) | ( | ||
69 | // col 14, PORTD 7 | ||
70 | ((~PIND) & (1 << PIND7)) << 7 | ||
71 | ); | ||
72 | |||
73 | if (matrix_debouncing[row] != cols) { | ||
74 | matrix_debouncing[row] = cols; | ||
75 | debouncing = DEBOUNCE; | ||
76 | } | ||
77 | } | ||
78 | |||
79 | if (debouncing) { | ||
80 | if (--debouncing) { | ||
81 | _delay_ms(1); | ||
82 | } else { | ||
83 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
84 | matrix[i] = matrix_debouncing[i]; | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | |||
89 | matrix_scan_quantum(); | ||
90 | |||
91 | return 1; | ||
92 | } | ||
93 | |||
94 | // declarations | ||
95 | void matrix_set_row_status(uint8_t row) { | ||
96 | DDRB = (1 << row); | ||
97 | PORTB = ~(1 << row); | ||
98 | } | ||
99 | |||
100 | uint8_t bit_reverse(uint8_t x) { | ||
101 | x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); | ||
102 | x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); | ||
103 | x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); | ||
104 | return x; | ||
105 | } | ||
106 | |||
107 | inline matrix_row_t matrix_get_row(uint8_t row) { | ||
108 | return matrix[row]; | ||
109 | } | ||
110 | |||
111 | void matrix_print(void) { | ||
112 | } | ||
diff --git a/keyboards/percent/skog/skog.c b/keyboards/percent/skog/skog.c index 8678d483a..1c26c550e 100644 --- a/keyboards/percent/skog/skog.c +++ b/keyboards/percent/skog/skog.c | |||
@@ -22,16 +22,6 @@ ps2avrGB support code by Kenneth A. (bminiex/.[ch]) | |||
22 | #include "backlight.h" | 22 | #include "backlight.h" |
23 | #include "backlight_custom.h" | 23 | #include "backlight_custom.h" |
24 | 24 | ||
25 | void matrix_init_kb(void) { matrix_init_user(); } | ||
26 | |||
27 | __attribute__ ((weak)) | ||
28 | void matrix_init_user(void) {} | ||
29 | |||
30 | void matrix_scan_kb(void) { matrix_scan_user(); } | ||
31 | |||
32 | __attribute__ ((weak)) | ||
33 | void matrix_scan_user(void) {} | ||
34 | |||
35 | #ifdef BACKLIGHT_ENABLE | 25 | #ifdef BACKLIGHT_ENABLE |
36 | /// Overrides functions in `quantum.c` | 26 | /// Overrides functions in `quantum.c` |
37 | void backlight_init_ports(void) { | 27 | void backlight_init_ports(void) { |
diff --git a/keyboards/percent/skog/skog.h b/keyboards/percent/skog/skog.h index 17be94621..c04a765b2 100644 --- a/keyboards/percent/skog/skog.h +++ b/keyboards/percent/skog/skog.h | |||
@@ -32,7 +32,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
32 | { K01, K11, K21, K31, K41, K51, K61, KC_NO, K81, K91, KA1, KB1, KC1, KD1 }, \ | 32 | { K01, K11, K21, K31, K41, K51, K61, KC_NO, K81, K91, KA1, KB1, KC1, KD1 }, \ |
33 | { K02, K12, K22, K32, K42, K52, K62, K72, K82, K92, KA2, KB2, KC2, KD2 }, \ | 33 | { K02, K12, K22, K32, K42, K52, K62, K72, K82, K92, KA2, KB2, KC2, KD2 }, \ |
34 | { K03, K13, K23, K33, K43, K53, K63, K73, K83, K93, KA3, KB3, KC3, KD3 }, \ | 34 | { K03, K13, K23, K33, K43, K53, K63, K73, K83, K93, KA3, KB3, KC3, KD3 }, \ |
35 | { 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 }, \ | ||
36 | { K05, K15, K25, K35, K45, K55, K65, K75, K85, K95, KA5, KB5, KC5, KC_NO }, \ | 35 | { K05, K15, K25, K35, K45, K55, K65, K75, K85, K95, KA5, KB5, KC5, KC_NO }, \ |
37 | { K06, K16, K26, K36, K46, K56, K66, K76, K86, K96, KA6, KB6, KC6, KD6 }, \ | 36 | { K06, K16, K26, K36, K46, K56, K66, K76, K86, K96, KA6, KB6, KC6, KD6 }, \ |
38 | { K07, K17, K27, K37, KC_NO, K57, KC_NO, KC_NO, K87, K97, KA7, KB7, KC7, KD7 } \ | 37 | { K07, K17, K27, K37, KC_NO, K57, KC_NO, KC_NO, K87, K97, KA7, KB7, KC7, KD7 } \ |
diff --git a/keyboards/winkeyless/bface/config.h b/keyboards/winkeyless/bface/config.h index 9d90e16a3..95d44557a 100644 --- a/keyboards/winkeyless/bface/config.h +++ b/keyboards/winkeyless/bface/config.h | |||
@@ -35,6 +35,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
35 | #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7} | 35 | #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7} |
36 | #define UNUSED_PINS | 36 | #define UNUSED_PINS |
37 | 37 | ||
38 | #define DIODE_DIRECTION COL2ROW | ||
39 | |||
38 | #define RGBLED_NUM 16 | 40 | #define RGBLED_NUM 16 |
39 | #define RGBLIGHT_ANIMATIONS | 41 | #define RGBLIGHT_ANIMATIONS |
40 | 42 | ||
diff --git a/keyboards/winkeyless/bmini/bmini.c b/keyboards/winkeyless/bmini/bmini.c index 87a31d052..f44fd36a8 100644 --- a/keyboards/winkeyless/bmini/bmini.c +++ b/keyboards/winkeyless/bmini/bmini.c | |||
@@ -16,6 +16,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include "bmini.h" | 18 | #include "bmini.h" |
19 | |||
20 | __attribute__ ((weak)) | ||
21 | void matrix_scan_user(void) {} | ||
diff --git a/keyboards/winkeyless/bmini/config.h b/keyboards/winkeyless/bmini/config.h index 37df80f80..f8a26e4f0 100644 --- a/keyboards/winkeyless/bmini/config.h +++ b/keyboards/winkeyless/bmini/config.h | |||
@@ -31,6 +31,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
31 | /* matrix size */ | 31 | /* matrix size */ |
32 | #define MATRIX_ROWS 8 | 32 | #define MATRIX_ROWS 8 |
33 | #define MATRIX_COLS 15 | 33 | #define MATRIX_COLS 15 |
34 | #define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 } | ||
35 | #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 } | ||
36 | #define DIODE_DIRECTION COL2ROW | ||
34 | 37 | ||
35 | #define RGBLIGHT_ANIMATIONS | 38 | #define RGBLIGHT_ANIMATIONS |
36 | 39 | ||
diff --git a/keyboards/winkeyless/bmini/matrix.c b/keyboards/winkeyless/bmini/matrix.c deleted file mode 100644 index 57aa36b5f..000000000 --- a/keyboards/winkeyless/bmini/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 | } | ||
diff --git a/keyboards/winkeyless/bmini/rules.mk b/keyboards/winkeyless/bmini/rules.mk index 7822bd830..530e8ea32 100644 --- a/keyboards/winkeyless/bmini/rules.mk +++ b/keyboards/winkeyless/bmini/rules.mk | |||
@@ -22,7 +22,3 @@ RGBLIGHT_ENABLE = yes | |||
22 | WS2812_DRIVER = i2c | 22 | WS2812_DRIVER = i2c |
23 | 23 | ||
24 | OPT_DEFS = -DDEBUG_LEVEL=0 | 24 | OPT_DEFS = -DDEBUG_LEVEL=0 |
25 | |||
26 | # custom matrix setup | ||
27 | CUSTOM_MATRIX = yes | ||
28 | SRC = matrix.c | ||
diff --git a/keyboards/winkeyless/bminiex/config.h b/keyboards/winkeyless/bminiex/config.h index 35c8ce933..037ca0028 100644 --- a/keyboards/winkeyless/bminiex/config.h +++ b/keyboards/winkeyless/bminiex/config.h | |||
@@ -30,6 +30,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
30 | /* matrix size */ | 30 | /* matrix size */ |
31 | #define MATRIX_ROWS 8 | 31 | #define MATRIX_ROWS 8 |
32 | #define MATRIX_COLS 15 | 32 | #define MATRIX_COLS 15 |
33 | #define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 } | ||
34 | #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 } | ||
35 | #define DIODE_DIRECTION COL2ROW | ||
33 | 36 | ||
34 | #define RGBLIGHT_ANIMATIONS | 37 | #define RGBLIGHT_ANIMATIONS |
35 | 38 | ||
diff --git a/keyboards/winkeyless/bminiex/matrix.c b/keyboards/winkeyless/bminiex/matrix.c deleted file mode 100644 index 8faaed8ac..000000000 --- a/keyboards/winkeyless/bminiex/matrix.c +++ /dev/null | |||
@@ -1,122 +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 "backlight.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_user(void) {} | ||
35 | __attribute__ ((weak)) | ||
36 | void matrix_scan_user(void) {} | ||
37 | __attribute__ ((weak)) | ||
38 | void matrix_init_kb(void) { | ||
39 | matrix_init_user(); | ||
40 | } | ||
41 | __attribute__ ((weak)) | ||
42 | void matrix_scan_kb(void) { | ||
43 | matrix_scan_user(); | ||
44 | } | ||
45 | |||
46 | void matrix_init(void) { | ||
47 | // all outputs for rows high | ||
48 | DDRB = 0xFF; | ||
49 | PORTB = 0xFF; | ||
50 | // all inputs for columns | ||
51 | DDRA = 0x00; | ||
52 | DDRC &= ~(0x111111<<2); | ||
53 | DDRD &= ~(1<<PIND7); | ||
54 | // all columns are pulled-up | ||
55 | PORTA = 0xFF; | ||
56 | PORTC |= (0b111111<<2); | ||
57 | PORTD |= (1<<PIND7); | ||
58 | |||
59 | // initialize matrix state: all keys off | ||
60 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
61 | matrix[row] = 0x00; | ||
62 | matrix_debouncing[row] = 0x00; | ||
63 | } | ||
64 | |||
65 | matrix_init_quantum(); | ||
66 | } | ||
67 | |||
68 | void matrix_set_row_status(uint8_t row) { | ||
69 | DDRB = (1 << row); | ||
70 | PORTB = ~(1 << row); | ||
71 | } | ||
72 | |||
73 | uint8_t bit_reverse(uint8_t x) { | ||
74 | x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); | ||
75 | x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); | ||
76 | x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); | ||
77 | return x; | ||
78 | } | ||
79 | |||
80 | uint8_t matrix_scan(void) { | ||
81 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
82 | matrix_set_row_status(row); | ||
83 | _delay_us(5); | ||
84 | |||
85 | matrix_row_t cols = ( | ||
86 | // cols 0..7, PORTA 0 -> 7 | ||
87 | (~PINA) & 0xFF | ||
88 | ) | ( | ||
89 | // cols 8..13, PORTC 7 -> 0 | ||
90 | bit_reverse((~PINC) & 0xFF) << 8 | ||
91 | ) | ( | ||
92 | // col 14, PORTD 7 | ||
93 | ((~PIND) & (1 << PIND7)) << 7 | ||
94 | ); | ||
95 | |||
96 | if (matrix_debouncing[row] != cols) { | ||
97 | matrix_debouncing[row] = cols; | ||
98 | debouncing = DEBOUNCE; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | if (debouncing) { | ||
103 | if (--debouncing) { | ||
104 | _delay_ms(1); | ||
105 | } else { | ||
106 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
107 | matrix[i] = matrix_debouncing[i]; | ||
108 | } | ||
109 | } | ||
110 | } | ||
111 | |||
112 | matrix_scan_quantum(); | ||
113 | |||
114 | return 1; | ||
115 | } | ||
116 | |||
117 | inline matrix_row_t matrix_get_row(uint8_t row) { | ||
118 | return matrix[row]; | ||
119 | } | ||
120 | |||
121 | void matrix_print(void) { | ||
122 | } | ||
diff --git a/keyboards/winkeyless/bminiex/rules.mk b/keyboards/winkeyless/bminiex/rules.mk index 39a77bda1..2c999dcbf 100644 --- a/keyboards/winkeyless/bminiex/rules.mk +++ b/keyboards/winkeyless/bminiex/rules.mk | |||
@@ -29,6 +29,4 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | |||
29 | 29 | ||
30 | OPT_DEFS = -DDEBUG_LEVEL=0 | 30 | OPT_DEFS = -DDEBUG_LEVEL=0 |
31 | 31 | ||
32 | # custom matrix setup | 32 | SRC += backlight.c |
33 | CUSTOM_MATRIX = yes | ||
34 | SRC = matrix.c backlight.c | ||
diff --git a/keyboards/ymd75/config.h b/keyboards/ymd75/config.h index a56a1b54b..00f6bd292 100644 --- a/keyboards/ymd75/config.h +++ b/keyboards/ymd75/config.h | |||
@@ -35,7 +35,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
35 | /* matrix size */ | 35 | /* matrix size */ |
36 | #define MATRIX_ROWS 8 | 36 | #define MATRIX_ROWS 8 |
37 | #define MATRIX_COLS 15 | 37 | #define MATRIX_COLS 15 |
38 | #define DIODE_DIRECTION ROW2COL | 38 | #define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 } |
39 | #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 } | ||
40 | #define DIODE_DIRECTION COL2ROW | ||
39 | 41 | ||
40 | #define BACKLIGHT_LEVELS 12 | 42 | #define BACKLIGHT_LEVELS 12 |
41 | 43 | ||
diff --git a/keyboards/ymd75/matrix.c b/keyboards/ymd75/matrix.c deleted file mode 100644 index a726ee889..000000000 --- a/keyboards/ymd75/matrix.c +++ /dev/null | |||
@@ -1,108 +0,0 @@ | |||
1 | /* | ||
2 | Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> | ||
3 | Modified 2018 by Wayne K Jones <github.com/WarmCatUK> | ||
4 | |||
5 | This program is free software: you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation, either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #include <avr/io.h> | ||
20 | #include <util/delay.h> | ||
21 | |||
22 | #include "matrix.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 | void matrix_init(void) { | ||
34 | // all outputs for rows high | ||
35 | DDRB = 0xFF; | ||
36 | PORTB = 0xFF; | ||
37 | // all inputs for columns | ||
38 | DDRA = 0x00; | ||
39 | DDRC &= ~(0x111111<<2); | ||
40 | DDRD &= ~(1<<PIND7); | ||
41 | // all columns are pulled-up | ||
42 | PORTA = 0xFF; | ||
43 | PORTC |= (0b111111<<2); | ||
44 | PORTD |= (1<<PIND7); | ||
45 | |||
46 | // initialize matrix state: all keys off | ||
47 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
48 | matrix[row] = 0x00; | ||
49 | matrix_debouncing[row] = 0x00; | ||
50 | } | ||
51 | matrix_init_quantum(); // missing from original port by Luiz | ||
52 | } | ||
53 | |||
54 | void matrix_set_row_status(uint8_t row) { | ||
55 | DDRB = (1 << row); | ||
56 | PORTB = ~(1 << row); | ||
57 | } | ||
58 | |||
59 | uint8_t bit_reverse(uint8_t x) { | ||
60 | x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); | ||
61 | x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); | ||
62 | x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); | ||
63 | return x; | ||
64 | } | ||
65 | |||
66 | uint8_t matrix_scan(void) { | ||
67 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
68 | matrix_set_row_status(row); | ||
69 | _delay_us(5); | ||
70 | |||
71 | matrix_row_t cols = ( | ||
72 | // cols 0..7, PORTA 0 -> 7 | ||
73 | (~PINA) & 0xFF | ||
74 | ) | ( | ||
75 | // cols 8..13, PORTC 7 -> 0 | ||
76 | bit_reverse((~PINC) & 0xFF) << 8 | ||
77 | ) | ( | ||
78 | // col 14, PORTD 7 | ||
79 | ((~PIND) & (1 << PIND7)) << 7 | ||
80 | ); | ||
81 | |||
82 | if (matrix_debouncing[row] != cols) { | ||
83 | matrix_debouncing[row] = cols; | ||
84 | debouncing = DEBOUNCE; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | if (debouncing) { | ||
89 | if (--debouncing) { | ||
90 | _delay_ms(1); | ||
91 | } else { | ||
92 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
93 | matrix[i] = matrix_debouncing[i]; | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | matrix_scan_quantum(); // also missing in original PS2AVRGB implementation | ||
98 | //matrix_scan_user(); | ||
99 | |||
100 | return 1; | ||
101 | } | ||
102 | |||
103 | inline matrix_row_t matrix_get_row(uint8_t row) { | ||
104 | return matrix[row]; | ||
105 | } | ||
106 | |||
107 | void matrix_print(void) { | ||
108 | } | ||
diff --git a/keyboards/ymd75/rules.mk b/keyboards/ymd75/rules.mk index 0c1c9110c..eb41e19cf 100644 --- a/keyboards/ymd75/rules.mk +++ b/keyboards/ymd75/rules.mk | |||
@@ -33,6 +33,4 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | |||
33 | 33 | ||
34 | #OPT_DEFS = -DDEBUG_LEVEL=0 | 34 | #OPT_DEFS = -DDEBUG_LEVEL=0 |
35 | 35 | ||
36 | # custom matrix setup | 36 | SRC = backlight.c |
37 | CUSTOM_MATRIX = yes | ||
38 | SRC = matrix.c backlight.c | ||
diff --git a/keyboards/ymd75/ymd75.c b/keyboards/ymd75/ymd75.c index 74f7c6a49..e32a745bf 100644 --- a/keyboards/ymd75/ymd75.c +++ b/keyboards/ymd75/ymd75.c | |||
@@ -20,16 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
20 | #include "backlight.h" | 20 | #include "backlight.h" |
21 | #include "backlight_custom.h" | 21 | #include "backlight_custom.h" |
22 | 22 | ||
23 | void matrix_init_kb(void) { matrix_init_user(); } | ||
24 | |||
25 | __attribute__ ((weak)) | ||
26 | void matrix_init_user(void) {} | ||
27 | |||
28 | void matrix_scan_kb(void) { matrix_scan_user(); } | ||
29 | |||
30 | __attribute__ ((weak)) | ||
31 | void matrix_scan_user(void) {} | ||
32 | |||
33 | #ifdef BACKLIGHT_ENABLE | 23 | #ifdef BACKLIGHT_ENABLE |
34 | /// Overrides functions in `quantum.c` | 24 | /// Overrides functions in `quantum.c` |
35 | void backlight_init_ports(void) { | 25 | void backlight_init_ports(void) { |
diff --git a/keyboards/ymd75/ymd75.h b/keyboards/ymd75/ymd75.h index e17dedeb3..0c9fff58c 100644 --- a/keyboards/ymd75/ymd75.h +++ b/keyboards/ymd75/ymd75.h | |||
@@ -25,8 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
25 | #include "keycode.h" | 25 | #include "keycode.h" |
26 | #include "action.h" | 26 | #include "action.h" |
27 | 27 | ||
28 | void matrix_init_user(void); | ||
29 | |||
30 | #define LAYOUT( \ | 28 | #define LAYOUT( \ |
31 | K05, K25, K35, K45, K55, K06, KA6, KA7, K07, KB5, KC5, KD5, KE5, KD1, KE1, KE2, \ | 29 | K05, K25, K35, K45, K55, K06, KA6, KA7, K07, KB5, KC5, KD5, KE5, KD1, KE1, KE2, \ |
32 | K04, K14, K24, K34, K44, K54, K16, KB6, KB7, K17, KA4, KB4, KC4, KE4, KD0, \ | 30 | K04, K14, K24, K34, K44, K54, K16, KB6, KB7, K17, KA4, KB4, KC4, KE4, KD0, \ |
diff --git a/keyboards/ymd96/config.h b/keyboards/ymd96/config.h index 5c496d8d2..1232f90c2 100644 --- a/keyboards/ymd96/config.h +++ b/keyboards/ymd96/config.h | |||
@@ -31,7 +31,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
31 | /* matrix size */ | 31 | /* matrix size */ |
32 | #define MATRIX_ROWS 8 | 32 | #define MATRIX_ROWS 8 |
33 | #define MATRIX_COLS 15 | 33 | #define MATRIX_COLS 15 |
34 | //#define DIODE_DIRECTION ROW2COL | 34 | #define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 } |
35 | #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 } | ||
35 | 36 | ||
36 | //#define RGB_DI_PIN C4 | 37 | //#define RGB_DI_PIN C4 |
37 | /* COL2ROW or ROW2COL */ | 38 | /* COL2ROW or ROW2COL */ |
diff --git a/keyboards/ymd96/matrix.c b/keyboards/ymd96/matrix.c deleted file mode 100644 index 2932976dd..000000000 --- a/keyboards/ymd96/matrix.c +++ /dev/null | |||
@@ -1,112 +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_set_row_status(uint8_t row); | ||
33 | uint8_t bit_reverse(uint8_t x); | ||
34 | |||
35 | void matrix_init(void) { | ||
36 | // all outputs for rows high | ||
37 | DDRB = 0xFF; | ||
38 | PORTB = 0xFF; | ||
39 | // all inputs for columns | ||
40 | DDRA = 0x00; | ||
41 | DDRC &= ~(0x111111<<2); | ||
42 | DDRD &= ~(1<<PIND7); | ||
43 | // all columns are pulled-up | ||
44 | PORTA = 0xFF; | ||
45 | PORTC |= (0b111111<<2); | ||
46 | PORTD |= (1<<PIND7); | ||
47 | |||
48 | // initialize matrix state: all keys off | ||
49 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
50 | matrix[row] = 0x00; | ||
51 | matrix_debouncing[row] = 0x00; | ||
52 | } | ||
53 | |||
54 | matrix_init_quantum(); // missing from original port by Luiz | ||
55 | } | ||
56 | |||
57 | uint8_t matrix_scan(void) { | ||
58 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
59 | matrix_set_row_status(row); | ||
60 | _delay_us(5); | ||
61 | |||
62 | matrix_row_t cols = ( | ||
63 | // cols 0..7, PORTA 0 -> 7 | ||
64 | (~PINA) & 0xFF | ||
65 | ) | ( | ||
66 | // cols 8..13, PORTC 7 -> 0 | ||
67 | bit_reverse((~PINC) & 0xFF) << 8 | ||
68 | ) | ( | ||
69 | // col 14, PORTD 7 | ||
70 | ((~PIND) & (1 << PIND7)) << 7 | ||
71 | ); | ||
72 | |||
73 | if (matrix_debouncing[row] != cols) { | ||
74 | matrix_debouncing[row] = cols; | ||
75 | debouncing = DEBOUNCE; | ||
76 | } | ||
77 | } | ||
78 | |||
79 | if (debouncing) { | ||
80 | if (--debouncing) { | ||
81 | _delay_ms(1); | ||
82 | } else { | ||
83 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
84 | matrix[i] = matrix_debouncing[i]; | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | |||
89 | matrix_scan_quantum(); // also missing in original PS2AVRGB implementation | ||
90 | |||
91 | return 1; | ||
92 | } | ||
93 | |||
94 | // declarations | ||
95 | void matrix_set_row_status(uint8_t row) { | ||
96 | DDRB = (1 << row); | ||
97 | PORTB = ~(1 << row); | ||
98 | } | ||
99 | |||
100 | uint8_t bit_reverse(uint8_t x) { | ||
101 | x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); | ||
102 | x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); | ||
103 | x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); | ||
104 | return x; | ||
105 | } | ||
106 | |||
107 | inline matrix_row_t matrix_get_row(uint8_t row) { | ||
108 | return matrix[row]; | ||
109 | } | ||
110 | |||
111 | void matrix_print(void) { | ||
112 | } | ||
diff --git a/keyboards/ymd96/rules.mk b/keyboards/ymd96/rules.mk index 19d9fd81a..3c892daab 100644 --- a/keyboards/ymd96/rules.mk +++ b/keyboards/ymd96/rules.mk | |||
@@ -31,6 +31,4 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | |||
31 | 31 | ||
32 | OPT_DEFS = -DDEBUG_LEVEL=0 | 32 | OPT_DEFS = -DDEBUG_LEVEL=0 |
33 | 33 | ||
34 | # custom matrix setup | 34 | SRC = backlight.c |
35 | CUSTOM_MATRIX = yes | ||
36 | SRC = matrix.c backlight.c | ||
diff --git a/keyboards/ymd96/ymd96.c b/keyboards/ymd96/ymd96.c index 546a4c6e3..eae84ade1 100644 --- a/keyboards/ymd96/ymd96.c +++ b/keyboards/ymd96/ymd96.c | |||
@@ -21,16 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
21 | #include "backlight.h" | 21 | #include "backlight.h" |
22 | #include "backlight_custom.h" | 22 | #include "backlight_custom.h" |
23 | 23 | ||
24 | void matrix_init_kb(void) { matrix_init_user(); } | ||
25 | |||
26 | __attribute__ ((weak)) | ||
27 | void matrix_init_user(void) {} | ||
28 | |||
29 | void matrix_scan_kb(void) { matrix_scan_user(); } | ||
30 | |||
31 | __attribute__ ((weak)) | ||
32 | void matrix_scan_user(void) {} | ||
33 | |||
34 | #ifdef BACKLIGHT_ENABLE | 24 | #ifdef BACKLIGHT_ENABLE |
35 | /// Overrides functions in `quantum.c` | 25 | /// Overrides functions in `quantum.c` |
36 | void backlight_init_ports(void) { | 26 | void backlight_init_ports(void) { |
diff --git a/keyboards/ymd96/ymd96.h b/keyboards/ymd96/ymd96.h index a516297c1..c89be7168 100644 --- a/keyboards/ymd96/ymd96.h +++ b/keyboards/ymd96/ymd96.h | |||
@@ -20,8 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
20 | 20 | ||
21 | #include "quantum.h" | 21 | #include "quantum.h" |
22 | 22 | ||
23 | void matrix_init_user(void); // TODO port this to other PS2AVRGB boards | ||
24 | |||
25 | #define LAYOUT_default( \ | 23 | #define LAYOUT_default( \ |
26 | K50, K52, K53, K54, K55, K60, K6A, K7A, K70, K5B, K5C, K5D, K5E, K1D, K2E, K0D, K76, K79, K78, \ | 24 | K50, K52, K53, K54, K55, K60, K6A, K7A, K70, K5B, K5C, K5D, K5E, K1D, K2E, K0D, K76, K79, K78, \ |
27 | K40, K41, K42, K43, K44, K45, K61, K6B, K7B, K71, K4A, K4B, K4C, K4E, K46, K47, K48, K49, \ | 25 | K40, K41, K42, K43, K44, K45, K61, K6B, K7B, K71, K4A, K4B, K4C, K4E, K46, K47, K48, K49, \ |
diff --git a/keyboards/ymdk/bface/config.h b/keyboards/ymdk/bface/config.h index 9e5a9134f..2273b7e84 100644 --- a/keyboards/ymdk/bface/config.h +++ b/keyboards/ymdk/bface/config.h | |||
@@ -34,6 +34,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
34 | #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7} | 34 | #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7} |
35 | #define UNUSED_PINS | 35 | #define UNUSED_PINS |
36 | 36 | ||
37 | #define DIODE_DIRECTION COL2ROW | ||
38 | |||
37 | #define NO_UART 1 | 39 | #define NO_UART 1 |
38 | 40 | ||
39 | #define BACKLIGHT_PIN D4 | 41 | #define BACKLIGHT_PIN D4 |
diff --git a/keyboards/ymdk/bface/rules.mk b/keyboards/ymdk/bface/rules.mk index 7b829530b..f6f026cf3 100644 --- a/keyboards/ymdk/bface/rules.mk +++ b/keyboards/ymdk/bface/rules.mk | |||
@@ -1,18 +1,3 @@ | |||
1 | # Copyright 2019 Ethan Durrant (emdarcher) | ||
2 | # | ||
3 | # This program is free software: you can redistribute it and/or modify | ||
4 | # it under the terms of the GNU General Public License as published by | ||
5 | # the Free Software Foundation, either version 2 of the License, or | ||
6 | # (at your option) any later version. | ||
7 | # | ||
8 | # This program is distributed in the hope that it will be useful, | ||
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | # GNU General Public License for more details. | ||
12 | # | ||
13 | # You should have received a copy of the GNU General Public License | ||
14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | |||
16 | # MCU name | 1 | # MCU name |
17 | MCU = atmega32a | 2 | MCU = atmega32a |
18 | 3 | ||
diff --git a/keyboards/ymdk_np21/config.h b/keyboards/ymdk_np21/config.h index 4a846f5e9..60c527776 100644 --- a/keyboards/ymdk_np21/config.h +++ b/keyboards/ymdk_np21/config.h | |||
@@ -29,8 +29,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
29 | #define PRODUCT np21 | 29 | #define PRODUCT np21 |
30 | 30 | ||
31 | /* matrix size */ | 31 | /* matrix size */ |
32 | #define MATRIX_ROWS 8 | 32 | #define MATRIX_ROWS 4 |
33 | #define MATRIX_COLS 15 | 33 | #define MATRIX_COLS 6 |
34 | #define MATRIX_ROW_PINS { B0, B1, B2, B3 } | ||
35 | #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5 } | ||
34 | 36 | ||
35 | /* COL2ROW or ROW2COL */ | 37 | /* COL2ROW or ROW2COL */ |
36 | #define DIODE_DIRECTION COL2ROW | 38 | #define DIODE_DIRECTION COL2ROW |
diff --git a/keyboards/ymdk_np21/matrix.c b/keyboards/ymdk_np21/matrix.c deleted file mode 100644 index b2bfb2f0b..000000000 --- a/keyboards/ymdk_np21/matrix.c +++ /dev/null | |||
@@ -1,129 +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_set_row_status(uint8_t row); | ||
33 | uint8_t bit_reverse(uint8_t x); | ||
34 | |||
35 | void matrix_init(void) { | ||
36 | // all outputs for rows high | ||
37 | DDRB = 0xFF; | ||
38 | PORTB = 0xFF; | ||
39 | // all inputs for columns | ||
40 | DDRA = 0x00; | ||
41 | DDRC &= ~(0x111111<<2); | ||
42 | DDRD &= ~(1<<PIND7); | ||
43 | // all columns are pulled-up | ||
44 | PORTA = 0xFF; | ||
45 | PORTC |= (0b111111<<2); | ||
46 | PORTD |= (1<<PIND7); | ||
47 | |||
48 | // initialize matrix state: all keys off | ||
49 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
50 | matrix[row] = 0x00; | ||
51 | matrix_debouncing[row] = 0x00; | ||
52 | } | ||
53 | |||
54 | matrix_init_quantum(); // missing from original port by Luiz | ||
55 | } | ||
56 | |||
57 | uint8_t matrix_scan(void) { | ||
58 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
59 | matrix_set_row_status(row); | ||
60 | _delay_us(5); | ||
61 | |||
62 | matrix_row_t cols = ( | ||
63 | // cols 0..7, PORTA 0 -> 7 | ||
64 | (~PINA) & 0xFF | ||
65 | ) | ( | ||
66 | // cols 8..13, PORTC 7 -> 0 | ||
67 | bit_reverse((~PINC) & 0xFF) << 8 | ||
68 | ) | ( | ||
69 | // col 14, PORTD 7 | ||
70 | ((~PIND) & (1 << PIND7)) << 7 | ||
71 | ); | ||
72 | |||
73 | if (matrix_debouncing[row] != cols) { | ||
74 | matrix_debouncing[row] = cols; | ||
75 | debouncing = DEBOUNCE; | ||
76 | } | ||
77 | } | ||
78 | |||
79 | if (debouncing) { | ||
80 | if (--debouncing) { | ||
81 | _delay_ms(1); | ||
82 | } else { | ||
83 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
84 | matrix[i] = matrix_debouncing[i]; | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | |||
89 | matrix_scan_quantum(); // also missing in original PS2AVRGB implementation | ||
90 | |||
91 | return 1; | ||
92 | } | ||
93 | |||
94 | __attribute__ ((weak)) | ||
95 | void matrix_scan_user(void) {}; | ||
96 | |||
97 | __attribute__ ((weak)) | ||
98 | void matrix_scan_kb(void) { | ||
99 | // Looping keyboard code goes here | ||
100 | // This runs every cycle (a lot) | ||
101 | matrix_scan_user(); | ||
102 | }; | ||
103 | |||
104 | __attribute__ ((weak)) | ||
105 | void matrix_init_user(void) {}; | ||
106 | |||
107 | __attribute__ ((weak)) | ||
108 | void matrix_init_kb(void) { | ||
109 | matrix_init_user(); | ||
110 | } | ||
111 | // declarations | ||
112 | void matrix_set_row_status(uint8_t row) { | ||
113 | DDRB = (1 << row); | ||
114 | PORTB = ~(1 << row); | ||
115 | } | ||
116 | |||
117 | uint8_t bit_reverse(uint8_t x) { | ||
118 | x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); | ||
119 | x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); | ||
120 | x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); | ||
121 | return x; | ||
122 | } | ||
123 | |||
124 | inline matrix_row_t matrix_get_row(uint8_t row) { | ||
125 | return matrix[row]; | ||
126 | } | ||
127 | |||
128 | void matrix_print(void) { | ||
129 | } | ||
diff --git a/keyboards/ymdk_np21/rules.mk b/keyboards/ymdk_np21/rules.mk index 2bab3043e..772bee928 100644 --- a/keyboards/ymdk_np21/rules.mk +++ b/keyboards/ymdk_np21/rules.mk | |||
@@ -31,6 +31,4 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | |||
31 | 31 | ||
32 | OPT_DEFS = -DDEBUG_LEVEL=0 | 32 | OPT_DEFS = -DDEBUG_LEVEL=0 |
33 | 33 | ||
34 | # custom matrix setup | 34 | SRC = backlight.c |
35 | CUSTOM_MATRIX = yes | ||
36 | SRC = matrix.c backlight.c | ||
diff --git a/keyboards/ymdk_np21/ymdk_np21.h b/keyboards/ymdk_np21/ymdk_np21.h index 728406d6e..2cd2d13c2 100644 --- a/keyboards/ymdk_np21/ymdk_np21.h +++ b/keyboards/ymdk_np21/ymdk_np21.h | |||
@@ -23,8 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
23 | #include "keycode.h" | 23 | #include "keycode.h" |
24 | #include "action.h" | 24 | #include "action.h" |
25 | 25 | ||
26 | void matrix_init_user(void); // TODO port this to other PS2AVRGB boards | ||
27 | |||
28 | #define LAYOUT( \ | 26 | #define LAYOUT( \ |
29 | K01, K02, K03, K04, K05, K06, \ | 27 | K01, K02, K03, K04, K05, K06, \ |
30 | K11, K12, K13, K14, K15, K16, \ | 28 | K11, K12, K13, K14, K15, K16, \ |