aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2020-09-17 00:41:55 -0700
committerGitHub <noreply@github.com>2020-09-17 00:41:55 -0700
commitf37a134f712891db64b1391a250b0d752206f520 (patch)
tree5067c94b61510d1e1f8db5cabad41d48147724e1
parentf650b03fb77530eb6aa7eab541f6a28c98e0ced6 (diff)
downloadqmk_firmware-f37a134f712891db64b1391a250b0d752206f520.tar.gz
qmk_firmware-f37a134f712891db64b1391a250b0d752206f520.zip
[Keyboard] Convert Corne Keyboard to Split Common (#6001)
* [Keyboard] Convert Corne Keyboard to Split Common * Add VIA Support * Makes sure that ol(e)d and new OLED implementation can't coexist * Add licensing header to files * Add changes based on feedback from foostan * Fixes
-rw-r--r--keyboards/crkbd/config.h54
-rw-r--r--keyboards/crkbd/crkbd.c26
-rw-r--r--keyboards/crkbd/crkbd.h21
-rw-r--r--keyboards/crkbd/keymaps/default/keymap.c18
-rw-r--r--keyboards/crkbd/keymaps/oled_sample/config.h48
-rw-r--r--keyboards/crkbd/keymaps/oled_sample/keymap.c208
-rw-r--r--keyboards/crkbd/keymaps/oled_sample/rules.mk7
-rw-r--r--keyboards/crkbd/rev1/common/common.c21
-rw-r--r--keyboards/crkbd/rev1/common/common.h24
-rw-r--r--keyboards/crkbd/rev1/common/config.h30
-rw-r--r--keyboards/crkbd/rev1/common/keymaps/via/config.h46
-rw-r--r--keyboards/crkbd/rev1/common/keymaps/via/keymap.c193
-rw-r--r--keyboards/crkbd/rev1/common/keymaps/via/rules.mk5
-rw-r--r--keyboards/crkbd/rev1/common/rules.mk2
-rw-r--r--keyboards/crkbd/rev1/common/ssd1306.c360
-rw-r--r--keyboards/crkbd/rev1/config.h61
-rw-r--r--keyboards/crkbd/rev1/legacy/config.h23
-rw-r--r--keyboards/crkbd/rev1/legacy/i2c.c (renamed from keyboards/crkbd/i2c.c)2
-rw-r--r--keyboards/crkbd/rev1/legacy/i2c.h (renamed from keyboards/crkbd/i2c.h)0
-rw-r--r--keyboards/crkbd/rev1/legacy/legacy.c19
-rw-r--r--keyboards/crkbd/rev1/legacy/legacy.h21
-rw-r--r--keyboards/crkbd/rev1/legacy/matrix.c (renamed from keyboards/crkbd/rev1/matrix.c)0
-rw-r--r--keyboards/crkbd/rev1/legacy/post_config.h27
-rw-r--r--keyboards/crkbd/rev1/legacy/rules.mk7
-rw-r--r--keyboards/crkbd/rev1/legacy/serial.c (renamed from keyboards/crkbd/serial.c)0
-rw-r--r--keyboards/crkbd/rev1/legacy/serial.h (renamed from keyboards/crkbd/serial.h)0
-rw-r--r--keyboards/crkbd/rev1/legacy/serial_config.h22
-rw-r--r--keyboards/crkbd/rev1/legacy/serial_config_simpleapi.h23
-rw-r--r--keyboards/crkbd/rev1/legacy/split_scomm.c (renamed from keyboards/crkbd/rev1/split_scomm.c)18
-rw-r--r--keyboards/crkbd/rev1/legacy/split_scomm.h (renamed from keyboards/crkbd/rev1/split_scomm.h)18
-rw-r--r--keyboards/crkbd/rev1/legacy/split_util.c (renamed from keyboards/crkbd/rev1/split_util.c)22
-rw-r--r--keyboards/crkbd/rev1/legacy/split_util.h37
-rw-r--r--keyboards/crkbd/rev1/legacy/ssd1306.c (renamed from keyboards/crkbd/ssd1306.c)12
-rw-r--r--keyboards/crkbd/rev1/rev1.c32
-rw-r--r--keyboards/crkbd/rev1/rev1.h42
-rw-r--r--keyboards/crkbd/rev1/rules.mk6
-rw-r--r--keyboards/crkbd/rev1/serial_config.h4
-rw-r--r--keyboards/crkbd/rev1/serial_config_simpleapi.h5
-rw-r--r--keyboards/crkbd/rev1/split_util.h19
-rw-r--r--keyboards/crkbd/rev1/ssd1306.h (renamed from keyboards/crkbd/ssd1306.h)0
-rw-r--r--keyboards/crkbd/rules.mk8
41 files changed, 1359 insertions, 132 deletions
diff --git a/keyboards/crkbd/config.h b/keyboards/crkbd/config.h
index fb1cdf396..a2dd71071 100644
--- a/keyboards/crkbd/config.h
+++ b/keyboards/crkbd/config.h
@@ -1,6 +1,6 @@
1/* 1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com> 2Copyright 2019 @foostan
3Copyright 2015 Jack Humbert 3Copyright 2020 Drashna Jaelre <@drashna>
4 4
5This program is free software: you can redistribute it and/or modify 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 6it under the terms of the GNU General Public License as published by
@@ -19,9 +19,55 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19#pragma once 19#pragma once
20 20
21#include "config_common.h" 21#include "config_common.h"
22#include <serial_config.h>
23 22
24#define USE_I2C 23/* USB Device descriptor parameter */
24#define VENDOR_ID 0x4653
25#define PRODUCT_ID 0x0001
26#define DEVICE_VER 0x0001
27#define MANUFACTURER foostan
28
29/* key matrix size */
30// Rows are doubled-up
31#define MATRIX_ROWS 8
32#define MATRIX_COLS 6
33#define MATRIX_ROW_PINS { D4, C6, D7, E6 }
34
35// wiring of each half
36#define MATRIX_COL_PINS { F4, F5, F6, F7, B1, B3 }
37// #define MATRIX_COL_PINS { B2, B3, B1, F7, F6, F5, F4 } //uncomment this line and comment line above if you need to reverse left-to-right key order
38
39/* define if matrix has ghost */
40//#define MATRIX_HAS_GHOST
41
42/* number of backlight levels */
43// #define BACKLIGHT_LEVELS 3
44
45/* Set 0 if debouncing isn't needed */
46#define DEBOUNCE 5
47
48/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
49//#define LOCKING_SUPPORT_ENABLE
50/* Locking resynchronize hack */
51//#define LOCKING_RESYNC_ENABLE
52
53
54/*
55 * Feature disable options
56 * These options are also useful to firmware size reduction.
57 */
58
59/* disable debug print */
60// #define NO_DEBUG
61
62/* disable print */
63// #define NO_PRINT
64
65/* disable action features */
66//#define NO_ACTION_LAYER
67//#define NO_ACTION_TAPPING
68//#define NO_ACTION_ONESHOT
69//#define NO_ACTION_MACRO
70//#define NO_ACTION_FUNCTION
25#define USE_SERIAL 71#define USE_SERIAL
26 72
27#define NO_ACTION_MACRO 73#define NO_ACTION_MACRO
diff --git a/keyboards/crkbd/crkbd.c b/keyboards/crkbd/crkbd.c
index 7417ad604..af0ef8a34 100644
--- a/keyboards/crkbd/crkbd.c
+++ b/keyboards/crkbd/crkbd.c
@@ -1,9 +1,19 @@
1#include "crkbd.h" 1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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.
2 14
3bool process_record_kb(uint16_t keycode, keyrecord_t *record) { 15You should have received a copy of the GNU General Public License
4#ifdef SSD1306OLED 16along with this program. If not, see <http://www.gnu.org/licenses/>.
5 return process_record_gfx(keycode,record) && process_record_user(keycode, record); 17*/
6#else 18
7 return process_record_user(keycode, record); 19#include "crkbd.h"
8#endif
9}
diff --git a/keyboards/crkbd/crkbd.h b/keyboards/crkbd/crkbd.h
index 73f2a3f07..4ba939704 100644
--- a/keyboards/crkbd/crkbd.h
+++ b/keyboards/crkbd/crkbd.h
@@ -1,5 +1,24 @@
1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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*/
1#pragma once 18#pragma once
2 19
3#ifdef KEYBOARD_crkbd_rev1 20#ifdef KEYBOARD_crkbd_rev1
4 #include "rev1.h" 21# include "rev1.h"
5#endif 22#endif
23
24#include "quantum.h"
diff --git a/keyboards/crkbd/keymaps/default/keymap.c b/keyboards/crkbd/keymaps/default/keymap.c
index 4dd0be899..a3a9d9535 100644
--- a/keyboards/crkbd/keymaps/default/keymap.c
+++ b/keyboards/crkbd/keymaps/default/keymap.c
@@ -1,3 +1,21 @@
1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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
1#include QMK_KEYBOARD_H 19#include QMK_KEYBOARD_H
2 20
3 21
diff --git a/keyboards/crkbd/keymaps/oled_sample/config.h b/keyboards/crkbd/keymaps/oled_sample/config.h
new file mode 100644
index 000000000..41568c591
--- /dev/null
+++ b/keyboards/crkbd/keymaps/oled_sample/config.h
@@ -0,0 +1,48 @@
1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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
20
21#pragma once
22
23//#define USE_MATRIX_I2C
24#ifdef KEYBOARD_crkbd_rev1_common
25# undef USE_I2C
26# define USE_SERIAL
27#endif
28
29/* Select hand configuration */
30
31#define MASTER_LEFT
32// #define MASTER_RIGHT
33// #define EE_HANDS
34
35#define USE_SERIAL_PD2
36
37#define TAPPING_FORCE_HOLD
38#define TAPPING_TERM 100
39
40#undef RGBLED_NUM
41#define RGBLIGHT_ANIMATIONS
42#define RGBLED_NUM 27
43#define RGBLIGHT_LIMIT_VAL 120
44#define RGBLIGHT_HUE_STEP 10
45#define RGBLIGHT_SAT_STEP 17
46#define RGBLIGHT_VAL_STEP 17
47
48#define OLED_FONT_H "keyboards/crkbd/lib/glcdfont.c"
diff --git a/keyboards/crkbd/keymaps/oled_sample/keymap.c b/keyboards/crkbd/keymaps/oled_sample/keymap.c
new file mode 100644
index 000000000..f2d5770b6
--- /dev/null
+++ b/keyboards/crkbd/keymaps/oled_sample/keymap.c
@@ -0,0 +1,208 @@
1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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 QMK_KEYBOARD_H
20
21
22// Each layer gets a name for readability, which is then used in the keymap matrix below.
23// The underscores don't mean anything - you can have a layer called STUFF or any other name.
24// Layer names don't all need to be of the same length, obviously, and you can also skip them
25// entirely and just use numbers.
26enum crkbd_layers {
27 _QWERTY,
28 _LOWER,
29 _RAISE,
30 _ADJUST,
31};
32
33
34#define RAISE MO(_RAISE)
35#define LOWER MO(_LOWER)
36#define CTLTB CTL_T(KC_TAB)
37#define GUIEI GUI_T(KC_LANG2)
38#define ALTKN ALT_T(KC_LANG1)
39
40const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
41 [_QWERTY] = LAYOUT(
42 KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
43 CTLTB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
44 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT,
45 GUIEI, LOWER, KC_SPC, KC_ENT, RAISE, ALTKN
46 ),
47
48 [_LOWER] = LAYOUT(
49 KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
50 CTLTB, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, XXXXXXX,
51 KC_LSFT, KC_F11, KC_F12, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, XXXXXXX,
52 GUIEI, LOWER, KC_SPC, KC_ENT, RAISE, ALTKN
53 ),
54
55 [_RAISE] = LAYOUT(
56 KC_ESC, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC,
57 CTLTB, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_MINS, KC_EQL, KC_LCBR, KC_RCBR, KC_PIPE, KC_GRV,
58 KC_LSFT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_UNDS, KC_PLUS, KC_LBRC, KC_RBRC, KC_BSLS, KC_TILD,
59 GUIEI, LOWER, KC_SPC, KC_ENT, RAISE, ALTKN
60
61 ),
62
63 [_ADJUST] = LAYOUT(
64 RESET, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
65 RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
66 RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
67 GUIEI, LOWER, KC_SPC, KC_ENT, RAISE, ALTKN
68 )
69};
70
71layer_state_t layer_state_set_user(layer_state_t state) {
72 state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
73 return state;
74}
75
76
77#ifdef OLED_DRIVER_ENABLE
78oled_rotation_t oled_init_user(oled_rotation_t rotation) {
79 if (is_keyboard_master()) {
80 return OLED_ROTATION_270;
81 } else {
82 return rotation;
83 }
84}
85
86void render_crkbd_logo(void) {
87 static const char PROGMEM crkbd_logo[] = {
88 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94,
89 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4,
90 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4,
91 0};
92 oled_write_P(crkbd_logo, false);
93}
94
95# define KEYLOG_LEN 5
96char keylog_str[KEYLOG_LEN] = {};
97uint8_t keylogs_str_idx = 0;
98uint16_t log_timer = 0;
99
100const char code_to_name[60] = {
101 ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
102 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
103 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
104 '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
105 'R', 'E', 'B', 'T', '_', '-', '=', '[', ']', '\\',
106 '#', ';', '\'', '`', ',', '.', '/', ' ', ' ', ' '};
107
108void add_keylog(uint16_t keycode) {
109 if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
110 keycode = keycode & 0xFF;
111 }
112
113 for (uint8_t i = KEYLOG_LEN - 1; i > 0; i--) {
114 keylog_str[i] = keylog_str[i - 1];
115 }
116 if (keycode < 60) {
117 keylog_str[0] = code_to_name[keycode];
118 }
119 keylog_str[KEYLOG_LEN - 1] = 0;
120
121 log_timer = timer_read();
122}
123
124void update_log(void) {
125 if (timer_elapsed(log_timer) > 750) {
126 add_keylog(0);
127 }
128}
129
130void render_keylogger_status(void) {
131 oled_write_P(PSTR("KLogr"), false);
132 oled_write(keylog_str, false);
133}
134
135void render_default_layer_state(void) {
136 oled_write_P(PSTR("Lyout"), false);
137 switch (get_highest_layer(default_layer_state)) {
138 case _QWERTY:
139 oled_write_P(PSTR(" QRTY"), false);
140 break;
141 }
142}
143
144void render_layer_state(void) {
145 oled_write_P(PSTR("LAYER"), false);
146 oled_write_P(PSTR("Lower"), layer_state_is(_LOWER));
147 oled_write_P(PSTR("Raise"), layer_state_is(_RAISE));
148}
149
150void render_keylock_status(uint8_t led_usb_state) {
151 oled_write_P(PSTR("Lock:"), false);
152 oled_write_P(PSTR(" "), false);
153 oled_write_P(PSTR("N"), led_usb_state & (1 << USB_LED_NUM_LOCK));
154 oled_write_P(PSTR("C"), led_usb_state & (1 << USB_LED_CAPS_LOCK));
155 oled_write_ln_P(PSTR("S"), led_usb_state & (1 << USB_LED_SCROLL_LOCK));
156}
157
158void render_mod_status(uint8_t modifiers) {
159 oled_write_P(PSTR("Mods:"), false);
160 oled_write_P(PSTR(" "), false);
161 oled_write_P(PSTR("S"), (modifiers & MOD_MASK_SHIFT));
162 oled_write_P(PSTR("C"), (modifiers & MOD_MASK_CTRL));
163 oled_write_P(PSTR("A"), (modifiers & MOD_MASK_ALT));
164 oled_write_P(PSTR("G"), (modifiers & MOD_MASK_GUI));
165}
166
167void render_bootmagic_status(void) {
168 /* Show Ctrl-Gui Swap options */
169 static const char PROGMEM logo[][2][3] = {
170 {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}},
171 {{0x95, 0x96, 0}, {0xb5, 0xb6, 0}},
172 };
173 oled_write_P(PSTR("BTMGK"), false);
174 oled_write_P(PSTR(" "), false);
175 oled_write_P(logo[0][0], !keymap_config.swap_lctl_lgui);
176 oled_write_P(logo[1][0], keymap_config.swap_lctl_lgui);
177 oled_write_P(PSTR(" "), false);
178 oled_write_P(logo[0][1], !keymap_config.swap_lctl_lgui);
179 oled_write_P(logo[1][1], keymap_config.swap_lctl_lgui);
180 oled_write_P(PSTR(" NKRO"), keymap_config.nkro);
181}
182
183void render_status_main(void) {
184 /* Show Keyboard Layout */
185 render_default_layer_state();
186 render_keylock_status(host_keyboard_leds());
187 render_mod_status(get_mods());
188 render_bootmagic_status();
189
190 render_keylogger_status();
191}
192
193void oled_task_user(void) {
194 update_log();
195 if (is_master) {
196 render_status_main(); // Renders the current keyboard state (layer, lock, caps, scroll, etc)
197 } else {
198 render_crkbd_logo();
199 }
200}
201
202bool process_record_user(uint16_t keycode, keyrecord_t *record) {
203 if (record->event.pressed) {
204 add_keylog(keycode);
205 }
206 return true;
207}
208#endif
diff --git a/keyboards/crkbd/keymaps/oled_sample/rules.mk b/keyboards/crkbd/keymaps/oled_sample/rules.mk
new file mode 100644
index 000000000..fb480bba8
--- /dev/null
+++ b/keyboards/crkbd/keymaps/oled_sample/rules.mk
@@ -0,0 +1,7 @@
1
2# Build Options
3# change to "no" to disable the options, or define them in the Makefile in
4# the appropriate keymap folder that will get included automatically
5#
6RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight.
7OLED_DRIVER_ENABLE = yes
diff --git a/keyboards/crkbd/rev1/common/common.c b/keyboards/crkbd/rev1/common/common.c
new file mode 100644
index 000000000..5ea7347de
--- /dev/null
+++ b/keyboards/crkbd/rev1/common/common.c
@@ -0,0 +1,21 @@
1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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 "common.h"
20
21uint8_t is_master;
diff --git a/keyboards/crkbd/rev1/common/common.h b/keyboards/crkbd/rev1/common/common.h
new file mode 100644
index 000000000..af1795f48
--- /dev/null
+++ b/keyboards/crkbd/rev1/common/common.h
@@ -0,0 +1,24 @@
1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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#pragma once
20
21#include "rev1.h"
22
23#define has_usb() is_keyboard_master()
24extern uint8_t is_master;
diff --git a/keyboards/crkbd/rev1/common/config.h b/keyboards/crkbd/rev1/common/config.h
new file mode 100644
index 000000000..12f5f7576
--- /dev/null
+++ b/keyboards/crkbd/rev1/common/config.h
@@ -0,0 +1,30 @@
1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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#pragma once
20
21#define PRODUCT Corne Keyboard Rev.1 (Split Common)
22
23#define USE_SERIAL
24#define SOFT_SERIAL_PIN D2
25
26#ifdef RGB_MATRIX_ENABLE
27# define RGB_MATRIX_SPLIT { 27, 27 }
28#endif
29
30#define DIODE_DIRECTION COL2ROW
diff --git a/keyboards/crkbd/rev1/common/keymaps/via/config.h b/keyboards/crkbd/rev1/common/keymaps/via/config.h
new file mode 100644
index 000000000..aa2d45e56
--- /dev/null
+++ b/keyboards/crkbd/rev1/common/keymaps/via/config.h
@@ -0,0 +1,46 @@
1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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
20
21#pragma once
22
23//#define USE_MATRIX_I2C
24#ifdef KEYBOARD_crkbd_rev1_legacy
25# undef USE_I2C
26# define USE_SERIAL
27#endif
28
29/* Select hand configuration */
30
31#define MASTER_LEFT
32// #define MASTER_RIGHT
33// #define EE_HANDS
34
35#define USE_SERIAL_PD2
36
37
38#undef RGBLED_NUM
39#define RGBLIGHT_ANIMATIONS
40#define RGBLED_NUM 27
41#define RGBLIGHT_LIMIT_VAL 120
42#define RGBLIGHT_HUE_STEP 10
43#define RGBLIGHT_SAT_STEP 17
44#define RGBLIGHT_VAL_STEP 17
45
46#define OLED_FONT_H "keyboards/crkbd/lib/glcdfont.c"
diff --git a/keyboards/crkbd/rev1/common/keymaps/via/keymap.c b/keyboards/crkbd/rev1/common/keymaps/via/keymap.c
new file mode 100644
index 000000000..a3b2e52ce
--- /dev/null
+++ b/keyboards/crkbd/rev1/common/keymaps/via/keymap.c
@@ -0,0 +1,193 @@
1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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 QMK_KEYBOARD_H
20
21const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
22 [0] = LAYOUT_split_3x6_3( \
23 //,-----------------------------------------------------. ,-----------------------------------------------------.
24 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
25 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
26 KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
27 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
28 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ESC,
29 //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
30 KC_LGUI, FN_MO13, KC_SPC, KC_ENT, FN_MO23, KC_RALT
31 //`--------------------------' `--------------------------'
32
33 ),
34
35 [1] = LAYOUT_split_3x6_3( \
36 //,-----------------------------------------------------. ,-----------------------------------------------------.
37 KC_TAB, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
38 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
39 KC_LCTL, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_LEFT, KC_DOWN, KC_UP,KC_RIGHT, XXXXXXX, XXXXXXX,
40 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
41 KC_LSFT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
42 //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
43 KC_LGUI, _______, KC_SPC, KC_ENT, _______, KC_RALT\
44 //`--------------------------' `--------------------------'
45 ),
46
47 [2] = LAYOUT_split_3x6_3( \
48 //,-----------------------------------------------------. ,-----------------------------------------------------.
49 KC_TAB, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC,
50 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
51 KC_LCTL, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, KC_GRV,
52 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
53 KC_LSFT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, KC_TILD,
54 //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
55 KC_LGUI, _______, KC_SPC, KC_ENT, _______, KC_RALT
56 //`--------------------------' `--------------------------'
57 ),
58
59 [3] = LAYOUT_split_3x6_3( \
60 //,-----------------------------------------------------. ,-----------------------------------------------------.
61 RESET, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,\
62 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
63 RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,\
64 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
65 RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,\
66 //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------|
67 KC_LGUI, _______, KC_SPC, KC_ENT, _______, KC_RALT\
68 //`--------------------------' `--------------------------'
69 )
70};
71
72#ifdef OLED_DRIVER_ENABLE
73oled_rotation_t oled_init_user(oled_rotation_t rotation) {
74 if (!is_master) {
75 return OLED_ROTATION_180; // flips the display 180 degrees if offhand
76 }
77 return rotation;
78}
79
80#define L_BASE 0
81#define L_LOWER 2
82#define L_RAISE 4
83#define L_ADJUST 8
84
85void oled_render_layer_state(void) {
86 oled_write_P("Layer: ", false);
87 switch (layer_state) {
88 case L_BASE:
89 oled_write_ln_P("Default", false);
90 break;
91 case L_LOWER:
92 oled_write_ln_P("Lower", false);
93 break;
94 case L_RAISE:
95 oled_write_ln_P("Raise", false);
96 break;
97 case L_ADJUST:
98 case L_ADJUST|L_LOWER:
99 case L_ADJUST|L_RAISE:
100 case L_ADJUST|L_LOWER|L_RAISE:
101 oled_write_ln_P("Adjust", false);
102 break;
103 }
104}
105
106
107char keylog_str[24] = {};
108char keylogs_str[21] = {};
109int keylogs_str_idx = 0;
110
111const char code_to_name[60] = {
112 ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
113 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
114 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
115 '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
116 'R', 'E', 'B', 'T', '_', '-', '=', '[', ']', '\\',
117 '#', ';', '\'', '`', ',', '.', '/', ' ', ' ', ' '};
118
119void set_keylog(uint16_t keycode, keyrecord_t *record) {
120 char name = ' ';
121 if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) ||
122 (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) { keycode = keycode & 0xFF; }
123 if (keycode < 60) {
124 name = code_to_name[keycode];
125 }
126
127 // update keylog
128 snprintf(keylog_str, sizeof(keylog_str), "%dx%d, k%2d : %c",
129 record->event.key.row, record->event.key.col,
130 keycode, name);
131
132 // update keylogs
133 if (keylogs_str_idx == sizeof(keylogs_str) - 1) {
134 keylogs_str_idx = 0;
135 for (int i = 0; i < sizeof(keylogs_str) - 1; i++) {
136 keylogs_str[i] = ' ';
137 }
138 }
139
140 keylogs_str[keylogs_str_idx] = name;
141 keylogs_str_idx++;
142}
143
144void oled_render_keylog(void) {
145 oled_write(keylog_str, false);
146}
147void oled_render_keylogs(void) {
148 oled_write(keylogs_str, false);
149}
150
151void render_bootmagic_status(bool status) {
152 /* Show Ctrl-Gui Swap options */
153 static const char PROGMEM logo[][2][3] = {
154 {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}},
155 {{0x95, 0x96, 0}, {0xb5, 0xb6, 0}},
156 };
157 if (status) {
158 oled_write_ln_P(logo[0][0], false);
159 oled_write_ln_P(logo[0][1], false);
160 } else {
161 oled_write_ln_P(logo[1][0], false);
162 oled_write_ln_P(logo[1][1], false);
163 }
164}
165
166void oled_render_logo(void) {
167 static const char PROGMEM crkbd_logo[] = {
168 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94,
169 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4,
170 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4,
171 0};
172 oled_write_P(crkbd_logo, false);
173}
174
175void oled_task_user(void) {
176 if (is_master) {
177 oled_render_layer_state();
178 oled_render_keylog();
179 // oled_render_keylogs();
180 // oled_renger_bootmagic_icon(keymap_config.swap_lalt_lgui);
181 } else {
182 oled_render_logo();
183 }
184}
185
186bool process_record_user(uint16_t keycode, keyrecord_t *record) {
187 if (record->event.pressed) {
188 set_keylog(keycode, record);
189 // set_timelog();
190 }
191 return true;
192}
193#endif // OLED_DRIVER_ENABLE
diff --git a/keyboards/crkbd/rev1/common/keymaps/via/rules.mk b/keyboards/crkbd/rev1/common/keymaps/via/rules.mk
new file mode 100644
index 000000000..93b2afed4
--- /dev/null
+++ b/keyboards/crkbd/rev1/common/keymaps/via/rules.mk
@@ -0,0 +1,5 @@
1MOUSEKEY_ENABLE = no # Mouse keys
2RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight.
3VIA_ENABLE = yes # Enable VIA
4OLED_DRIVER_ENABLE = yes
5LTO_ENABLE = yes
diff --git a/keyboards/crkbd/rev1/common/rules.mk b/keyboards/crkbd/rev1/common/rules.mk
new file mode 100644
index 000000000..0b8106e3f
--- /dev/null
+++ b/keyboards/crkbd/rev1/common/rules.mk
@@ -0,0 +1,2 @@
1SPLIT_KEYBOARD = yes
2SPLIT_TRANSPORT = mirror # for when Split Mirroring drops, it will maintain mirroring functionality
diff --git a/keyboards/crkbd/rev1/common/ssd1306.c b/keyboards/crkbd/rev1/common/ssd1306.c
new file mode 100644
index 000000000..4a889da67
--- /dev/null
+++ b/keyboards/crkbd/rev1/common/ssd1306.c
@@ -0,0 +1,360 @@
1#ifdef SSD1306OLED
2
3#include "ssd1306.h"
4#include "i2c_master.h"
5#include <string.h>
6#include "print.h"
7#ifdef ADAFRUIT_BLE_ENABLE
8#include "adafruit_ble.h"
9#endif
10#ifdef PROTOCOL_LUFA
11#include "lufa.h"
12#endif
13#include "sendchar.h"
14#include "timer.h"
15
16struct CharacterMatrix display;
17
18extern const unsigned char font[] PROGMEM;
19
20#ifndef OLED_BLANK_CHAR
21#define OLED_BLANK_CHAR ' '
22#endif
23
24#ifndef OLED_BITS_FILTER
25#define OLED_BITS_FILTER
26#endif
27
28// Set this to 1 to help diagnose early startup problems
29// when testing power-on with ble. Turn it off otherwise,
30// as the latency of printing most of the debug info messes
31// with the matrix scan, causing keys to drop.
32#define DEBUG_TO_SCREEN 0
33
34//static uint16_t last_battery_update;
35//static uint32_t vbat;
36//#define BatteryUpdateInterval 10000 /* milliseconds */
37
38// 'last_flush' is declared as uint16_t,
39// so this must be less than 65535
40#ifndef ScreenOffInterval
41#define ScreenOffInterval 60000 /* milliseconds */
42#endif
43
44#if DEBUG_TO_SCREEN
45static uint8_t displaying;
46#endif
47static uint16_t last_flush;
48
49static bool force_dirty = true;
50
51// Write command sequence.
52// Returns true on success.
53static inline bool _send_cmd1(uint8_t cmd) {
54 bool res = false;
55
56 if (i2c_start(SSD1306_ADDRESS, 100)) {
57 xprintf("failed to start write to %d\n", SSD1306_ADDRESS);
58 goto done;
59 }
60
61 if (i2c_write(0x0 /* command byte follows */, 100)) {
62 print("failed to write control byte\n");
63
64 goto done;
65 }
66
67 if (i2c_write(cmd, 100)) {
68 xprintf("failed to write command %d\n", cmd);
69 goto done;
70 }
71 res = true;
72done:
73 i2c_stop();
74 return res;
75}
76
77#define send_cmd1(c) if (!_send_cmd1(c)) {goto done;}
78#define send_cmds(c) if (!_send_cmds(c,sizeof(c))) {goto done;}
79#define cmd1(X) X
80#define cmd2(X,Y) X,Y
81#define cmd3(X,Y,Z) X,Y,Z
82
83static bool _send_cmds(const uint8_t* p,uint8_t sz) {
84 for(uint8_t i=sz;i;i--) {
85 send_cmd1( pgm_read_byte(p++) );
86 }
87 return true;
88done:
89 return false;
90}
91
92#define SEND_CMDS(...) {static const uint8_t _cmds[] PROGMEM = { __VA_ARGS__,0 };send_cmds(_cmds);}
93
94static void clear_display(void) {
95 matrix_clear(&display);
96
97 // Clear all of the display bits (there can be random noise
98 // in the RAM on startup)
99 SEND_CMDS(
100 cmd3(PageAddr, 0, (DisplayHeight / 8) - 1),
101 cmd3(ColumnAddr, 0, DisplayWidth - 1)
102 );
103
104 if (i2c_start(SSD1306_ADDRESS, 100)) {
105 goto done;
106 }
107 if (i2c_write(0x40, 100)) {
108 // Data mode
109 goto done;
110 }
111 for (uint8_t row = MatrixRows;row; row--) {
112 for (uint8_t col = DisplayWidth; col; col--) {
113 i2c_write(0, 100);
114 }
115 }
116
117 display.dirty = false;
118
119done:
120 i2c_stop();
121}
122
123#if DEBUG_TO_SCREEN
124#undef sendchar
125static int8_t capture_sendchar(uint8_t c) {
126 sendchar(c);
127 iota_gfx_write_char(c);
128
129 if (!displaying) {
130 iota_gfx_flush();
131 }
132 return 0;
133}
134#endif
135
136bool iota_gfx_init(bool rotate) {
137 bool success = false;
138
139 i2c_init();
140 SEND_CMDS(
141 cmd1(DisplayOff),
142 cmd2(SetDisplayClockDiv, 0x80),
143 cmd2(SetMultiPlex, DisplayHeight - 1),
144 cmd2(SetDisplayOffset, 0),
145 cmd1(SetStartLine | 0x0),
146 cmd2(SetChargePump, 0x14 /* Enable */),
147 cmd2(SetMemoryMode, 0 /* horizontal addressing */)
148 );
149
150 if(rotate){
151 // the following Flip the display orientation 180 degrees
152 SEND_CMDS(
153 cmd1(SegRemap),
154 cmd1(ComScanInc)
155 );
156 }else{
157 // Flips the display orientation 0 degrees
158 SEND_CMDS(
159 cmd1(SegRemap | 0x1),
160 cmd1(ComScanDec)
161 );
162 }
163
164 SEND_CMDS(
165#ifdef SSD1306_128X64
166 cmd2(SetComPins, 0x12),
167#else
168 cmd2(SetComPins, 0x2),
169#endif
170 cmd2(SetContrast, 0x8f),
171 cmd2(SetPreCharge, 0xf1),
172 cmd2(SetVComDetect, 0x40),
173 cmd1(DisplayAllOnResume),
174 cmd1(NormalDisplay),
175 cmd1(DeActivateScroll),
176 cmd1(DisplayOn),
177
178 cmd2(SetContrast, 0) // Dim
179 );
180
181 clear_display();
182
183 success = true;
184
185 iota_gfx_flush();
186
187#if DEBUG_TO_SCREEN
188 print_set_sendchar(capture_sendchar);
189#endif
190
191done:
192 return success;
193}
194
195bool iota_gfx_off(void) {
196 bool success = false;
197
198 send_cmd1(DisplayOff);
199 success = true;
200
201done:
202 return success;
203}
204
205bool iota_gfx_on(void) {
206 bool success = false;
207
208 send_cmd1(DisplayOn);
209 success = true;
210
211done:
212 return success;
213}
214
215void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c) {
216 *matrix->cursor = c;
217 ++matrix->cursor;
218
219 if (matrix->cursor - &matrix->display[0][0] == sizeof(matrix->display)) {
220 // We went off the end; scroll the display upwards by one line
221 memmove(&matrix->display[0], &matrix->display[1],
222 MatrixCols * (MatrixRows - 1));
223 matrix->cursor = &matrix->display[MatrixRows - 1][0];
224 memset(matrix->cursor, OLED_BLANK_CHAR, MatrixCols);
225 }
226}
227
228void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c) {
229 matrix->dirty = true;
230
231 if (c == '\n') {
232 // Clear to end of line from the cursor and then move to the
233 // start of the next line
234 uint8_t cursor_col = (matrix->cursor - &matrix->display[0][0]) % MatrixCols;
235
236 while (cursor_col++ < MatrixCols) {
237 matrix_write_char_inner(matrix, OLED_BLANK_CHAR);
238 }
239 return;
240 }
241
242 matrix_write_char_inner(matrix, c);
243}
244
245void iota_gfx_write_char(uint8_t c) {
246 matrix_write_char(&display, c);
247}
248
249void matrix_write(struct CharacterMatrix *matrix, const char *data) {
250 while (*data) {
251 matrix_write_char(matrix, *data);
252 ++data;
253 }
254}
255
256void matrix_write_ln(struct CharacterMatrix *matrix, const char *data) {
257 matrix_write(matrix, data);
258 matrix_write(matrix, "\n");
259}
260
261void iota_gfx_write(const char *data) {
262 matrix_write(&display, data);
263}
264
265void matrix_write_P(struct CharacterMatrix *matrix, const char *data) {
266 while (true) {
267 uint8_t c = pgm_read_byte(data);
268 if (c == 0) {
269 return;
270 }
271 matrix_write_char(matrix, c);
272 ++data;
273 }
274}
275
276void iota_gfx_write_P(const char *data) {
277 matrix_write_P(&display, data);
278}
279
280void matrix_clear(struct CharacterMatrix *matrix) {
281 memset(matrix->display, OLED_BLANK_CHAR, sizeof(matrix->display));
282 matrix->cursor = &matrix->display[0][0];
283 matrix->dirty = true;
284}
285
286void iota_gfx_clear_screen(void) {
287 matrix_clear(&display);
288}
289
290void matrix_render(struct CharacterMatrix *matrix) {
291 last_flush = timer_read();
292 iota_gfx_on();
293#if DEBUG_TO_SCREEN
294 ++displaying;
295#endif
296
297 // Move to the home position
298 SEND_CMDS(
299 cmd3(PageAddr, 0, MatrixRows - 1),
300 cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1)
301 );
302
303 if (i2c_write(SSD1306_ADDRESS, 100)) {
304 goto done;
305 }
306 if (i2c_write(0x40, 100)) {
307 // Data mode
308 goto done;
309 }
310
311 for (uint8_t row = 0; row < MatrixRows; ++row) {
312 for (uint8_t col = 0; col < MatrixCols; ++col) {
313 const uint8_t *glyph = font + (matrix->display[row][col] * FontWidth);
314
315 for (uint8_t glyphCol = 0; glyphCol < FontWidth; ++glyphCol) {
316 uint8_t colBits = pgm_read_byte(glyph + glyphCol);
317 i2c_write(colBits OLED_BITS_FILTER, 100);
318 }
319
320 // 1 column of space between chars (it's not included in the glyph)
321 //i2c_master_write(0);
322 }
323 }
324
325 matrix->dirty = false;
326
327done:
328 i2c_stop();
329#if DEBUG_TO_SCREEN
330 --displaying;
331#endif
332}
333
334void iota_gfx_flush(void) {
335 matrix_render(&display);
336}
337
338__attribute__ ((weak))
339void iota_gfx_task_user(void) {
340}
341
342void iota_gfx_task(void) {
343 iota_gfx_task_user();
344
345 if (display.dirty|| force_dirty) {
346 iota_gfx_flush();
347 force_dirty = false;
348 }
349
350 if (ScreenOffInterval !=0 && timer_elapsed(last_flush) > ScreenOffInterval) {
351 iota_gfx_off();
352 }
353}
354
355bool process_record_gfx(uint16_t keycode, keyrecord_t *record) {
356 force_dirty = true;
357 return true;
358}
359
360#endif
diff --git a/keyboards/crkbd/rev1/config.h b/keyboards/crkbd/rev1/config.h
index f7f278f2c..60bd37972 100644
--- a/keyboards/crkbd/rev1/config.h
+++ b/keyboards/crkbd/rev1/config.h
@@ -1,6 +1,6 @@
1/* 1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com> 2Copyright 2019 @foostan
3Copyright 2015 Jack Humbert 3Copyright 2020 Drashna Jaelre <@drashna>
4 4
5This program is free software: you can redistribute it and/or modify 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 6it under the terms of the GNU General Public License as published by
@@ -18,64 +18,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18 18
19#pragma once 19#pragma once
20 20
21/* USB Device descriptor parameter */
22#define VENDOR_ID 0xFEED
23#define PRODUCT_ID 0x3060
24#define DEVICE_VER 0x0001
25#define MANUFACTURER foostan
26#define PRODUCT Corne Keyboard (crkbd)
27#define DESCRIPTION A split keyboard with 3x6 vertically staggered keys and 3 thumb keys
28
29/* key matrix size */
30// Rows are doubled-up
31#define MATRIX_ROWS 8
32#define MATRIX_COLS 6
33#define MATRIX_ROW_PINS { D4, C6, D7, E6 }
34
35// wiring of each half
36#define MATRIX_COL_PINS { F4, F5, F6, F7, B1, B3 }
37// #define MATRIX_COL_PINS { B2, B3, B1, F7, F6, F5, F4 } //uncomment this line and comment line above if you need to reverse left-to-right key order
38
39/* define if matrix has ghost */
40//#define MATRIX_HAS_GHOST
41
42/* number of backlight levels */
43// #define BACKLIGHT_LEVELS 3
44
45/* Set 0 if debouncing isn't needed */
46#define DEBOUNCE 5
47
48/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
49//#define LOCKING_SUPPORT_ENABLE
50/* Locking resynchronize hack */
51//#define LOCKING_RESYNC_ENABLE
52
53/* ws2812 RGB LED */ 21/* ws2812 RGB LED */
54#define RGB_DI_PIN D3 22#define RGB_DI_PIN D3
55 23
56#ifdef RGBLIGHT_ENABLE 24#ifdef RGBLIGHT_ENABLE
57#define RGBLED_NUM 12 // Number of LEDs 25# define RGBLED_NUM 12 // Number of LEDs
26# define RGBLIGHT_SPLIT
58#endif 27#endif
59 28
60#ifdef RGB_MATRIX_ENABLE 29#ifdef RGB_MATRIX_ENABLE
61#define RGBLED_NUM 54 // Number of LEDs 30# define RGBLED_NUM 54 // Number of LEDs
62#define DRIVER_LED_TOTAL RGBLED_NUM 31# define DRIVER_LED_TOTAL RGBLED_NUM
63#endif 32#endif
64
65/*
66 * Feature disable options
67 * These options are also useful to firmware size reduction.
68 */
69
70/* disable debug print */
71// #define NO_DEBUG
72
73/* disable print */
74// #define NO_PRINT
75
76/* disable action features */
77//#define NO_ACTION_LAYER
78//#define NO_ACTION_TAPPING
79//#define NO_ACTION_ONESHOT
80//#define NO_ACTION_MACRO
81//#define NO_ACTION_FUNCTION
diff --git a/keyboards/crkbd/rev1/legacy/config.h b/keyboards/crkbd/rev1/legacy/config.h
new file mode 100644
index 000000000..9e3676414
--- /dev/null
+++ b/keyboards/crkbd/rev1/legacy/config.h
@@ -0,0 +1,23 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3Copyright 2015 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
19#pragma once
20
21#include <serial_config.h>
22
23#define PRODUCT Corne Keyboard Rev.1 (Legacy Split)
diff --git a/keyboards/crkbd/i2c.c b/keyboards/crkbd/rev1/legacy/i2c.c
index 4bee5c639..7b45c3f86 100644
--- a/keyboards/crkbd/i2c.c
+++ b/keyboards/crkbd/rev1/legacy/i2c.c
@@ -6,7 +6,7 @@
6#include <stdbool.h> 6#include <stdbool.h>
7#include "i2c.h" 7#include "i2c.h"
8 8
9#ifdef USE_I2C 9#if defined(USE_I2C) || defined(USE_MATRIX_I2C)
10 10
11// Limits the amount of we wait for any one i2c transaction. 11// Limits the amount of we wait for any one i2c transaction.
12// Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is 12// Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is
diff --git a/keyboards/crkbd/i2c.h b/keyboards/crkbd/rev1/legacy/i2c.h
index 710662c7a..710662c7a 100644
--- a/keyboards/crkbd/i2c.h
+++ b/keyboards/crkbd/rev1/legacy/i2c.h
diff --git a/keyboards/crkbd/rev1/legacy/legacy.c b/keyboards/crkbd/rev1/legacy/legacy.c
new file mode 100644
index 000000000..595ff1eaf
--- /dev/null
+++ b/keyboards/crkbd/rev1/legacy/legacy.c
@@ -0,0 +1,19 @@
1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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 "legacy.h"
diff --git a/keyboards/crkbd/rev1/legacy/legacy.h b/keyboards/crkbd/rev1/legacy/legacy.h
new file mode 100644
index 000000000..6c6308e59
--- /dev/null
+++ b/keyboards/crkbd/rev1/legacy/legacy.h
@@ -0,0 +1,21 @@
1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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#pragma once
20
21#include "rev1.h"
diff --git a/keyboards/crkbd/rev1/matrix.c b/keyboards/crkbd/rev1/legacy/matrix.c
index 46dead369..46dead369 100644
--- a/keyboards/crkbd/rev1/matrix.c
+++ b/keyboards/crkbd/rev1/legacy/matrix.c
diff --git a/keyboards/crkbd/rev1/legacy/post_config.h b/keyboards/crkbd/rev1/legacy/post_config.h
new file mode 100644
index 000000000..b3d6346cc
--- /dev/null
+++ b/keyboards/crkbd/rev1/legacy/post_config.h
@@ -0,0 +1,27 @@
1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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#pragma once
20
21#ifdef SSD1306OLED
22# define USE_I2C
23#endif
24
25#if defined(OLED_DRIVER_ENABLE) && (defined(USE_I2C) || defined(USE_MATRIX_I2C))
26# error Cannot use both legacy i2c driver and new i2c_master driver at the same time. Undefine USE_I2C and/or USE_MATRIX_I2C
27#endif
diff --git a/keyboards/crkbd/rev1/legacy/rules.mk b/keyboards/crkbd/rev1/legacy/rules.mk
new file mode 100644
index 000000000..2bef24297
--- /dev/null
+++ b/keyboards/crkbd/rev1/legacy/rules.mk
@@ -0,0 +1,7 @@
1CUSTOM_MATRIX = yes
2
3SRC += matrix.c \
4 split_util.c \
5 split_scomm.c
6
7QUANTUM_LIB_SRC += i2c.c serial.c
diff --git a/keyboards/crkbd/serial.c b/keyboards/crkbd/rev1/legacy/serial.c
index f6293c3dc..f6293c3dc 100644
--- a/keyboards/crkbd/serial.c
+++ b/keyboards/crkbd/rev1/legacy/serial.c
diff --git a/keyboards/crkbd/serial.h b/keyboards/crkbd/rev1/legacy/serial.h
index 7e0c0847a..7e0c0847a 100644
--- a/keyboards/crkbd/serial.h
+++ b/keyboards/crkbd/rev1/legacy/serial.h
diff --git a/keyboards/crkbd/rev1/legacy/serial_config.h b/keyboards/crkbd/rev1/legacy/serial_config.h
new file mode 100644
index 000000000..40d11d4de
--- /dev/null
+++ b/keyboards/crkbd/rev1/legacy/serial_config.h
@@ -0,0 +1,22 @@
1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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#ifndef SOFT_SERIAL_PIN
20#define SOFT_SERIAL_PIN D2
21#define SERIAL_USE_MULTI_TRANSACTION
22#endif
diff --git a/keyboards/crkbd/rev1/legacy/serial_config_simpleapi.h b/keyboards/crkbd/rev1/legacy/serial_config_simpleapi.h
new file mode 100644
index 000000000..bd152ddda
--- /dev/null
+++ b/keyboards/crkbd/rev1/legacy/serial_config_simpleapi.h
@@ -0,0 +1,23 @@
1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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#pragma once
20
21#undef SERIAL_USE_MULTI_TRANSACTION
22#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
23#define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2
diff --git a/keyboards/crkbd/rev1/split_scomm.c b/keyboards/crkbd/rev1/legacy/split_scomm.c
index 12b00f684..c14bb32a4 100644
--- a/keyboards/crkbd/rev1/split_scomm.c
+++ b/keyboards/crkbd/rev1/legacy/split_scomm.c
@@ -1,3 +1,21 @@
1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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
1#ifdef USE_SERIAL 19#ifdef USE_SERIAL
2#ifdef SERIAL_USE_MULTI_TRANSACTION 20#ifdef SERIAL_USE_MULTI_TRANSACTION
3/* --- USE flexible API (using multi-type transaction function) --- */ 21/* --- USE flexible API (using multi-type transaction function) --- */
diff --git a/keyboards/crkbd/rev1/split_scomm.h b/keyboards/crkbd/rev1/legacy/split_scomm.h
index 873d8939d..47f0ca1b9 100644
--- a/keyboards/crkbd/rev1/split_scomm.h
+++ b/keyboards/crkbd/rev1/legacy/split_scomm.h
@@ -1,3 +1,21 @@
1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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
1#ifndef SPLIT_COMM_H 19#ifndef SPLIT_COMM_H
2#define SPLIT_COMM_H 20#define SPLIT_COMM_H
3 21
diff --git a/keyboards/crkbd/rev1/split_util.c b/keyboards/crkbd/rev1/legacy/split_util.c
index b642a734c..d0fee04ad 100644
--- a/keyboards/crkbd/rev1/split_util.c
+++ b/keyboards/crkbd/rev1/legacy/split_util.c
@@ -1,3 +1,21 @@
1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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
1#include <avr/io.h> 19#include <avr/io.h>
2#include <avr/wdt.h> 20#include <avr/wdt.h>
3#include <avr/power.h> 21#include <avr/power.h>
@@ -14,7 +32,7 @@
14#endif 32#endif
15 33
16#ifdef USE_MATRIX_I2C 34#ifdef USE_MATRIX_I2C
17# include "i2c.h" 35# include "i2c_master.h"
18#else 36#else
19# include "split_scomm.h" 37# include "split_scomm.h"
20#endif 38#endif
@@ -81,7 +99,7 @@ __attribute__((weak)) bool has_usb(void) {
81static void keyboard_master_setup(void) { 99static void keyboard_master_setup(void) {
82 100
83#ifdef USE_MATRIX_I2C 101#ifdef USE_MATRIX_I2C
84 i2c_master_init(); 102 i2c_init();
85#else 103#else
86 serial_master_init(); 104 serial_master_init();
87#endif 105#endif
diff --git a/keyboards/crkbd/rev1/legacy/split_util.h b/keyboards/crkbd/rev1/legacy/split_util.h
new file mode 100644
index 000000000..414763bff
--- /dev/null
+++ b/keyboards/crkbd/rev1/legacy/split_util.h
@@ -0,0 +1,37 @@
1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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#ifndef SPLIT_KEYBOARD_UTIL_H
20#define SPLIT_KEYBOARD_UTIL_H
21
22#include <stdbool.h>
23#include "eeconfig.h"
24
25#define SLAVE_I2C_ADDRESS 0x32
26
27extern volatile bool isLeftHand;
28
29// slave version of matix scan, defined in matrix.c
30void matrix_slave_scan(void);
31
32void split_keyboard_setup(void);
33bool has_usb(void);
34
35void matrix_master_OLED_init (void);
36
37#endif
diff --git a/keyboards/crkbd/ssd1306.c b/keyboards/crkbd/rev1/legacy/ssd1306.c
index 4ec8a9a00..b04b7e15c 100644
--- a/keyboards/crkbd/ssd1306.c
+++ b/keyboards/crkbd/rev1/legacy/ssd1306.c
@@ -134,7 +134,7 @@ bool iota_gfx_init(bool rotate) {
134 bool success = false; 134 bool success = false;
135 135
136 i2c_master_init(); 136 i2c_master_init();
137 SEND_CMDS( 137 SEND_CMDS(
138 cmd1(DisplayOff), 138 cmd1(DisplayOff),
139 cmd2(SetDisplayClockDiv, 0x80), 139 cmd2(SetDisplayClockDiv, 0x80),
140 cmd2(SetMultiPlex, DisplayHeight - 1), 140 cmd2(SetMultiPlex, DisplayHeight - 1),
@@ -146,19 +146,19 @@ bool iota_gfx_init(bool rotate) {
146 146
147 if(rotate){ 147 if(rotate){
148 // the following Flip the display orientation 180 degrees 148 // the following Flip the display orientation 180 degrees
149 SEND_CMDS( 149 SEND_CMDS(
150 cmd1(SegRemap), 150 cmd1(SegRemap),
151 cmd1(ComScanInc) 151 cmd1(ComScanInc)
152 ); 152 );
153 }else{ 153 }else{
154 // Flips the display orientation 0 degrees 154 // Flips the display orientation 0 degrees
155 SEND_CMDS( 155 SEND_CMDS(
156 cmd1(SegRemap | 0x1), 156 cmd1(SegRemap | 0x1),
157 cmd1(ComScanDec) 157 cmd1(ComScanDec)
158 ); 158 );
159 } 159 }
160 160
161 SEND_CMDS( 161 SEND_CMDS(
162#ifdef SSD1306_128X64 162#ifdef SSD1306_128X64
163 cmd2(SetComPins, 0x12), 163 cmd2(SetComPins, 0x12),
164#else 164#else
@@ -171,10 +171,10 @@ bool iota_gfx_init(bool rotate) {
171 cmd1(NormalDisplay), 171 cmd1(NormalDisplay),
172 cmd1(DeActivateScroll), 172 cmd1(DeActivateScroll),
173 cmd1(DisplayOn), 173 cmd1(DisplayOn),
174 174
175 cmd2(SetContrast, 0) // Dim 175 cmd2(SetContrast, 0) // Dim
176 ); 176 );
177 177
178 clear_display(); 178 clear_display();
179 179
180 success = true; 180 success = true;
diff --git a/keyboards/crkbd/rev1/rev1.c b/keyboards/crkbd/rev1/rev1.c
index b26292af5..5e4e6560f 100644
--- a/keyboards/crkbd/rev1/rev1.c
+++ b/keyboards/crkbd/rev1/rev1.c
@@ -1,4 +1,21 @@
1#include "crkbd.h" 1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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 "rev1.h"
2 19
3#ifdef RGB_MATRIX_ENABLE 20#ifdef RGB_MATRIX_ENABLE
4 21
@@ -68,11 +85,12 @@ led_config_t g_led_config = { {
68} }; 85} };
69#endif 86#endif
70 87
71__attribute__((weak))
72void matrix_init_user(void) {}
73
74void matrix_init_kb(void) { 88void matrix_init_kb(void) {
75 89
90#ifdef KEYBOARD_crkbd_rev1_common
91 is_master = (uint8_t)is_keyboard_master();
92#endif
93
76#ifdef RGB_MATRIX_ENABLE 94#ifdef RGB_MATRIX_ENABLE
77 if (!isLeftHand) { 95 if (!isLeftHand) {
78 g_led_config = (led_config_t){ { 96 g_led_config = (led_config_t){ {
@@ -107,3 +125,9 @@ void matrix_init_kb(void) {
107#endif 125#endif
108 matrix_init_user(); 126 matrix_init_user();
109} 127}
128
129#ifdef SSD1306OLED
130bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
131 return process_record_gfx(keycode,record) && process_record_user(keycode, record);
132}
133#endif
diff --git a/keyboards/crkbd/rev1/rev1.h b/keyboards/crkbd/rev1/rev1.h
index 2244b87f1..ce88068e6 100644
--- a/keyboards/crkbd/rev1/rev1.h
+++ b/keyboards/crkbd/rev1/rev1.h
@@ -1,25 +1,41 @@
1/*
2Copyright 2019 @foostan
3Copyright 2020 Drashna Jaelre <@drashna>
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
1#pragma once 19#pragma once
2 20
21extern uint8_t is_master;
22
3#include "crkbd.h" 23#include "crkbd.h"
24#if defined(KEYBOARD_crkbd_rev1_legacy)
25# include "legacy.h"
26#elif defined(KEYBOARD_crkbd_rev1_common)
27# include "common.h"
28#endif
4 29
5#include "quantum.h" 30#include "quantum.h"
6 31#include "split_util.h"
7#ifdef PROTOCOL_LUFA 32#ifdef PROTOCOL_LUFA
8 #include "lufa.h" 33# include "lufa.h"
9 #include "split_util.h"
10#endif 34#endif
11
12#ifdef SSD1306OLED 35#ifdef SSD1306OLED
13 #include "ssd1306.h" 36# include "ssd1306.h"
14#endif 37#endif
15 38
16#ifdef USE_I2C
17 #include <stddef.h>
18 #ifdef __AVR__
19 #include <avr/interrupt.h>
20 #include <avr/io.h>
21 #endif
22#endif
23 39
24// clang-format off 40// clang-format off
25#define LAYOUT_split_3x6_3( \ 41#define LAYOUT_split_3x6_3( \
@@ -62,7 +78,7 @@
62 L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \ 78 L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \
63 L30, L31, L32, R30, R31, R32 \ 79 L30, L31, L32, R30, R31, R32 \
64 ) \ 80 ) \
65 LAYOUT( \ 81 LAYOUT_split_3x6_3( \
66 KC_##L00, KC_##L01, KC_##L02, KC_##L03, KC_##L04, KC_##L05, KC_##R00, KC_##R01, KC_##R02, KC_##R03, KC_##R04, KC_##R05, \ 82 KC_##L00, KC_##L01, KC_##L02, KC_##L03, KC_##L04, KC_##L05, KC_##R00, KC_##R01, KC_##R02, KC_##R03, KC_##R04, KC_##R05, \
67 KC_##L10, KC_##L11, KC_##L12, KC_##L13, KC_##L14, KC_##L15, KC_##R10, KC_##R11, KC_##R12, KC_##R13, KC_##R14, KC_##R15, \ 83 KC_##L10, KC_##L11, KC_##L12, KC_##L13, KC_##L14, KC_##L15, KC_##R10, KC_##R11, KC_##R12, KC_##R13, KC_##R14, KC_##R15, \
68 KC_##L20, KC_##L21, KC_##L22, KC_##L23, KC_##L24, KC_##L25, KC_##R20, KC_##R21, KC_##R22, KC_##R23, KC_##R24, KC_##R25, \ 84 KC_##L20, KC_##L21, KC_##L22, KC_##L23, KC_##L24, KC_##L25, KC_##R20, KC_##R21, KC_##R22, KC_##R23, KC_##R24, KC_##R25, \
diff --git a/keyboards/crkbd/rev1/rules.mk b/keyboards/crkbd/rev1/rules.mk
index 21cee6bcf..6bc5a5b03 100644
--- a/keyboards/crkbd/rev1/rules.mk
+++ b/keyboards/crkbd/rev1/rules.mk
@@ -1,5 +1,3 @@
1SRC += matrix.c \ 1LIB_SRC += ssd1306.c
2 split_util.c \
3 split_scomm.c
4 2
5LAYOUTS = split_3x5_3 split_3x6_3 3DEFAULT_FOLDER = crkbd/rev1/legacy
diff --git a/keyboards/crkbd/rev1/serial_config.h b/keyboards/crkbd/rev1/serial_config.h
deleted file mode 100644
index 4fab8e8dd..000000000
--- a/keyboards/crkbd/rev1/serial_config.h
+++ /dev/null
@@ -1,4 +0,0 @@
1#ifndef SOFT_SERIAL_PIN
2#define SOFT_SERIAL_PIN D2
3#define SERIAL_USE_MULTI_TRANSACTION
4#endif
diff --git a/keyboards/crkbd/rev1/serial_config_simpleapi.h b/keyboards/crkbd/rev1/serial_config_simpleapi.h
deleted file mode 100644
index 0e1dd9e4a..000000000
--- a/keyboards/crkbd/rev1/serial_config_simpleapi.h
+++ /dev/null
@@ -1,5 +0,0 @@
1#pragma once
2
3#undef SERIAL_USE_MULTI_TRANSACTION
4#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
5#define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2
diff --git a/keyboards/crkbd/rev1/split_util.h b/keyboards/crkbd/rev1/split_util.h
deleted file mode 100644
index 687ca19bd..000000000
--- a/keyboards/crkbd/rev1/split_util.h
+++ /dev/null
@@ -1,19 +0,0 @@
1#ifndef SPLIT_KEYBOARD_UTIL_H
2#define SPLIT_KEYBOARD_UTIL_H
3
4#include <stdbool.h>
5#include "eeconfig.h"
6
7#define SLAVE_I2C_ADDRESS 0x32
8
9extern volatile bool isLeftHand;
10
11// slave version of matix scan, defined in matrix.c
12void matrix_slave_scan(void);
13
14void split_keyboard_setup(void);
15bool has_usb(void);
16
17void matrix_master_OLED_init (void);
18
19#endif
diff --git a/keyboards/crkbd/ssd1306.h b/keyboards/crkbd/rev1/ssd1306.h
index 11a3cc67f..11a3cc67f 100644
--- a/keyboards/crkbd/ssd1306.h
+++ b/keyboards/crkbd/rev1/ssd1306.h
diff --git a/keyboards/crkbd/rules.mk b/keyboards/crkbd/rules.mk
index 16d05b589..30de5b388 100644
--- a/keyboards/crkbd/rules.mk
+++ b/keyboards/crkbd/rules.mk
@@ -31,12 +31,8 @@ RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
31# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE 31# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
32SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend 32SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
33 33
34CUSTOM_MATRIX = yes
35QUANTUM_LIB_SRC += i2c.c \
36 serial.c
37SRC += ssd1306.c
38
39# if firmware size over limit, try this option 34# if firmware size over limit, try this option
40# CFLAGS += -flto 35# CFLAGS += -flto
36LAYOUTS = split_3x5_3 split_3x6_3
41 37
42DEFAULT_FOLDER = crkbd/rev1 38DEFAULT_FOLDER = crkbd/rev1/legacy