aboutsummaryrefslogtreecommitdiff
path: root/keyboards/bpiphany/pegasushoof/2013
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/bpiphany/pegasushoof/2013')
-rw-r--r--keyboards/bpiphany/pegasushoof/2013/.noci0
-rw-r--r--keyboards/bpiphany/pegasushoof/2013/2013.c25
-rw-r--r--keyboards/bpiphany/pegasushoof/2013/2013.h82
-rw-r--r--keyboards/bpiphany/pegasushoof/2013/config.h36
-rw-r--r--keyboards/bpiphany/pegasushoof/2013/matrix.c222
-rw-r--r--keyboards/bpiphany/pegasushoof/2013/rules.mk2
6 files changed, 367 insertions, 0 deletions
diff --git a/keyboards/bpiphany/pegasushoof/2013/.noci b/keyboards/bpiphany/pegasushoof/2013/.noci
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/keyboards/bpiphany/pegasushoof/2013/.noci
diff --git a/keyboards/bpiphany/pegasushoof/2013/2013.c b/keyboards/bpiphany/pegasushoof/2013/2013.c
new file mode 100644
index 000000000..c9bd01a99
--- /dev/null
+++ b/keyboards/bpiphany/pegasushoof/2013/2013.c
@@ -0,0 +1,25 @@
1/*
2Copyright 2016 Daniel Svensson <[email protected]>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include "2013.h"
19
20
21extern inline void ph_caps_led_on(void);
22extern inline void ph_caps_led_off(void);
23
24extern inline void ph_sclk_led_on(void);
25extern inline void ph_sclk_led_off(void);
diff --git a/keyboards/bpiphany/pegasushoof/2013/2013.h b/keyboards/bpiphany/pegasushoof/2013/2013.h
new file mode 100644
index 000000000..7a4d7f0b5
--- /dev/null
+++ b/keyboards/bpiphany/pegasushoof/2013/2013.h
@@ -0,0 +1,82 @@
1/*
2Copyright 2016 Daniel Svensson <[email protected]>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#pragma once
19
20#include "matrix.h"
21#include "quantum.h"
22
23#define LAYOUT( \
24 KG6, KH4, KI4, KI2, KI6, KP5, KL6, KM2, KM4, KO4, KO5, KO6, KO0, KN5, KN7, KP7, \
25 KG4, KG5, KH5, KI5, KJ5, KJ4, KK4, KK5, KL5, KM5, KF5, KF4, KL4, KO2, KR4, KC4, KE4, \
26 KG2, KG7, KH7, KI7, KJ7, KJ2, KK2, KK7, KL7, KM7, KF7, KF2, KL2, KO3, KQ4, KC5, KE5, \
27 KH2, KG3, KH3, KI3, KJ3, KJ6, KK6, KK3, KL3, KM3, KF3, KF6, KO1, \
28 KB2, KH6, KG1, KH1, KI1, KJ1, KJ0, KK0, KK1, KL1, KM1, KF0, KB3, KC6, \
29 KP4, KD2, KN6, KQ6, KN0, KA3, KM0, KP1, KC0, KQ0, KR0 \
30 ) { /* 00-A 01-B 02-C 03-D 04-E 05-F 06-G 07-H 08-I 09-J 10-K 11-L 12-M 13-N 14-O 15-P 16-Q 17-R */ \
31 /* 0 */ { KC_NO , KC_NO , KC0 , KC_NO , KC_NO , KF0 , KC_NO , KC_NO , KC_NO , KJ0 , KK0 , KC_NO , KM0 , KN0 , KO0 , KC_NO , KQ0 , KR0 }, \
32 /* 1 */ { KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KG1 , KH1 , KI1 , KJ1 , KK1 , KL1 , KM1 , KC_NO , KO1 , KP1 , KC_NO , KC_NO }, \
33 /* 2 */ { KC_NO , KB2 , KC_NO , KD2 , KC_NO , KF2 , KG2 , KH2 , KI2 , KJ2 , KK2 , KL2 , KM2 , KC_NO , KO2 , KC_NO , KC_NO , KC_NO }, \
34 /* 3 */ { KA3 , KB3 , KC_NO , KC_NO , KC_NO , KF3 , KG3 , KH3 , KI3 , KJ3 , KK3 , KL3 , KM3 , KC_NO , KO3 , KC_NO , KC_NO , KC_NO }, \
35 /* 4 */ { KC_NO , KC_NO , KC4 , KC_NO , KE4 , KF4 , KG4 , KH4 , KI4 , KJ4 , KK4 , KL4 , KM4 , KC_NO , KO4 , KP4 , KQ4 , KR4 }, \
36 /* 5 */ { KC_NO , KC_NO , KC5 , KC_NO , KE5 , KF5 , KG5 , KH5 , KI5 , KJ5 , KK5 , KL5 , KM5 , KN5 , KO5 , KP5 , KC_NO , KC_NO }, \
37 /* 6 */ { KC_NO , KC_NO , KC6 , KC_NO , KC_NO , KF6 , KG6 , KH6 , KI6 , KJ6 , KK6 , KL6 , KC_NO , KN6 , KO6 , KC_NO , KQ6 , KC_NO }, \
38 /* 7 */ { KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KF7 , KG7 , KH7 , KI7 , KJ7 , KK7 , KL7 , KM7 , KN7 , KC_NO , KP7 , KC_NO , KC_NO } \
39 }
40
41#define LAYOUT_tkl_ansi( \
42 KG6, KH4, KI4, KI2, KI6, KP5, KL6, KM2, KM4, KO4, KO5, KO6, KO0, KN5, KN7, KP7, \
43 KG4, KG5, KH5, KI5, KJ5, KJ4, KK4, KK5, KL5, KM5, KF5, KF4, KL4, KO2, KR4, KC4, KE4, \
44 KG2, KG7, KH7, KI7, KJ7, KJ2, KK2, KK7, KL7, KM7, KF7, KF2, KL2, KO3, KQ4, KC5, KE5, \
45 KH2, KG3, KH3, KI3, KJ3, KJ6, KK6, KK3, KL3, KM3, KF3, KF6, KO1, \
46 KB2, KG1, KH1, KI1, KJ1, KJ0, KK0, KK1, KL1, KM1, KF0, KB3, KC6, \
47 KP4, KD2, KN6, KQ6, KN0, KA3, KM0, KP1, KC0, KQ0, KR0 \
48 ) { /* 00-A 01-B 02-C 03-D 04-E 05-F 06-G 07-H 08-I 09-J 10-K 11-L 12-M 13-N 14-O 15-P 16-Q 17-R */ \
49 /* 0 */ { KC_NO , KC_NO , KC0 , KC_NO , KC_NO , KF0 , KC_NO , KC_NO , KC_NO , KJ0 , KK0 , KC_NO , KM0 , KN0 , KO0 , KC_NO , KQ0 , KR0 }, \
50 /* 1 */ { KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KG1 , KH1 , KI1 , KJ1 , KK1 , KL1 , KM1 , KC_NO , KO1 , KP1 , KC_NO , KC_NO }, \
51 /* 2 */ { KC_NO , KB2 , KC_NO , KD2 , KC_NO , KF2 , KG2 , KH2 , KI2 , KJ2 , KK2 , KL2 , KM2 , KC_NO , KO2 , KC_NO , KC_NO , KC_NO }, \
52 /* 3 */ { KA3 , KB3 , KC_NO , KC_NO , KC_NO , KF3 , KG3 , KH3 , KI3 , KJ3 , KK3 , KL3 , KM3 , KC_NO , KO3 , KC_NO , KC_NO , KC_NO }, \
53 /* 4 */ { KC_NO , KC_NO , KC4 , KC_NO , KE4 , KF4 , KG4 , KH4 , KI4 , KJ4 , KK4 , KL4 , KM4 , KC_NO , KO4 , KP4 , KQ4 , KR4 }, \
54 /* 5 */ { KC_NO , KC_NO , KC5 , KC_NO , KE5 , KF5 , KG5 , KH5 , KI5 , KJ5 , KK5 , KL5 , KM5 , KN5 , KO5 , KP5 , KC_NO , KC_NO }, \
55 /* 6 */ { KC_NO , KC_NO , KC6 , KC_NO , KC_NO , KF6 , KG6 , KC_NO , KI6 , KJ6 , KK6 , KL6 , KC_NO , KN6 , KO6 , KC_NO , KQ6 , KC_NO }, \
56 /* 7 */ { KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KF7 , KG7 , KH7 , KI7 , KJ7 , KK7 , KL7 , KM7 , KN7 , KC_NO , KP7 , KC_NO , KC_NO } \
57 }
58
59#define LAYOUT_tkl_jis( \
60 KG6, KH4, KI4, KI2, KI6, KP5, KL6, KM2, KM4, KO4, KO5, KO6, KO0, KN5, KN7, KP7, \
61 KG4, KG5, KH5, KI5, KJ5, KJ4, KK4, KK5, KL5, KM5, KF5, KF4, KL4, KO7, KO2, KR4, KC4, KE4, \
62 KG2, KG7, KH7, KI7, KJ7, KJ2, KK2, KK7, KL7, KM7, KF7, KF2, KL2, KQ4, KC5, KE5, \
63 KH2, KG3, KH3, KI3, KJ3, KJ6, KK6, KK3, KL3, KM3, KF3, KF6, KO3, KO1, \
64 KB2, KG1, KH1, KI1, KJ1, KJ0, KK0, KK1, KL1, KM1, KF0, KL0, KB3, KC6, \
65 KP4, KD2, KN6, KG0, KQ6, KH0, KI0, KN0, KM0, KP1, KC0, KQ0, KR0 \
66 ) { /* 00-A 01-B 02-C 03-D 04-E 05-F 06-G 07-H 08-I 09-J 10-K 11-L 12-M 13-N 14-O 15-P 16-Q 17-R */ \
67 /* 0 */ { KC_NO, KC_NO, KC0, KC_NO, KC_NO, KF0, KG0, KH0, KI0, KJ0, KK0, KL0, KM0, KN0, KO0, KC_NO, KQ0, KR0 }, \
68 /* 1 */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KG1, KH1, KI1, KJ1, KK1, KL1, KM1, KC_NO, KO1, KP1, KC_NO, KC_NO }, \
69 /* 2 */ { KC_NO, KB2, KC_NO, KD2, KC_NO, KF2, KG2, KH2, KI2, KJ2, KK2, KL2, KM2, KC_NO, KO2, KC_NO, KC_NO, KC_NO }, \
70 /* 3 */ { KC_NO, KB3, KC_NO, KC_NO, KC_NO, KF3, KG3, KH3, KI3, KJ3, KK3, KL3, KM3, KC_NO, KO3, KC_NO, KC_NO, KC_NO }, \
71 /* 4 */ { KC_NO, KC_NO, KC4, KC_NO, KE4, KF4, KG4, KH4, KI4, KJ4, KK4, KL4, KM4, KC_NO, KO4, KP4, KQ4, KR4 }, \
72 /* 5 */ { KC_NO, KC_NO, KC5, KC_NO, KE5, KF5, KG5, KH5, KI5, KJ5, KK5, KL5, KM5, KN5, KO5, KP5, KC_NO, KC_NO }, \
73 /* 6 */ { KC_NO, KC_NO, KC6, KC_NO, KC_NO, KF6, KG6, KC_NO, KI6, KJ6, KK6, KL6, KC_NO, KN6, KO6, KC_NO, KQ6, KC_NO }, \
74 /* 7 */ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KF7, KG7, KH7, KI7, KJ7, KK7, KL7, KK7, KL7, KO7, KP7, KC_NO, KC_NO } \
75}
76
77inline void ph_caps_led_on(void) { DDRC |= (1<<6); PORTC &= ~(1<<6); }
78inline void ph_caps_led_off(void) { DDRC &= ~(1<<6); PORTC &= ~(1<<6); }
79
80inline void ph_sclk_led_on(void) { DDRC |= (1<<5); PORTC &= ~(1<<5); }
81inline void ph_sclk_led_off(void) { DDRC &= ~(1<<5); PORTC &= ~(1<<5); }
82
diff --git a/keyboards/bpiphany/pegasushoof/2013/config.h b/keyboards/bpiphany/pegasushoof/2013/config.h
new file mode 100644
index 000000000..2573cecfc
--- /dev/null
+++ b/keyboards/bpiphany/pegasushoof/2013/config.h
@@ -0,0 +1,36 @@
1/*
2Copyright 2016 Daniel Svensson <[email protected]>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#pragma once
19
20
21/* USB Device descriptor parameter */
22#define VENDOR_ID 0xFEED
23#define PRODUCT_ID 0x6050
24#define DEVICE_VER 0x0104
25#define MANUFACTURER Filco
26#define PRODUCT Majestouch TKL \\w The Pegasus Hoof 2013
27
28/* key matrix size */
29#define MATRIX_ROWS 8
30#define MATRIX_COLS 18
31
32/* COL2ROW or ROW2COL */
33#define DIODE_DIRECTION COL2ROW
34
35/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
36#define DEBOUNCE 5
diff --git a/keyboards/bpiphany/pegasushoof/2013/matrix.c b/keyboards/bpiphany/pegasushoof/2013/matrix.c
new file mode 100644
index 000000000..037f323c0
--- /dev/null
+++ b/keyboards/bpiphany/pegasushoof/2013/matrix.c
@@ -0,0 +1,222 @@
1/*
2Copyright 2014 Ralf Schmitt <[email protected]>
3Copyright 2016 Daniel Svensson <[email protected]>
4
5This program is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 2 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#include <stdint.h>
20#include <stdbool.h>
21#include <avr/io.h>
22#include <util/delay.h>
23#include "wait.h"
24#include "print.h"
25#include "debug.h"
26#include "util.h"
27#include "matrix.h"
28
29static uint8_t debouncing = DEBOUNCE;
30static matrix_row_t matrix[MATRIX_ROWS];
31static matrix_row_t matrix_debouncing[MATRIX_ROWS];
32
33static matrix_row_t read_cols(void);
34static void select_row(uint8_t col);
35
36__attribute__ ((weak))
37void matrix_init_kb(void) {
38 matrix_init_user();
39}
40
41__attribute__ ((weak))
42void matrix_scan_kb(void) {
43 matrix_scan_user();
44}
45
46__attribute__ ((weak))
47void matrix_init_user(void) {
48}
49
50__attribute__ ((weak))
51void matrix_scan_user(void) {
52}
53
54inline uint8_t matrix_rows(void)
55{
56 return MATRIX_ROWS;
57}
58
59inline uint8_t matrix_cols(void)
60{
61 return MATRIX_COLS;
62}
63
64void matrix_init(void)
65{
66 /* Column output pins */
67 DDRD |= 0b01111011;
68 /* Row input pins */
69 DDRC &= ~0b10000000;
70 DDRB &= ~0b01111111;
71 PORTC |= 0b10000000;
72 PORTB |= 0b01111111;
73
74 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
75 matrix[i] = 0;
76 matrix_debouncing[i] = 0;
77 }
78
79 matrix_init_quantum();
80}
81
82uint8_t matrix_scan(void)
83{
84 for (uint8_t col = 0; col < MATRIX_COLS; col++) {
85 select_row(col);
86 wait_us(30);
87 matrix_row_t rows = read_cols();
88 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
89 bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
90 bool curr_bit = rows & (1<<row);
91 if (prev_bit != curr_bit) {
92 matrix_debouncing[row] ^= (matrix_row_t) 1 << col;
93 debouncing = DEBOUNCE;
94 }
95 }
96 }
97
98 if (debouncing) {
99 if (--debouncing) {
100 wait_ms(1);
101 } else {
102 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
103 matrix[i] = matrix_debouncing[i];
104 }
105 }
106 }
107
108 matrix_scan_quantum();
109
110 return 1;
111}
112
113bool matrix_is_modified(void)
114{
115 if (debouncing)
116 return false;
117 return true;
118}
119
120inline
121bool matrix_is_on(uint8_t row, uint8_t col)
122{
123 return matrix[row] & 1 << col;
124}
125
126inline
127matrix_row_t matrix_get_row(uint8_t row)
128{
129 return matrix[row];
130}
131
132void matrix_print(void)
133{
134 print("\nr/c 0123456789ABCDEF\n");
135 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
136 print_hex8(row); print(": ");
137 print_bin_reverse16(matrix_get_row(row));
138 print("\n");
139 }
140}
141
142uint8_t matrix_key_count(void)
143{
144 uint8_t count = 0;
145 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
146 count += bitpop16(matrix[i]);
147 }
148 return count;
149}
150
151static matrix_row_t read_cols(void)
152{
153 return
154 (PINB & (1 << 5) ? 0 : 1 << 0) |
155 (PINC & (1 << 7) ? 0 : 1 << 1) |
156 (PINB & (1 << 4) ? 0 : 1 << 2) |
157 (PINB & (1 << 6) ? 0 : 1 << 3) |
158 (PINB & (1 << 1) ? 0 : 1 << 4) |
159 (PINB & (1 << 0) ? 0 : 1 << 5) |
160 (PINB & (1 << 3) ? 0 : 1 << 6) |
161 (PINB & (1 << 2) ? 0 : 1 << 7);
162}
163
164static void select_row(uint8_t col)
165{
166 switch (col) {
167 case 0:
168 PORTD = (PORTD & ~0b01111011) | 0b00110011;
169 break;
170 case 1:
171 PORTD = (PORTD & ~0b01111011) | 0b01110000;
172 break;
173 case 2:
174 PORTD = (PORTD & ~0b01111011) | 0b00010011;
175 break;
176 case 3:
177 PORTD = (PORTD & ~0b01111011) | 0b01101000;
178 break;
179 case 4:
180 PORTD = (PORTD & ~0b01111011) | 0b00001011;
181 break;
182 case 5:
183 PORTD = (PORTD & ~0b01111011) | 0b00111011;
184 break;
185 case 6:
186 PORTD = (PORTD & ~0b01111011) | 0b01111000;
187 break;
188 case 7:
189 PORTD = (PORTD & ~0b01111011) | 0b01100001;
190 break;
191 case 8:
192 PORTD = (PORTD & ~0b01111011) | 0b01101001;
193 break;
194 case 9:
195 PORTD = (PORTD & ~0b01111011) | 0b01110001;
196 break;
197 case 10:
198 PORTD = (PORTD & ~0b01111011) | 0b01101010;
199 break;
200 case 11:
201 PORTD = (PORTD & ~0b01111011) | 0b01100010;
202 break;
203 case 12:
204 PORTD = (PORTD & ~0b01111011) | 0b01111001;
205 break;
206 case 13:
207 PORTD = (PORTD & ~0b01111011) | 0b01100000;
208 break;
209 case 14:
210 PORTD = (PORTD & ~0b01111011) | 0b01000011;
211 break;
212 case 15:
213 PORTD = (PORTD & ~0b01111011) | 0b00011011;
214 break;
215 case 16:
216 PORTD = (PORTD & ~0b01111011) | 0b00100011;
217 break;
218 case 17:
219 PORTD = (PORTD & ~0b01111011) | 0b00101011;
220 break;
221 }
222}
diff --git a/keyboards/bpiphany/pegasushoof/2013/rules.mk b/keyboards/bpiphany/pegasushoof/2013/rules.mk
new file mode 100644
index 000000000..3215e3588
--- /dev/null
+++ b/keyboards/bpiphany/pegasushoof/2013/rules.mk
@@ -0,0 +1,2 @@
1CUSTOM_MATRIX = yes
2SRC = matrix.c