aboutsummaryrefslogtreecommitdiff
path: root/keyboards/dc01/right
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/dc01/right')
-rw-r--r--keyboards/dc01/right/config.h87
-rw-r--r--keyboards/dc01/right/info.json13
-rw-r--r--keyboards/dc01/right/keymaps/default/keymap.c32
-rw-r--r--keyboards/dc01/right/keymaps/default/readme.md3
-rw-r--r--keyboards/dc01/right/keymaps/via/keymap.c46
-rw-r--r--keyboards/dc01/right/keymaps/via/readme.md11
-rwxr-xr-xkeyboards/dc01/right/keymaps/via/rules.mk1
-rw-r--r--keyboards/dc01/right/matrix.c400
-rw-r--r--keyboards/dc01/right/readme.md15
-rw-r--r--keyboards/dc01/right/right.c16
-rw-r--r--keyboards/dc01/right/right.h48
-rw-r--r--keyboards/dc01/right/rules.mk21
12 files changed, 693 insertions, 0 deletions
diff --git a/keyboards/dc01/right/config.h b/keyboards/dc01/right/config.h
new file mode 100644
index 000000000..60672e252
--- /dev/null
+++ b/keyboards/dc01/right/config.h
@@ -0,0 +1,87 @@
1/*
2Copyright 2018 Yiancar
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 "config_common.h"
21
22/* USB Device descriptor parameter */
23#define VENDOR_ID 0x8968
24#define PRODUCT_ID 0x1011
25#define DEVICE_VER 0x0001
26#define MANUFACTURER Mechboards
27#define PRODUCT DC01 Right
28
29/* key matrix size */
30#define MATRIX_ROWS 5
31#define MATRIX_COLS 8
32
33/*
34 * Keyboard Matrix Assignments
35 *
36 * Change this to how you wired your keyboard
37 * COLS: AVR pins used for columns, left to right
38 * ROWS: AVR pins used for rows, top to bottom
39 * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
40 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
41 *
42*/
43#define MATRIX_ROW_PINS { C7, C6, B6, B5, B4 }
44#define MATRIX_COL_PINS { F1, E6, F6, F5, F4, D4, D6, D7 }
45#define UNUSED_PINS
46
47/* COL2ROW, ROW2COL*/
48#define DIODE_DIRECTION COL2ROW
49
50/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
51#define DEBOUNCE 5
52
53/* define if matrix has ghost (lacks anti-ghosting diodes) */
54//#define MATRIX_HAS_GHOST
55
56/* number of backlight levels */
57
58/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
59#define LOCKING_SUPPORT_ENABLE
60/* Locking resynchronize hack */
61#define LOCKING_RESYNC_ENABLE
62
63/* If defined, GRAVE_ESC will always act as ESC when CTRL is held.
64 * This is userful for the Windows task manager shortcut (ctrl+shift+esc).
65 */
66// #define GRAVE_ESC_CTRL_OVERRIDE
67
68/*
69 * Force NKRO
70 *
71 * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved
72 * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the
73 * makefile for this to work.)
74 *
75 * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N)
76 * until the next keyboard reset.
77 *
78 * NKRO may prevent your keystrokes from being detected in the BIOS, but it is
79 * fully operational during normal computer usage.
80 *
81 * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N)
82 * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by
83 * bootmagic, NKRO mode will always be enabled until it is toggled again during a
84 * power-up.
85 *
86 */
87//#define FORCE_NKRO
diff --git a/keyboards/dc01/right/info.json b/keyboards/dc01/right/info.json
new file mode 100644
index 000000000..1eb6f1792
--- /dev/null
+++ b/keyboards/dc01/right/info.json
@@ -0,0 +1,13 @@
1{
2 "keyboard_name": "DC01 Right Half",
3 "url": "",
4 "maintainer": "Yiancar-Designs",
5 "layouts": {
6 "LAYOUT_all": {
7 "layout": [{"label":"&", "x":0.5, "y":0}, {"label":"*", "x":1.5, "y":0}, {"label":"(", "x":2.5, "y":0}, {"label":")", "x":3.5, "y":0}, {"label":"_", "x":4.5, "y":0}, {"label":"+", "x":5.5, "y":0}, {"label":"Back", "x":6.5, "y":0}, {"label":"Del", "x":7.5, "y":0}, {"label":"Y", "x":0, "y":1}, {"label":"U", "x":1, "y":1}, {"label":"I", "x":2, "y":1}, {"label":"O", "x":3, "y":1}, {"label":"P", "x":4, "y":1}, {"label":"{", "x":5, "y":1}, {"label":"}", "x":6, "y":1}, {"label":"|", "x":7, "y":1, "w":1.5}, {"label":"H", "x":0.25, "y":2}, {"label":"J", "x":1.25, "y":2}, {"label":"K", "x":2.25, "y":2}, {"label":"L", "x":3.25, "y":2}, {"label":":", "x":4.25, "y":2}, {"label":"@", "x":5.25, "y":2}, {"label":"~", "x":6.25, "y":2}, {"label":"Enter", "x":7.25, "y":2, "w":1.25}, {"label":"N", "x":0.75, "y":3}, {"label":"M", "x":1.75, "y":3}, {"label":"<", "x":2.75, "y":3}, {"label":">", "x":3.75, "y":3}, {"label":"?", "x":4.75, "y":3}, {"label":"Shift", "x":5.75, "y":3, "w":1.75}, {"label":"Shift", "x":7.5, "y":3}, {"label":"Fn", "x":0, "y":4, "w":1.25}, {"x":1.25, "y":4, "w":2.25}, {"label":"AltGr", "x":3.5, "y":4, "w":1.25}, {"label":"Win", "x":4.75, "y":4, "w":1.25}, {"label":"Menu", "x":6, "y":4, "w":1.25}, {"label":"Ctrl", "x":7.25, "y":4, "w":1.25}]
8 },
9 "LAYOUT_ansi": {
10 "layout": [{"label":"&", "x":0.5, "y":0}, {"label":"*", "x":1.5, "y":0}, {"label":"(", "x":2.5, "y":0}, {"label":")", "x":3.5, "y":0}, {"label":"_", "x":4.5, "y":0}, {"label":"+", "x":5.5, "y":0}, {"label":"Back", "x":6.5, "y":0}, {"label":"Del", "x":7.5, "y":0}, {"label":"Y", "x":0, "y":1}, {"label":"U", "x":1, "y":1}, {"label":"I", "x":2, "y":1}, {"label":"O", "x":3, "y":1}, {"label":"P", "x":4, "y":1}, {"label":"{", "x":5, "y":1}, {"label":"}", "x":6, "y":1}, {"label":"|", "x":7, "y":1, "w":1.5}, {"label":"H", "x":0.25, "y":2}, {"label":"J", "x":1.25, "y":2}, {"label":"K", "x":2.25, "y":2}, {"label":"L", "x":3.25, "y":2}, {"label":":", "x":4.25, "y":2}, {"label":"@", "x":5.25, "y":2}, {"label":"Enter", "x":6.25, "y":2, "w":2.25}, {"label":"N", "x":0.75, "y":3}, {"label":"M", "x":1.75, "y":3}, {"label":"<", "x":2.75, "y":3}, {"label":">", "x":3.75, "y":3}, {"label":"?", "x":4.75, "y":3}, {"label":"Shift", "x":5.75, "y":3, "w":1.75}, {"label":"Shift", "x":7.5, "y":3}, {"label":"Fn", "x":0, "y":4, "w":1.25}, {"x":1.25, "y":4, "w":2.25}, {"label":"AltGr", "x":3.5, "y":4, "w":1.25}, {"label":"Win", "x":4.75, "y":4, "w":1.25}, {"label":"Menu", "x":6, "y":4, "w":1.25}, {"label":"Ctrl", "x":7.25, "y":4, "w":1.25}]
11 }
12 }
13}
diff --git a/keyboards/dc01/right/keymaps/default/keymap.c b/keyboards/dc01/right/keymaps/default/keymap.c
new file mode 100644
index 000000000..1bf026f3d
--- /dev/null
+++ b/keyboards/dc01/right/keymaps/default/keymap.c
@@ -0,0 +1,32 @@
1/* Copyright 2018 Yiancar
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#include QMK_KEYBOARD_H
17
18const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
19[0] = LAYOUT_ansi( /* Base */
20 KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSLS, KC_GRV,
21 KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC,KC_BSPC,
22 KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
23 KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT,MO(1),
24 KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_RGUI, KC_RCTL),
25
26[1] = LAYOUT_ansi( /* Empty for Dynamic keymap */
27 KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_INS, KC_DEL,
28 KC_TRNS, KC_TRNS, KC_PSCR, KC_SLCK, KC_PAUS, KC_UP, KC_TRNS, KC_BSPC,
29 KC_PAST, KC_PSLS, KC_HOME, KC_PGUP, KC_LEFT, KC_RGHT, KC_PENT,
30 KC_PPLS, KC_PMNS, KC_END, KC_PGDN, KC_DOWN, KC_TRNS, KC_TRNS,
31 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
32};
diff --git a/keyboards/dc01/right/keymaps/default/readme.md b/keyboards/dc01/right/keymaps/default/readme.md
new file mode 100644
index 000000000..50a56f610
--- /dev/null
+++ b/keyboards/dc01/right/keymaps/default/readme.md
@@ -0,0 +1,3 @@
1# The default ANSI keymap for DC01 Right
2
3When using the right module individually, this keymap will take effect. When using the keyboard as a whole please edit the keymap of the left module.
diff --git a/keyboards/dc01/right/keymaps/via/keymap.c b/keyboards/dc01/right/keymaps/via/keymap.c
new file mode 100644
index 000000000..92495e6d2
--- /dev/null
+++ b/keyboards/dc01/right/keymaps/via/keymap.c
@@ -0,0 +1,46 @@
1/* Copyright 2018 Yiancar
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#include QMK_KEYBOARD_H
17
18const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
19[0] = LAYOUT_all( /* Base */
20 KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSLS, KC_GRV,
21 KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSPC,
22 KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_NUHS, KC_ENT,
23 KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, MO(1),
24 KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_RGUI, KC_RCTL),
25
26[1] = LAYOUT_all( /* FN */
27 KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_INS, KC_DEL,
28 KC_TRNS, KC_TRNS, KC_PSCR, KC_SLCK, KC_PAUS, KC_UP, KC_TRNS, KC_BSPC,
29 KC_PAST, KC_PSLS, KC_HOME, KC_PGUP, KC_LEFT, KC_RGHT, KC_TRNS, KC_PENT,
30 KC_PPLS, KC_PMNS, KC_END, KC_PGDN, KC_DOWN, KC_TRNS, KC_TRNS,
31 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
32
33[2] = LAYOUT_all( /* Empty for Dynamic keymap */
34 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
35 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
36 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
37 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
38 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
39
40[3] = LAYOUT_all( /* Empty for Dynamic keymap */
41 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
42 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
43 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
44 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
45 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
46};
diff --git a/keyboards/dc01/right/keymaps/via/readme.md b/keyboards/dc01/right/keymaps/via/readme.md
new file mode 100644
index 000000000..a2c2fb0cd
--- /dev/null
+++ b/keyboards/dc01/right/keymaps/via/readme.md
@@ -0,0 +1,11 @@
1# The default VIA keymap for DC01 Left
2
3Please use this for ISO as well.
4
5The keymap looks like a full layout keymap.
6
7This is because the left part of the keyboard acts as the masterm coordinating all four part.
8
9When using the keyboard to connect the other three parts, this keymap overwrites the individual keymaps of the single modules.
10
11When using a module individually, the keymap of that module will take effect.
diff --git a/keyboards/dc01/right/keymaps/via/rules.mk b/keyboards/dc01/right/keymaps/via/rules.mk
new file mode 100755
index 000000000..1e5b99807
--- /dev/null
+++ b/keyboards/dc01/right/keymaps/via/rules.mk
@@ -0,0 +1 @@
VIA_ENABLE = yes
diff --git a/keyboards/dc01/right/matrix.c b/keyboards/dc01/right/matrix.c
new file mode 100644
index 000000000..544c8dc53
--- /dev/null
+++ b/keyboards/dc01/right/matrix.c
@@ -0,0 +1,400 @@
1/*
2Copyright 2012 Jun Wako
3Copyright 2014 Jack Humbert
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#include <stdint.h>
19#include <stdbool.h>
20#if defined(__AVR__)
21#include <avr/io.h>
22#include <avr/wdt.h>
23#include <avr/interrupt.h>
24#include <util/delay.h>
25#endif
26#include "wait.h"
27#include "print.h"
28#include "debug.h"
29#include "util.h"
30#include "matrix.h"
31#include "timer.h"
32#include "i2c_slave.h"
33#include "lufa.h"
34#include "quantum.h"
35
36#define SLAVE_I2C_ADDRESS 0x32
37
38/* Set 0 if debouncing isn't needed */
39
40#ifndef DEBOUNCE
41# define DEBOUNCE 5
42#endif
43
44#if (DEBOUNCE > 0)
45 static uint16_t debouncing_time;
46 static bool debouncing = false;
47#endif
48
49#if (MATRIX_COLS <= 8)
50# define print_matrix_header() print("\nr/c 01234567\n")
51# define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row))
52# define matrix_bitpop(i) bitpop(matrix[i])
53# define ROW_SHIFTER ((uint8_t)1)
54#elif (MATRIX_COLS <= 16)
55# define print_matrix_header() print("\nr/c 0123456789ABCDEF\n")
56# define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row))
57# define matrix_bitpop(i) bitpop16(matrix[i])
58# define ROW_SHIFTER ((uint16_t)1)
59#elif (MATRIX_COLS <= 32)
60# define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n")
61# define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row))
62# define matrix_bitpop(i) bitpop32(matrix[i])
63# define ROW_SHIFTER ((uint32_t)1)
64#endif
65
66#ifdef MATRIX_MASKED
67 extern const matrix_row_t matrix_mask[];
68#endif
69
70#if (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW)
71static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
72static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
73#endif
74
75/* matrix state(1:on, 0:off) */
76static matrix_row_t matrix[MATRIX_ROWS];
77
78static matrix_row_t matrix_debouncing[MATRIX_ROWS];
79
80
81#if (DIODE_DIRECTION == COL2ROW)
82 static void init_cols(void);
83 static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row);
84 static void unselect_rows(void);
85 static void select_row(uint8_t row);
86 static void unselect_row(uint8_t row);
87#elif (DIODE_DIRECTION == ROW2COL)
88 static void init_rows(void);
89 static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col);
90 static void unselect_cols(void);
91 static void unselect_col(uint8_t col);
92 static void select_col(uint8_t col);
93#endif
94
95__attribute__ ((weak))
96void matrix_init_quantum(void) {
97 matrix_init_kb();
98}
99
100__attribute__ ((weak))
101void matrix_scan_quantum(void) {
102 matrix_scan_kb();
103}
104
105__attribute__ ((weak))
106void matrix_init_kb(void) {
107 matrix_init_user();
108}
109
110__attribute__ ((weak))
111void matrix_scan_kb(void) {
112 matrix_scan_user();
113}
114
115__attribute__ ((weak))
116void matrix_init_user(void) {
117}
118
119__attribute__ ((weak))
120void matrix_scan_user(void) {
121}
122
123inline
124uint8_t matrix_rows(void) {
125 return MATRIX_ROWS;
126}
127
128inline
129uint8_t matrix_cols(void) {
130 return MATRIX_COLS;
131}
132
133void matrix_init(void) {
134
135 // initialize row and col
136#if (DIODE_DIRECTION == COL2ROW)
137 unselect_rows();
138 init_cols();
139#elif (DIODE_DIRECTION == ROW2COL)
140 unselect_cols();
141 init_rows();
142#endif
143
144 // initialize matrix state: all keys off
145 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
146 matrix[i] = 0;
147 matrix_debouncing[i] = 0;
148 }
149
150 matrix_init_quantum();
151}
152
153uint8_t matrix_scan(void)
154{
155#if (DIODE_DIRECTION == COL2ROW)
156
157 // Set row, read cols
158 for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
159# if (DEBOUNCE > 0)
160 bool matrix_changed = read_cols_on_row(matrix_debouncing, current_row);
161
162 if (matrix_changed) {
163 debouncing = true;
164 debouncing_time = timer_read();
165 }
166
167# else
168 read_cols_on_row(matrix, current_row);
169# endif
170
171 }
172
173#elif (DIODE_DIRECTION == ROW2COL)
174
175 // Set col, read rows
176 for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
177# if (DEBOUNCE > 0)
178 bool matrix_changed = read_rows_on_col(matrix_debouncing, current_col);
179 if (matrix_changed) {
180 debouncing = true;
181 debouncing_time = timer_read();
182 }
183# else
184 read_rows_on_col(matrix, current_col);
185# endif
186
187 }
188
189#endif
190
191# if (DEBOUNCE > 0)
192 if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCE)) {
193 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
194 matrix[i] = matrix_debouncing[i];
195 }
196 debouncing = false;
197 }
198# endif
199
200 i2c_slave_reg[1] = 0x55;
201 for (uint8_t i = 0; i < MATRIX_ROWS; i++){
202 i2c_slave_reg[i+2] = matrix[i]; //send matrix over i2c
203 }
204
205 matrix_scan_quantum();
206 return 1;
207}
208
209bool matrix_is_modified(void)
210{
211#if (DEBOUNCE > 0)
212 if (debouncing) return false;
213#endif
214 return true;
215}
216
217inline
218bool matrix_is_on(uint8_t row, uint8_t col)
219{
220 return (matrix[row] & ((matrix_row_t)1<<col));
221}
222
223inline
224matrix_row_t matrix_get_row(uint8_t row)
225{
226 // Matrix mask lets you disable switches in the returned matrix data. For example, if you have a
227 // switch blocker installed and the switch is always pressed.
228#ifdef MATRIX_MASKED
229 return matrix[row] & matrix_mask[row];
230#else
231 return matrix[row];
232#endif
233}
234
235void matrix_print(void)
236{
237 print_matrix_header();
238
239 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
240 print_hex8(row); print(": ");
241 print_matrix_row(row);
242 print("\n");
243 }
244}
245
246uint8_t matrix_key_count(void)
247{
248 uint8_t count = 0;
249 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
250 count += matrix_bitpop(i);
251 }
252 return count;
253}
254
255
256
257#if (DIODE_DIRECTION == COL2ROW)
258
259static void init_cols(void)
260{
261 for(uint8_t x = 0; x < MATRIX_COLS; x++) {
262 uint8_t pin = col_pins[x];
263 _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
264 _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
265 }
266}
267
268static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
269{
270 // Store last value of row prior to reading
271 matrix_row_t last_row_value = current_matrix[current_row];
272
273 // Clear data in matrix row
274 current_matrix[current_row] = 0;
275
276 // Select row and wait for row selecton to stabilize
277 select_row(current_row);
278 wait_us(30);
279
280 // For each col...
281 for(uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
282
283 // Select the col pin to read (active low)
284 uint8_t pin = col_pins[col_index];
285 uint8_t pin_state = (_SFR_IO8(pin >> 4) & _BV(pin & 0xF));
286
287 // Populate the matrix row with the state of the col pin
288 current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index);
289 }
290
291 // Unselect row
292 unselect_row(current_row);
293
294 return (last_row_value != current_matrix[current_row]);
295}
296
297static void select_row(uint8_t row)
298{
299 uint8_t pin = row_pins[row];
300 _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); // OUT
301 _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW
302}
303
304static void unselect_row(uint8_t row)
305{
306 uint8_t pin = row_pins[row];
307 _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
308 _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
309}
310
311static void unselect_rows(void)
312{
313 for(uint8_t x = 0; x < MATRIX_ROWS; x++) {
314 uint8_t pin = row_pins[x];
315 _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
316 _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
317 }
318}
319
320#elif (DIODE_DIRECTION == ROW2COL)
321
322static void init_rows(void)
323{
324 for(uint8_t x = 0; x < MATRIX_ROWS; x++) {
325 uint8_t pin = row_pins[x];
326 _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
327 _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
328 }
329}
330
331static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
332{
333 bool matrix_changed = false;
334
335 // Select col and wait for col selecton to stabilize
336 select_col(current_col);
337 wait_us(30);
338
339 // For each row...
340 for(uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++)
341 {
342
343 // Store last value of row prior to reading
344 matrix_row_t last_row_value = current_matrix[row_index];
345
346 // Check row pin state
347 if ((_SFR_IO8(row_pins[row_index] >> 4) & _BV(row_pins[row_index] & 0xF)) == 0)
348 {
349 // Pin LO, set col bit
350 current_matrix[row_index] |= (ROW_SHIFTER << current_col);
351 }
352 else
353 {
354 // Pin HI, clear col bit
355 current_matrix[row_index] &= ~(ROW_SHIFTER << current_col);
356 }
357
358 // Determine if the matrix changed state
359 if ((last_row_value != current_matrix[row_index]) && !(matrix_changed))
360 {
361 matrix_changed = true;
362 }
363 }
364
365 // Unselect col
366 unselect_col(current_col);
367
368 return matrix_changed;
369}
370
371static void select_col(uint8_t col)
372{
373 uint8_t pin = col_pins[col];
374 _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); // OUT
375 _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW
376}
377
378static void unselect_col(uint8_t col)
379{
380 uint8_t pin = col_pins[col];
381 _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
382 _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
383}
384
385static void unselect_cols(void)
386{
387 for(uint8_t x = 0; x < MATRIX_COLS; x++) {
388 uint8_t pin = col_pins[x];
389 _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN
390 _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI
391 }
392}
393
394#endif
395
396//this replases tmk code
397void matrix_setup(void){
398 i2c_slave_init(SLAVE_I2C_ADDRESS); //setup address of slave i2c
399 sei(); //enable interupts
400} \ No newline at end of file
diff --git a/keyboards/dc01/right/readme.md b/keyboards/dc01/right/readme.md
new file mode 100644
index 000000000..a93459305
--- /dev/null
+++ b/keyboards/dc01/right/readme.md
@@ -0,0 +1,15 @@
1# DC01 Right Half
2
3![DC01 Right Half](https://i.imgur.com/PTn0sp8.jpg)
4
5A hotpluggable four part keyboard which comes together with magnets and pogo pins! This is the right part.
6
7Keyboard Maintainer: [Yiancar](https://github.com/yiancar)
8Hardware Supported: Runs on an atmega32u4
9Hardware Availability: [Mechboards](https://mechboards.co.uk/)
10
11Make example for this keyboard (after setting up your build environment):
12
13 make dc01/right:default
14
15See [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) then the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information.
diff --git a/keyboards/dc01/right/right.c b/keyboards/dc01/right/right.c
new file mode 100644
index 000000000..bbb1d568c
--- /dev/null
+++ b/keyboards/dc01/right/right.c
@@ -0,0 +1,16 @@
1/* Copyright 2018 Yiancar
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#include "right.h"
diff --git a/keyboards/dc01/right/right.h b/keyboards/dc01/right/right.h
new file mode 100644
index 000000000..55616ec03
--- /dev/null
+++ b/keyboards/dc01/right/right.h
@@ -0,0 +1,48 @@
1/* Copyright 2018 Yiancar
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#pragma once
17
18#include "quantum.h"
19
20#define XXX KC_NO
21
22#define LAYOUT_all( \
23 K01, K02, K03, K04, K05, K06, K07, K00, \
24 K10, K11, K12, K13, K14, K15, K16, K17, \
25 K20, K21, K22, K23, K24, K25, K26, K27, \
26 K30, K31, K32, K33, K34, K36, K37, \
27 K40, K41, K42, K43, K44, K45 \
28) { \
29 { K00, K01, K02, K03, K04, K05, K06, K07 }, \
30 { K10, K11, K12, K13, K14, K15, K16, K17 }, \
31 { K20, K21, K22, K23, K24, K25, K26, K27 }, \
32 { K30, K31, K32, K33, K34, XXX, K36, K37 }, \
33 { K40, K41, K42, K43, K44, K45, XXX, XXX } \
34}
35
36#define LAYOUT_ansi( \
37 K01, K02, K03, K04, K05, K06, K07, K00, \
38 K10, K11, K12, K13, K14, K15, K16, K17, \
39 K20, K21, K22, K23, K24, K25, K27, \
40 K30, K31, K32, K33, K34, K36, K37, \
41 K40, K41, K42, K43, K44, K45 \
42) { \
43 { K00, K01, K02, K03, K04, K05, K06, K07 }, \
44 { K10, K11, K12, K13, K14, K15, K16, K17 }, \
45 { K20, K21, K22, K23, K24, K25, XXX, K27 }, \
46 { K30, K31, K32, K33, K34, XXX, K36, K37 }, \
47 { K40, K41, K42, K43, K44, K45, XXX, XXX } \
48}
diff --git a/keyboards/dc01/right/rules.mk b/keyboards/dc01/right/rules.mk
new file mode 100644
index 000000000..8d8884e59
--- /dev/null
+++ b/keyboards/dc01/right/rules.mk
@@ -0,0 +1,21 @@
1# MCU name
2MCU = atmega32u4
3
4# Bootloader selection
5BOOTLOADER = atmel-dfu
6
7# Build Options
8# change yes to no to disable
9#
10BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
11MOUSEKEY_ENABLE = yes # Mouse keys
12EXTRAKEY_ENABLE = yes # Audio control and System control
13CONSOLE_ENABLE = no # Console for debug
14COMMAND_ENABLE = no # Commands for debug and configuration
15NKRO_ENABLE = yes # Enable N-Key Rollover
16BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
17AUDIO_ENABLE = no # Audio output
18NO_USB_STARTUP_CHECK = yes # Disable initialization only when usb is plugged in
19CUSTOM_MATRIX = yes # Use custom matrix
20SRC += matrix.c \
21 i2c_slave.c