diff options
author | fauxpark <fauxpark@gmail.com> | 2020-01-02 17:45:41 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-02 17:45:41 +1100 |
commit | 2557bc8e6f6e61352fa5875646d861126c42a3b0 (patch) | |
tree | 40ef2cb1a51c31a2eaa9d43414a7e88c83181dd2 /keyboards/ymd75 | |
parent | b83e3ae556239b4aa6f2c4db20535c536692eb3b (diff) | |
download | qmk_firmware-2557bc8e6f6e61352fa5875646d861126c42a3b0.tar.gz qmk_firmware-2557bc8e6f6e61352fa5875646d861126c42a3b0.zip |
Remove custom matrix from PS2AVRGB boards (#7396)
* Remove custom matrix from PS2AVRGB boards
* Add custom backlight.c to SRC for bminiex, for now
* Add missing DIODE_DIRECTIONs
Diffstat (limited to 'keyboards/ymd75')
-rw-r--r-- | keyboards/ymd75/config.h | 4 | ||||
-rw-r--r-- | keyboards/ymd75/matrix.c | 108 | ||||
-rw-r--r-- | keyboards/ymd75/rules.mk | 4 | ||||
-rw-r--r-- | keyboards/ymd75/ymd75.c | 10 | ||||
-rw-r--r-- | keyboards/ymd75/ymd75.h | 2 |
5 files changed, 4 insertions, 124 deletions
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, \ |