diff options
37 files changed, 2176 insertions, 2 deletions
@@ -21,4 +21,5 @@ COMMON_VPATH += $(QUANTUM_PATH)/keymap_extras | |||
21 | COMMON_VPATH += $(QUANTUM_PATH)/audio | 21 | COMMON_VPATH += $(QUANTUM_PATH)/audio |
22 | COMMON_VPATH += $(QUANTUM_PATH)/process_keycode | 22 | COMMON_VPATH += $(QUANTUM_PATH)/process_keycode |
23 | COMMON_VPATH += $(QUANTUM_PATH)/api | 23 | COMMON_VPATH += $(QUANTUM_PATH)/api |
24 | COMMON_VPATH += $(QUANTUM_PATH)/split_common | ||
24 | COMMON_VPATH += $(DRIVER_PATH) | 25 | COMMON_VPATH += $(DRIVER_PATH) |
diff --git a/common_features.mk b/common_features.mk index b12b6ae51..b78f04d2a 100644 --- a/common_features.mk +++ b/common_features.mk | |||
@@ -210,5 +210,17 @@ QUANTUM_SRC:= \ | |||
210 | $(QUANTUM_DIR)/process_keycode/process_leader.c | 210 | $(QUANTUM_DIR)/process_keycode/process_leader.c |
211 | 211 | ||
212 | ifndef CUSTOM_MATRIX | 212 | ifndef CUSTOM_MATRIX |
213 | QUANTUM_SRC += $(QUANTUM_DIR)/matrix.c | 213 | ifeq ($(strip $(SPLIT_KEYBOARD)), yes) |
214 | QUANTUM_SRC += $(QUANTUM_DIR)/split_common/matrix.c | ||
215 | else | ||
216 | QUANTUM_SRC += $(QUANTUM_DIR)/matrix.c | ||
217 | endif | ||
218 | endif | ||
219 | |||
220 | ifeq ($(strip $(SPLIT_KEYBOARD)), yes) | ||
221 | OPT_DEFS += -DSPLIT_KEYBOARD | ||
222 | QUANTUM_SRC += $(QUANTUM_DIR)/split_common/split_flags.c \ | ||
223 | $(QUANTUM_DIR)/split_common/split_util.c \ | ||
224 | $(QUANTUM_DIR)/split_common/i2c.c \ | ||
225 | $(QUANTUM_DIR)/split_common/serial.c | ||
214 | endif | 226 | endif |
diff --git a/docs/config_options.md b/docs/config_options.md index 94233cadc..d728a49c3 100644 --- a/docs/config_options.md +++ b/docs/config_options.md | |||
@@ -179,6 +179,16 @@ If you define these options you will enable the associated feature, which may in | |||
179 | * `#define MOUSEKEY_MAX_SPEED 7` | 179 | * `#define MOUSEKEY_MAX_SPEED 7` |
180 | * `#define MOUSEKEY_WHEEL_DELAY 0` | 180 | * `#define MOUSEKEY_WHEEL_DELAY 0` |
181 | 181 | ||
182 | ## Split Keyboard Options | ||
183 | |||
184 | Split Keyboard specific options, make sure you have 'SPLIT_KEYBOARD = yes' in your rules.mk | ||
185 | |||
186 | * `#define SPLIT_HAND_PIN B7` | ||
187 | * For using high/low pin to determine handedness, low = right hand, high = left hand. Replace 'B7' with the pin you are using. This is optional and you can still use the EEHANDS method or MASTER_LEFT / MASTER_RIGHT defines like the stock Let's Split uses. | ||
188 | |||
189 | * `#define USE_I2C` | ||
190 | * For using I2C instead of Serial (defaults to serial) | ||
191 | |||
182 | # The `rules.mk` File | 192 | # The `rules.mk` File |
183 | 193 | ||
184 | This is a [make](https://www.gnu.org/software/make/manual/make.html) file that is included by the top-level `Makefile`. It is used to set some information about the MCU that we will be compiling for as well as enabling and disabling certain features. | 194 | This is a [make](https://www.gnu.org/software/make/manual/make.html) file that is included by the top-level `Makefile`. It is used to set some information about the MCU that we will be compiling for as well as enabling and disabling certain features. |
@@ -232,3 +242,5 @@ Use these to enable or disable building certain features. The more you have enab | |||
232 | * Unicode | 242 | * Unicode |
233 | * `BLUETOOTH_ENABLE` | 243 | * `BLUETOOTH_ENABLE` |
234 | * Enable Bluetooth with the Adafruit EZ-Key HID | 244 | * Enable Bluetooth with the Adafruit EZ-Key HID |
245 | * `SPLIT_KEYBOARD` | ||
246 | * Enables split keyboard support (dual MCU like the let's split and bakingpy's boards) and includes all necessary files located at quantum/split_common | ||
diff --git a/docs/getting_started_make_guide.md b/docs/getting_started_make_guide.md index a57edcb98..e51541190 100644 --- a/docs/getting_started_make_guide.md +++ b/docs/getting_started_make_guide.md | |||
@@ -133,6 +133,10 @@ This consumes about 5390 bytes. | |||
133 | 133 | ||
134 | This enables [key lock](feature_key_lock.md). This consumes an additional 260 bytes. | 134 | This enables [key lock](feature_key_lock.md). This consumes an additional 260 bytes. |
135 | 135 | ||
136 | `SPLIT_KEYBOARD` | ||
137 | |||
138 | This enables split keyboard support (dual MCU like the let's split and bakingpy's boards) and includes all necessary files located at quantum/split_common | ||
139 | |||
136 | ## Customizing Makefile Options on a Per-Keymap Basis | 140 | ## Customizing Makefile Options on a Per-Keymap Basis |
137 | 141 | ||
138 | If your keymap directory has a file called `rules.mk` any options you set in that file will take precedence over other `rules.mk` options for your particular keyboard. | 142 | If your keymap directory has a file called `rules.mk` any options you set in that file will take precedence over other `rules.mk` options for your particular keyboard. |
diff --git a/keyboards/lets_split/keymaps/that_canadian/config.h b/keyboards/lets_split/keymaps/that_canadian/config.h new file mode 100644 index 000000000..586b6e8c8 --- /dev/null +++ b/keyboards/lets_split/keymaps/that_canadian/config.h | |||
@@ -0,0 +1,32 @@ | |||
1 | /* | ||
2 | This is the c configuration file for the keymap | ||
3 | |||
4 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
5 | Copyright 2015 Jack Humbert | ||
6 | |||
7 | This program is free software: you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation, either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | ||
20 | |||
21 | #ifndef CONFIG_USER_H | ||
22 | #define CONFIG_USER_H | ||
23 | |||
24 | #include "../../config.h" | ||
25 | |||
26 | /* Select hand configuration */ | ||
27 | |||
28 | #define MASTER_LEFT | ||
29 | // #define _MASTER_RIGHT | ||
30 | // #define EE_HANDS | ||
31 | |||
32 | #endif \ No newline at end of file | ||
diff --git a/keyboards/lets_split/keymaps/that_canadian/keymap.c b/keyboards/lets_split/keymaps/that_canadian/keymap.c new file mode 100644 index 000000000..239a8d3be --- /dev/null +++ b/keyboards/lets_split/keymaps/that_canadian/keymap.c | |||
@@ -0,0 +1,163 @@ | |||
1 | #include QMK_KEYBOARD_H | ||
2 | #include "action_layer.h" | ||
3 | #include "eeconfig.h" | ||
4 | |||
5 | extern keymap_config_t keymap_config; | ||
6 | |||
7 | // Each layer gets a name for readability, which is then used in the keymap matrix below. | ||
8 | // The underscores don't mean anything - you can have a layer called STUFF or any other name. | ||
9 | // Layer names don't all need to be of the same length, obviously, and you can also skip them | ||
10 | // entirely and just use numbers. | ||
11 | #define _QWERTY 0 | ||
12 | |||
13 | #define _LOWER 3 | ||
14 | #define _RAISE 4 | ||
15 | #define _ADJUST 16 | ||
16 | |||
17 | enum custom_keycodes { | ||
18 | QWERTY = SAFE_RANGE, | ||
19 | LOWER, | ||
20 | RAISE, | ||
21 | ADJUST, | ||
22 | BACKLIT | ||
23 | }; | ||
24 | |||
25 | // Fillers to make layering more clear | ||
26 | #define _______ KC_TRNS | ||
27 | #define XXXXXXX KC_NO | ||
28 | |||
29 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
30 | |||
31 | /* Qwerty | ||
32 | * ,-----------------------------------------------------------------------------------. | ||
33 | * | RESET| Q | W | E | R | T | Y | U | I | O | P | Bksp | | ||
34 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
35 | * | Esc | A | S | D | F | G | H | J | K | L | ; | " | | ||
36 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
37 | * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter | | ||
38 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
39 | * |Backlt| Ctrl | GUI | Alt |Lower |Space |Space |Raise | Left | Down | Up |Right | | ||
40 | * `-----------------------------------------------------------------------------------' | ||
41 | */ | ||
42 | [_QWERTY] = LAYOUT( \ | ||
43 | RESET, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \ | ||
44 | KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \ | ||
45 | RGB_TOG, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \ | ||
46 | BACKLIT, KC_LCTL, KC_LGUI, KC_LALT, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
47 | ), | ||
48 | |||
49 | /* Lower | ||
50 | * ,-----------------------------------------------------------------------------------. | ||
51 | * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp | | ||
52 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
53 | * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | | \ | | | | ||
54 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
55 | * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter | | ||
56 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
57 | * | | | | | | | | Next | Vol- | Vol+ | Play | | ||
58 | * `-----------------------------------------------------------------------------------' | ||
59 | */ | ||
60 | [_LOWER] = LAYOUT( \ | ||
61 | KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \ | ||
62 | KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \ | ||
63 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______, \ | ||
64 | _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
65 | ), | ||
66 | |||
67 | /* Raise | ||
68 | * ,-----------------------------------------------------------------------------------. | ||
69 | * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | | ||
70 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
71 | * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ | | ||
72 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
73 | * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Enter | | ||
74 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
75 | * | | | | | | | | Next | Vol- | Vol+ | Play | | ||
76 | * `-----------------------------------------------------------------------------------' | ||
77 | */ | ||
78 | [_RAISE] = LAYOUT( \ | ||
79 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \ | ||
80 | KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \ | ||
81 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______, \ | ||
82 | _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
83 | ), | ||
84 | |||
85 | /* Adjust (Lower + Raise) | ||
86 | * ,-----------------------------------------------------------------------------------. | ||
87 | * | | Reset| | | | | | | | | | Del | | ||
88 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
89 | * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak| | | | ||
90 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
91 | * | | | | | | | | | | | | | | ||
92 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
93 | * | | | | | | | | | | | | | ||
94 | * `-----------------------------------------------------------------------------------' | ||
95 | */ | ||
96 | [_ADJUST] = LAYOUT( \ | ||
97 | _______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \ | ||
98 | _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, _______, _______, _______, _______, _______, \ | ||
99 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
100 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \ | ||
101 | ) | ||
102 | |||
103 | |||
104 | }; | ||
105 | |||
106 | void persistent_default_layer_set(uint16_t default_layer) { | ||
107 | eeconfig_update_default_layer(default_layer); | ||
108 | default_layer_set(default_layer); | ||
109 | } | ||
110 | |||
111 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
112 | switch (keycode) { | ||
113 | case QWERTY: | ||
114 | if (record->event.pressed) { | ||
115 | #ifdef AUDIO_ENABLE | ||
116 | PLAY_SONG(tone_qwerty); | ||
117 | #endif | ||
118 | persistent_default_layer_set(1UL<<_QWERTY); | ||
119 | } | ||
120 | return false; | ||
121 | break; | ||
122 | case BACKLIT: | ||
123 | if (record->event.pressed) { | ||
124 | register_code(KC_RSFT); | ||
125 | #ifdef BACKLIGHT_ENABLE | ||
126 | backlight_step(); | ||
127 | #endif | ||
128 | } else { | ||
129 | unregister_code(KC_RSFT); | ||
130 | } | ||
131 | return false; | ||
132 | break; | ||
133 | case LOWER: | ||
134 | if (record->event.pressed) { | ||
135 | layer_on(_LOWER); | ||
136 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
137 | } else { | ||
138 | layer_off(_LOWER); | ||
139 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
140 | } | ||
141 | return false; | ||
142 | break; | ||
143 | case RAISE: | ||
144 | if (record->event.pressed) { | ||
145 | layer_on(_RAISE); | ||
146 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
147 | } else { | ||
148 | layer_off(_RAISE); | ||
149 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
150 | } | ||
151 | return false; | ||
152 | break; | ||
153 | case ADJUST: | ||
154 | if (record->event.pressed) { | ||
155 | layer_on(_ADJUST); | ||
156 | } else { | ||
157 | layer_off(_ADJUST); | ||
158 | } | ||
159 | return false; | ||
160 | break; | ||
161 | } | ||
162 | return true; | ||
163 | } \ No newline at end of file | ||
diff --git a/keyboards/lets_split_eh/README.md b/keyboards/lets_split_eh/README.md new file mode 100644 index 000000000..185e74dab --- /dev/null +++ b/keyboards/lets_split_eh/README.md | |||
@@ -0,0 +1,13 @@ | |||
1 | # Let's Split Eh? | ||
2 | |||
3 |  | ||
4 | |||
5 | This is a split 40% ortho board. It is the exact same footprint and the Let's Split keyboard by wootpatoot. This board has USB-C / RGB Underglow / and is all on-board. Meant as a drop-in replacement for the V2 Let's Split. | ||
6 | |||
7 | Keyboard Maintainer: [Christopher Poole (That-Canadian)](https://github.com/That-Canadian) | ||
8 | |||
9 | Make example for this keyboard (after setting up your build environment): | ||
10 | |||
11 | make lets_split_eh/eh:default | ||
12 | |||
13 | See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information. \ No newline at end of file | ||
diff --git a/keyboards/lets_split_eh/config.h b/keyboards/lets_split_eh/config.h new file mode 100644 index 000000000..b8fe95ea2 --- /dev/null +++ b/keyboards/lets_split_eh/config.h | |||
@@ -0,0 +1,44 @@ | |||
1 | /* | ||
2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation, either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #ifndef CONFIG_H | ||
19 | #define CONFIG_H | ||
20 | |||
21 | #include "config_common.h" | ||
22 | |||
23 | /* USB Device descriptor parameter */ | ||
24 | #define VENDOR_ID 0xFEED | ||
25 | #define PRODUCT_ID 0xE401 | ||
26 | #define DEVICE_VER 0x0E41 | ||
27 | #define MANUFACTURER That-Canadian | ||
28 | #define PRODUCT Lets Split Eh? | ||
29 | #define DESCRIPTION An on-board component Lets Split w/ USB-C | ||
30 | |||
31 | /* key matrix size */ | ||
32 | // Rows are doubled-up | ||
33 | #define MATRIX_ROWS 8 | ||
34 | #define MATRIX_COLS 6 | ||
35 | |||
36 | /* Set 0 if debouncing isn't needed */ | ||
37 | #define DEBOUNCING_DELAY 5 | ||
38 | |||
39 | /* key combination for command */ | ||
40 | #define IS_COMMAND() ( \ | ||
41 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
42 | ) | ||
43 | |||
44 | #endif | ||
diff --git a/keyboards/lets_split_eh/eh/config.h b/keyboards/lets_split_eh/eh/config.h new file mode 100644 index 000000000..5651ddd8b --- /dev/null +++ b/keyboards/lets_split_eh/eh/config.h | |||
@@ -0,0 +1,47 @@ | |||
1 | /* | ||
2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
3 | Copyright 2015 Jack Humbert | ||
4 | |||
5 | This program is free software: you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation, either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #ifndef EH_CONFIG_H | ||
20 | #define EH_CONFIG_H | ||
21 | |||
22 | // To let configuration know this is of type EH, which will force I2C irregardless of user config | ||
23 | #define EH | ||
24 | |||
25 | #include "config_common.h" | ||
26 | |||
27 | /* Let's Split EH? pin-out */ | ||
28 | #define MATRIX_ROW_PINS { B1, B3, D7, B4 } | ||
29 | #define MATRIX_COL_PINS { F4, F5, C6, B6, B5, D5 } | ||
30 | #define UNUSED_PINS | ||
31 | |||
32 | #define DIODE_DIRECTION COL2ROW | ||
33 | |||
34 | #define BACKLIGHT_PIN B7 | ||
35 | |||
36 | /* number of backlight levels */ | ||
37 | #define BACKLIGHT_LEVELS 3 | ||
38 | |||
39 | /* ws2812 RGB LED */ | ||
40 | #define RGB_DI_PIN B2 | ||
41 | #define RGBLED_NUM 6 // Number of LEDs (each hand) | ||
42 | |||
43 | /* Split Defines */ | ||
44 | #define SPLIT_HAND_PIN D3 | ||
45 | |||
46 | #endif | ||
47 | |||
diff --git a/keyboards/lets_split_eh/eh/eh.c b/keyboards/lets_split_eh/eh/eh.c new file mode 100644 index 000000000..e748d3ae0 --- /dev/null +++ b/keyboards/lets_split_eh/eh/eh.c | |||
@@ -0,0 +1,14 @@ | |||
1 | #include "lets_split_eh.h" | ||
2 | |||
3 | void matrix_init_kb(void) { | ||
4 | |||
5 | // JTAG disable for PORT F. write JTD bit twice within four cycles. | ||
6 | MCUCR |= (1<<JTD); | ||
7 | MCUCR |= (1<<JTD); | ||
8 | |||
9 | // Undo init of RX LED, we use that port currently | ||
10 | // DDRB &= ~(1<<0); | ||
11 | |||
12 | matrix_init_user(); | ||
13 | }; | ||
14 | |||
diff --git a/keyboards/lets_split_eh/eh/eh.h b/keyboards/lets_split_eh/eh/eh.h new file mode 100644 index 000000000..7dc84fe18 --- /dev/null +++ b/keyboards/lets_split_eh/eh/eh.h | |||
@@ -0,0 +1,27 @@ | |||
1 | #ifndef EH_H | ||
2 | #define EH_H | ||
3 | |||
4 | #include "lets_split_eh.h" | ||
5 | |||
6 | #include "quantum.h" | ||
7 | |||
8 | #define LAYOUT( \ | ||
9 | L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ | ||
10 | L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ | ||
11 | L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \ | ||
12 | L30, L31, L32, L33, L34, L35, R30, R31, R32, R33, R34, R35 \ | ||
13 | ) \ | ||
14 | { \ | ||
15 | { L00, L01, L02, L03, L04, L05 }, \ | ||
16 | { L10, L11, L12, L13, L14, L15 }, \ | ||
17 | { L20, L21, L22, L23, L24, L25 }, \ | ||
18 | { L30, L31, L32, L33, L34, L35 }, \ | ||
19 | { R00, R01, R02, R03, R04, R05 }, \ | ||
20 | { R10, R11, R12, R13, R14, R15 }, \ | ||
21 | { R20, R21, R22, R23, R24, R25 }, \ | ||
22 | { R30, R31, R32, R33, R34, R35 } \ | ||
23 | } | ||
24 | |||
25 | #define LAYOUT_ortho_4x12 LAYOUT | ||
26 | |||
27 | #endif | ||
diff --git a/keyboards/lets_split_eh/eh/rules.mk b/keyboards/lets_split_eh/eh/rules.mk new file mode 100644 index 000000000..4bac58533 --- /dev/null +++ b/keyboards/lets_split_eh/eh/rules.mk | |||
@@ -0,0 +1,4 @@ | |||
1 | BOOTLOADER = atmel-dfu | ||
2 | |||
3 | BACKLIGHT_ENABLE = yes | ||
4 | RGBLIGHT_ENABLE = yes \ No newline at end of file | ||
diff --git a/keyboards/lets_split_eh/keymaps/default/config.h b/keyboards/lets_split_eh/keymaps/default/config.h new file mode 100644 index 000000000..a1df337bd --- /dev/null +++ b/keyboards/lets_split_eh/keymaps/default/config.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* | ||
2 | This is the c configuration file for the keymap | ||
3 | |||
4 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
5 | Copyright 2015 Jack Humbert | ||
6 | |||
7 | This program is free software: you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation, either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | ||
20 | |||
21 | #ifndef CONFIG_USER_H | ||
22 | #define CONFIG_USER_H | ||
23 | |||
24 | #include "../../config.h" | ||
25 | |||
26 | #endif \ No newline at end of file | ||
diff --git a/keyboards/lets_split_eh/keymaps/default/keymap.c b/keyboards/lets_split_eh/keymaps/default/keymap.c new file mode 100644 index 000000000..8ef973574 --- /dev/null +++ b/keyboards/lets_split_eh/keymaps/default/keymap.c | |||
@@ -0,0 +1,170 @@ | |||
1 | #include QMK_KEYBOARD_H | ||
2 | #include "action_layer.h" | ||
3 | #include "eeconfig.h" | ||
4 | |||
5 | extern keymap_config_t keymap_config; | ||
6 | |||
7 | // Each layer gets a name for readability, which is then used in the keymap matrix below. | ||
8 | // The underscores don't mean anything - you can have a layer called STUFF or any other name. | ||
9 | // Layer names don't all need to be of the same length, obviously, and you can also skip them | ||
10 | // entirely and just use numbers. | ||
11 | #define _QWERTY 0 | ||
12 | |||
13 | #define _LOWER 3 | ||
14 | #define _RAISE 4 | ||
15 | #define _FUNCTION 15 | ||
16 | #define _ADJUST 16 | ||
17 | |||
18 | enum custom_keycodes { | ||
19 | QWERTY = SAFE_RANGE, | ||
20 | LOWER, | ||
21 | RAISE, | ||
22 | ADJUST | ||
23 | }; | ||
24 | |||
25 | // Fillers to make layering more clear | ||
26 | #define _______ KC_TRNS | ||
27 | #define XXXXXXX KC_NO | ||
28 | |||
29 | // Defines for task manager and such | ||
30 | #define CALTDEL LCTL(LALT(KC_DEL)) | ||
31 | #define TSKMGR LCTL(LSFT(KC_ESC)) | ||
32 | |||
33 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
34 | |||
35 | /* Qwerty | ||
36 | * ,-----------------------------------------------------------------------------------. | ||
37 | * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp | | ||
38 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
39 | * | Func | A | S | D | F | G | H | J | K | L | ; | Enter| | ||
40 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
41 | * | Shift| Z | X | C | V | B | N | M | , | . | / | ' | | ||
42 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
43 | * | Ctrl | ` | GUI | Alt |Lower | Space |Raise | Left | Down | Up |Right | | ||
44 | * `-----------------------------------------------------------------------------------' | ||
45 | */ | ||
46 | [_QWERTY] = LAYOUT( \ | ||
47 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \ | ||
48 | MO(_FUNCTION), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENT, \ | ||
49 | OSM(MOD_LSFT), KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_QUOT, \ | ||
50 | KC_LCTL, KC_GRV, KC_LGUI, KC_LALT, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
51 | ), | ||
52 | |||
53 | /* Lower | ||
54 | * ,-----------------------------------------------------------------------------------. | ||
55 | * | Esc | ! | @ | # | $ | % | ^ | & | * | ( | ) | Del | | ||
56 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
57 | * | | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } |Enter | | ||
58 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
59 | * | | F7 | F8 | F9 | F10 | F11 | F12 | | | Mute | | | | | ||
60 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
61 | * | | | | |Lower | Bksp | Bksp |Raise | Next | Vol- | Vol+ | Play | | ||
62 | * `-----------------------------------------------------------------------------------' | ||
63 | */ | ||
64 | [_LOWER] = LAYOUT( \ | ||
65 | KC_ESC, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL, \ | ||
66 | _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, _______, \ | ||
67 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, KC_MUTE, _______, KC_PIPE, \ | ||
68 | _______, _______, _______, _______, _______, KC_BSPC, KC_BSPC, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
69 | ), | ||
70 | |||
71 | /* Raise | ||
72 | * ,-----------------------------------------------------------------------------------. | ||
73 | * | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Del | | ||
74 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
75 | * | | 4 | 5 | 6 | + | F5 | F6 | - | = | [ | ] |Enter | | ||
76 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
77 | * |Enter | 7 | 8 | 9 | - | F11 | F12 |ISO # |ISO / | Mute | | \ | | ||
78 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
79 | * | | , | 0 | . |Lower | Bksp | Bksp |Raise | Next | Vol- | Vol+ | Play | | ||
80 | * `-----------------------------------------------------------------------------------' | ||
81 | */ | ||
82 | [_RAISE] = LAYOUT( \ | ||
83 | KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \ | ||
84 | _______, KC_4, KC_5, KC_6, KC_PLUS, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, _______, \ | ||
85 | KC_ENT, KC_7, KC_8, KC_9, KC_MINS, KC_F11, KC_F12, KC_NUHS, KC_NUBS, KC_MUTE, _______, KC_BSLS, \ | ||
86 | _______, KC_COMM, KC_0, KC_DOT, _______, KC_BSPC, KC_BSPC, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
87 | ), | ||
88 | |||
89 | /* Adjust (Lower + Raise) | ||
90 | * ,-----------------------------------------------------------------------------------. | ||
91 | * |Taskmg| | | | | | | |RGBVAI|RGBSAI|RGBHUI|caltde| | ||
92 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
93 | * | | | | | | | |Qwerty|RGBVAD|RGBSAD|RGBHUD|RGBTOG| | ||
94 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
95 | * | | | | | | | | | | | |BLSTEP| | ||
96 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
97 | * | | | | | | | | | | | | RESET| | ||
98 | * `-----------------------------------------------------------------------------------' | ||
99 | */ | ||
100 | [_ADJUST] = LAYOUT( \ | ||
101 | TSKMGR, _______, _______, _______, _______, _______, _______, _______, RGB_VAI, RGB_SAI, RGB_HUI, CALTDEL, \ | ||
102 | _______, _______, _______, _______, _______, _______, _______, QWERTY, RGB_VAD, RGB_SAD, RGB_HUD, RGB_TOG, \ | ||
103 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, BL_STEP, \ | ||
104 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET \ | ||
105 | ), | ||
106 | |||
107 | /* Function | ||
108 | * ,-----------------------------------------------------------------------------------. | ||
109 | * | | | | | | | | | Up | | | | | ||
110 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
111 | * | | | | | | | | Left | Down |Right | | | | ||
112 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
113 | * | Caps | | | | | | | | | | | | | ||
114 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
115 | * | | | | | | | | | | | | | ||
116 | * `-----------------------------------------------------------------------------------' | ||
117 | */ | ||
118 | [_FUNCTION] = LAYOUT( \ | ||
119 | _______, _______, _______, _______, _______, _______, _______, _______, KC_UP, _______, _______, _______, \ | ||
120 | _______, _______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, \ | ||
121 | KC_CAPS, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
122 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \ | ||
123 | ) | ||
124 | |||
125 | }; | ||
126 | |||
127 | void persistent_default_layer_set(uint16_t default_layer) { | ||
128 | eeconfig_update_default_layer(default_layer); | ||
129 | default_layer_set(default_layer); | ||
130 | } | ||
131 | |||
132 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
133 | switch (keycode) { | ||
134 | case QWERTY: | ||
135 | if (record->event.pressed) { | ||
136 | persistent_default_layer_set(1UL<<_QWERTY); | ||
137 | } | ||
138 | return false; | ||
139 | break; | ||
140 | case LOWER: | ||
141 | if (record->event.pressed) { | ||
142 | layer_on(_LOWER); | ||
143 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
144 | } else { | ||
145 | layer_off(_LOWER); | ||
146 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
147 | } | ||
148 | return false; | ||
149 | break; | ||
150 | case RAISE: | ||
151 | if (record->event.pressed) { | ||
152 | layer_on(_RAISE); | ||
153 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
154 | } else { | ||
155 | layer_off(_RAISE); | ||
156 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
157 | } | ||
158 | return false; | ||
159 | break; | ||
160 | case ADJUST: | ||
161 | if (record->event.pressed) { | ||
162 | layer_on(_ADJUST); | ||
163 | } else { | ||
164 | layer_off(_ADJUST); | ||
165 | } | ||
166 | return false; | ||
167 | break; | ||
168 | } | ||
169 | return true; | ||
170 | } \ No newline at end of file | ||
diff --git a/keyboards/lets_split_eh/keymaps/default/rules.mk b/keyboards/lets_split_eh/keymaps/default/rules.mk new file mode 100644 index 000000000..457a3d01d --- /dev/null +++ b/keyboards/lets_split_eh/keymaps/default/rules.mk | |||
@@ -0,0 +1,3 @@ | |||
1 | ifndef QUANTUM_DIR | ||
2 | include ../../../../Makefile | ||
3 | endif | ||
diff --git a/keyboards/lets_split_eh/keymaps/that_canadian/config.h b/keyboards/lets_split_eh/keymaps/that_canadian/config.h new file mode 100644 index 000000000..a1df337bd --- /dev/null +++ b/keyboards/lets_split_eh/keymaps/that_canadian/config.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* | ||
2 | This is the c configuration file for the keymap | ||
3 | |||
4 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
5 | Copyright 2015 Jack Humbert | ||
6 | |||
7 | This program is free software: you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation, either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | ||
20 | |||
21 | #ifndef CONFIG_USER_H | ||
22 | #define CONFIG_USER_H | ||
23 | |||
24 | #include "../../config.h" | ||
25 | |||
26 | #endif \ No newline at end of file | ||
diff --git a/keyboards/lets_split_eh/keymaps/that_canadian/keymap.c b/keyboards/lets_split_eh/keymaps/that_canadian/keymap.c new file mode 100644 index 000000000..8ef973574 --- /dev/null +++ b/keyboards/lets_split_eh/keymaps/that_canadian/keymap.c | |||
@@ -0,0 +1,170 @@ | |||
1 | #include QMK_KEYBOARD_H | ||
2 | #include "action_layer.h" | ||
3 | #include "eeconfig.h" | ||
4 | |||
5 | extern keymap_config_t keymap_config; | ||
6 | |||
7 | // Each layer gets a name for readability, which is then used in the keymap matrix below. | ||
8 | // The underscores don't mean anything - you can have a layer called STUFF or any other name. | ||
9 | // Layer names don't all need to be of the same length, obviously, and you can also skip them | ||
10 | // entirely and just use numbers. | ||
11 | #define _QWERTY 0 | ||
12 | |||
13 | #define _LOWER 3 | ||
14 | #define _RAISE 4 | ||
15 | #define _FUNCTION 15 | ||
16 | #define _ADJUST 16 | ||
17 | |||
18 | enum custom_keycodes { | ||
19 | QWERTY = SAFE_RANGE, | ||
20 | LOWER, | ||
21 | RAISE, | ||
22 | ADJUST | ||
23 | }; | ||
24 | |||
25 | // Fillers to make layering more clear | ||
26 | #define _______ KC_TRNS | ||
27 | #define XXXXXXX KC_NO | ||
28 | |||
29 | // Defines for task manager and such | ||
30 | #define CALTDEL LCTL(LALT(KC_DEL)) | ||
31 | #define TSKMGR LCTL(LSFT(KC_ESC)) | ||
32 | |||
33 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
34 | |||
35 | /* Qwerty | ||
36 | * ,-----------------------------------------------------------------------------------. | ||
37 | * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp | | ||
38 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
39 | * | Func | A | S | D | F | G | H | J | K | L | ; | Enter| | ||
40 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
41 | * | Shift| Z | X | C | V | B | N | M | , | . | / | ' | | ||
42 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
43 | * | Ctrl | ` | GUI | Alt |Lower | Space |Raise | Left | Down | Up |Right | | ||
44 | * `-----------------------------------------------------------------------------------' | ||
45 | */ | ||
46 | [_QWERTY] = LAYOUT( \ | ||
47 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \ | ||
48 | MO(_FUNCTION), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENT, \ | ||
49 | OSM(MOD_LSFT), KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_QUOT, \ | ||
50 | KC_LCTL, KC_GRV, KC_LGUI, KC_LALT, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
51 | ), | ||
52 | |||
53 | /* Lower | ||
54 | * ,-----------------------------------------------------------------------------------. | ||
55 | * | Esc | ! | @ | # | $ | % | ^ | & | * | ( | ) | Del | | ||
56 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
57 | * | | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } |Enter | | ||
58 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
59 | * | | F7 | F8 | F9 | F10 | F11 | F12 | | | Mute | | | | | ||
60 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
61 | * | | | | |Lower | Bksp | Bksp |Raise | Next | Vol- | Vol+ | Play | | ||
62 | * `-----------------------------------------------------------------------------------' | ||
63 | */ | ||
64 | [_LOWER] = LAYOUT( \ | ||
65 | KC_ESC, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL, \ | ||
66 | _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, _______, \ | ||
67 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, KC_MUTE, _______, KC_PIPE, \ | ||
68 | _______, _______, _______, _______, _______, KC_BSPC, KC_BSPC, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
69 | ), | ||
70 | |||
71 | /* Raise | ||
72 | * ,-----------------------------------------------------------------------------------. | ||
73 | * | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Del | | ||
74 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
75 | * | | 4 | 5 | 6 | + | F5 | F6 | - | = | [ | ] |Enter | | ||
76 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
77 | * |Enter | 7 | 8 | 9 | - | F11 | F12 |ISO # |ISO / | Mute | | \ | | ||
78 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
79 | * | | , | 0 | . |Lower | Bksp | Bksp |Raise | Next | Vol- | Vol+ | Play | | ||
80 | * `-----------------------------------------------------------------------------------' | ||
81 | */ | ||
82 | [_RAISE] = LAYOUT( \ | ||
83 | KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \ | ||
84 | _______, KC_4, KC_5, KC_6, KC_PLUS, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, _______, \ | ||
85 | KC_ENT, KC_7, KC_8, KC_9, KC_MINS, KC_F11, KC_F12, KC_NUHS, KC_NUBS, KC_MUTE, _______, KC_BSLS, \ | ||
86 | _______, KC_COMM, KC_0, KC_DOT, _______, KC_BSPC, KC_BSPC, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
87 | ), | ||
88 | |||
89 | /* Adjust (Lower + Raise) | ||
90 | * ,-----------------------------------------------------------------------------------. | ||
91 | * |Taskmg| | | | | | | |RGBVAI|RGBSAI|RGBHUI|caltde| | ||
92 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
93 | * | | | | | | | |Qwerty|RGBVAD|RGBSAD|RGBHUD|RGBTOG| | ||
94 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
95 | * | | | | | | | | | | | |BLSTEP| | ||
96 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
97 | * | | | | | | | | | | | | RESET| | ||
98 | * `-----------------------------------------------------------------------------------' | ||
99 | */ | ||
100 | [_ADJUST] = LAYOUT( \ | ||
101 | TSKMGR, _______, _______, _______, _______, _______, _______, _______, RGB_VAI, RGB_SAI, RGB_HUI, CALTDEL, \ | ||
102 | _______, _______, _______, _______, _______, _______, _______, QWERTY, RGB_VAD, RGB_SAD, RGB_HUD, RGB_TOG, \ | ||
103 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, BL_STEP, \ | ||
104 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET \ | ||
105 | ), | ||
106 | |||
107 | /* Function | ||
108 | * ,-----------------------------------------------------------------------------------. | ||
109 | * | | | | | | | | | Up | | | | | ||
110 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
111 | * | | | | | | | | Left | Down |Right | | | | ||
112 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
113 | * | Caps | | | | | | | | | | | | | ||
114 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
115 | * | | | | | | | | | | | | | ||
116 | * `-----------------------------------------------------------------------------------' | ||
117 | */ | ||
118 | [_FUNCTION] = LAYOUT( \ | ||
119 | _______, _______, _______, _______, _______, _______, _______, _______, KC_UP, _______, _______, _______, \ | ||
120 | _______, _______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, \ | ||
121 | KC_CAPS, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
122 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \ | ||
123 | ) | ||
124 | |||
125 | }; | ||
126 | |||
127 | void persistent_default_layer_set(uint16_t default_layer) { | ||
128 | eeconfig_update_default_layer(default_layer); | ||
129 | default_layer_set(default_layer); | ||
130 | } | ||
131 | |||
132 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
133 | switch (keycode) { | ||
134 | case QWERTY: | ||
135 | if (record->event.pressed) { | ||
136 | persistent_default_layer_set(1UL<<_QWERTY); | ||
137 | } | ||
138 | return false; | ||
139 | break; | ||
140 | case LOWER: | ||
141 | if (record->event.pressed) { | ||
142 | layer_on(_LOWER); | ||
143 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
144 | } else { | ||
145 | layer_off(_LOWER); | ||
146 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
147 | } | ||
148 | return false; | ||
149 | break; | ||
150 | case RAISE: | ||
151 | if (record->event.pressed) { | ||
152 | layer_on(_RAISE); | ||
153 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
154 | } else { | ||
155 | layer_off(_RAISE); | ||
156 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
157 | } | ||
158 | return false; | ||
159 | break; | ||
160 | case ADJUST: | ||
161 | if (record->event.pressed) { | ||
162 | layer_on(_ADJUST); | ||
163 | } else { | ||
164 | layer_off(_ADJUST); | ||
165 | } | ||
166 | return false; | ||
167 | break; | ||
168 | } | ||
169 | return true; | ||
170 | } \ No newline at end of file | ||
diff --git a/keyboards/lets_split_eh/keymaps/that_canadian/rules.mk b/keyboards/lets_split_eh/keymaps/that_canadian/rules.mk new file mode 100644 index 000000000..457a3d01d --- /dev/null +++ b/keyboards/lets_split_eh/keymaps/that_canadian/rules.mk | |||
@@ -0,0 +1,3 @@ | |||
1 | ifndef QUANTUM_DIR | ||
2 | include ../../../../Makefile | ||
3 | endif | ||
diff --git a/keyboards/lets_split_eh/lets_split_eh.c b/keyboards/lets_split_eh/lets_split_eh.c new file mode 100644 index 000000000..d5a312085 --- /dev/null +++ b/keyboards/lets_split_eh/lets_split_eh.c | |||
@@ -0,0 +1 @@ | |||
#include "lets_split_eh.h" | |||
diff --git a/keyboards/lets_split_eh/lets_split_eh.h b/keyboards/lets_split_eh/lets_split_eh.h new file mode 100644 index 000000000..f3d2cd0d0 --- /dev/null +++ b/keyboards/lets_split_eh/lets_split_eh.h | |||
@@ -0,0 +1,27 @@ | |||
1 | #ifndef LETS_SPLIT_EH_H | ||
2 | #define LETS_SPLIT_EH_H | ||
3 | |||
4 | #include "quantum.h" | ||
5 | |||
6 | #ifdef KEYBOARD_lets_split_eh_eh | ||
7 | #include "eh.h" | ||
8 | #endif | ||
9 | |||
10 | |||
11 | // Used to create a keymap using only KC_ prefixed keys | ||
12 | #define LAYOUT_kc( \ | ||
13 | L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ | ||
14 | L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ | ||
15 | L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \ | ||
16 | L30, L31, L32, L33, L34, L35, R30, R31, R32, R33, R34, R35 \ | ||
17 | ) \ | ||
18 | LAYOUT( \ | ||
19 | KC_##L00, KC_##L01, KC_##L02, KC_##L03, KC_##L04, KC_##L05, KC_##R00, KC_##R01, KC_##R02, KC_##R03, KC_##R04, KC_##R05, \ | ||
20 | KC_##L10, KC_##L11, KC_##L12, KC_##L13, KC_##L14, KC_##L15, KC_##R10, KC_##R11, KC_##R12, KC_##R13, KC_##R14, KC_##R15, \ | ||
21 | KC_##L20, KC_##L21, KC_##L22, KC_##L23, KC_##L24, KC_##L25, KC_##R20, KC_##R21, KC_##R22, KC_##R23, KC_##R24, KC_##R25, \ | ||
22 | KC_##L30, KC_##L31, KC_##L32, KC_##L33, KC_##L34, KC_##L35, KC_##R30, KC_##R31, KC_##R32, KC_##R33, KC_##R34, KC_##R35 \ | ||
23 | ) | ||
24 | |||
25 | #define LAYOUT_kc_ortho_4x12 LAYOUT_kc | ||
26 | |||
27 | #endif | ||
diff --git a/keyboards/lets_split_eh/rules.mk b/keyboards/lets_split_eh/rules.mk new file mode 100644 index 000000000..dffeb9fa3 --- /dev/null +++ b/keyboards/lets_split_eh/rules.mk | |||
@@ -0,0 +1,70 @@ | |||
1 | # MCU name | ||
2 | #MCU = at90usb1287 | ||
3 | MCU = atmega32u4 | ||
4 | |||
5 | # Processor frequency. | ||
6 | # This will define a symbol, F_CPU, in all source code files equal to the | ||
7 | # processor frequency in Hz. You can then use this symbol in your source code to | ||
8 | # calculate timings. Do NOT tack on a 'UL' at the end, this will be done | ||
9 | # automatically to create a 32-bit value in your source code. | ||
10 | # | ||
11 | # This will be an integer division of F_USB below, as it is sourced by | ||
12 | # F_USB after it has run through any CPU prescalers. Note that this value | ||
13 | # does not *change* the processor frequency - it should merely be updated to | ||
14 | # reflect the processor speed set externally so that the code can use accurate | ||
15 | # software delays. | ||
16 | F_CPU = 16000000 | ||
17 | |||
18 | # | ||
19 | # LUFA specific | ||
20 | # | ||
21 | # Target architecture (see library "Board Types" documentation). | ||
22 | ARCH = AVR8 | ||
23 | |||
24 | # Input clock frequency. | ||
25 | # This will define a symbol, F_USB, in all source code files equal to the | ||
26 | # input clock frequency (before any prescaling is performed) in Hz. This value may | ||
27 | # differ from F_CPU if prescaling is used on the latter, and is required as the | ||
28 | # raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
29 | # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
30 | # at the end, this will be done automatically to create a 32-bit value in your | ||
31 | # source code. | ||
32 | # | ||
33 | # If no clock division is performed on the input clock inside the AVR (via the | ||
34 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
35 | F_USB = $(F_CPU) | ||
36 | |||
37 | # Bootloader | ||
38 | # This definition is optional, and if your keyboard supports multiple bootloaders of | ||
39 | # different sizes, comment this out, and the correct address will be loaded | ||
40 | # automatically (+60). See bootloader.mk for all options. | ||
41 | BOOTLOADER = atmel-dfu | ||
42 | |||
43 | |||
44 | # Interrupt driven control endpoint task(+60) | ||
45 | OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | ||
46 | |||
47 | # Build Options | ||
48 | # change to "no" to disable the options, or define them in the Makefile in | ||
49 | # the appropriate keymap folder that will get included automatically | ||
50 | # | ||
51 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) | ||
52 | MOUSEKEY_ENABLE = no # Mouse keys(+4700) | ||
53 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | ||
54 | CONSOLE_ENABLE = no # Console for debug(+400) | ||
55 | COMMAND_ENABLE = no # Commands for debug and configuration | ||
56 | NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
57 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality | ||
58 | MIDI_ENABLE = no # MIDI controls | ||
59 | AUDIO_ENABLE = no # Audio output on port C6 | ||
60 | UNICODE_ENABLE = no # Unicode | ||
61 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
62 | RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. | ||
63 | API_SYSEX_ENABLE = no | ||
64 | |||
65 | SPLIT_KEYBOARD = yes | ||
66 | |||
67 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | ||
68 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | ||
69 | |||
70 | DEFAULT_FOLDER = lets_split_eh/eh | ||
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 9a412b66a..50af15d62 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c | |||
@@ -29,6 +29,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
29 | #include "backlight.h" | 29 | #include "backlight.h" |
30 | #include "quantum.h" | 30 | #include "quantum.h" |
31 | 31 | ||
32 | #ifdef SPLIT_KEYBOARD | ||
33 | #include "split_flags.h" | ||
34 | #endif | ||
35 | |||
32 | #ifdef MIDI_ENABLE | 36 | #ifdef MIDI_ENABLE |
33 | #include "process_midi.h" | 37 | #include "process_midi.h" |
34 | #endif | 38 | #endif |
@@ -134,21 +138,39 @@ action_t action_for_key(uint8_t layer, keypos_t key) | |||
134 | #ifdef BACKLIGHT_ENABLE | 138 | #ifdef BACKLIGHT_ENABLE |
135 | case BL_ON: | 139 | case BL_ON: |
136 | action.code = ACTION_BACKLIGHT_ON(); | 140 | action.code = ACTION_BACKLIGHT_ON(); |
141 | #ifdef SPLIT_KEYBOARD | ||
142 | BACKLIT_DIRTY = true; | ||
143 | #endif | ||
137 | break; | 144 | break; |
138 | case BL_OFF: | 145 | case BL_OFF: |
139 | action.code = ACTION_BACKLIGHT_OFF(); | 146 | action.code = ACTION_BACKLIGHT_OFF(); |
147 | #ifdef SPLIT_KEYBOARD | ||
148 | BACKLIT_DIRTY = true; | ||
149 | #endif | ||
140 | break; | 150 | break; |
141 | case BL_DEC: | 151 | case BL_DEC: |
142 | action.code = ACTION_BACKLIGHT_DECREASE(); | 152 | action.code = ACTION_BACKLIGHT_DECREASE(); |
153 | #ifdef SPLIT_KEYBOARD | ||
154 | BACKLIT_DIRTY = true; | ||
155 | #endif | ||
143 | break; | 156 | break; |
144 | case BL_INC: | 157 | case BL_INC: |
145 | action.code = ACTION_BACKLIGHT_INCREASE(); | 158 | action.code = ACTION_BACKLIGHT_INCREASE(); |
159 | #ifdef SPLIT_KEYBOARD | ||
160 | BACKLIT_DIRTY = true; | ||
161 | #endif | ||
146 | break; | 162 | break; |
147 | case BL_TOGG: | 163 | case BL_TOGG: |
148 | action.code = ACTION_BACKLIGHT_TOGGLE(); | 164 | action.code = ACTION_BACKLIGHT_TOGGLE(); |
165 | #ifdef SPLIT_KEYBOARD | ||
166 | BACKLIT_DIRTY = true; | ||
167 | #endif | ||
149 | break; | 168 | break; |
150 | case BL_STEP: | 169 | case BL_STEP: |
151 | action.code = ACTION_BACKLIGHT_STEP(); | 170 | action.code = ACTION_BACKLIGHT_STEP(); |
171 | #ifdef SPLIT_KEYBOARD | ||
172 | BACKLIT_DIRTY = true; | ||
173 | #endif | ||
152 | break; | 174 | break; |
153 | #endif | 175 | #endif |
154 | #ifdef SWAP_HANDS_ENABLE | 176 | #ifdef SWAP_HANDS_ENABLE |
diff --git a/quantum/quantum.c b/quantum/quantum.c index 2bd2c71af..9c6ed3330 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
@@ -312,8 +312,16 @@ bool process_record_quantum(keyrecord_t *record) { | |||
312 | #endif | 312 | #endif |
313 | #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) | 313 | #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) |
314 | case RGB_TOG: | 314 | case RGB_TOG: |
315 | // Split keyboards need to trigger on key-up for edge-case issue | ||
316 | #ifndef SPLIT_KEYBOARD | ||
315 | if (record->event.pressed) { | 317 | if (record->event.pressed) { |
318 | #else | ||
319 | if (!record->event.pressed) { | ||
320 | #endif | ||
316 | rgblight_toggle(); | 321 | rgblight_toggle(); |
322 | #ifdef SPLIT_KEYBOARD | ||
323 | RGB_DIRTY = true; | ||
324 | #endif | ||
317 | } | 325 | } |
318 | return false; | 326 | return false; |
319 | case RGB_MODE_FORWARD: | 327 | case RGB_MODE_FORWARD: |
@@ -325,6 +333,9 @@ bool process_record_quantum(keyrecord_t *record) { | |||
325 | else { | 333 | else { |
326 | rgblight_step(); | 334 | rgblight_step(); |
327 | } | 335 | } |
336 | #ifdef SPLIT_KEYBOARD | ||
337 | RGB_DIRTY = true; | ||
338 | #endif | ||
328 | } | 339 | } |
329 | return false; | 340 | return false; |
330 | case RGB_MODE_REVERSE: | 341 | case RGB_MODE_REVERSE: |
@@ -336,36 +347,87 @@ bool process_record_quantum(keyrecord_t *record) { | |||
336 | else { | 347 | else { |
337 | rgblight_step_reverse(); | 348 | rgblight_step_reverse(); |
338 | } | 349 | } |
350 | #ifdef SPLIT_KEYBOARD | ||
351 | RGB_DIRTY = true; | ||
352 | #endif | ||
339 | } | 353 | } |
340 | return false; | 354 | return false; |
341 | case RGB_HUI: | 355 | case RGB_HUI: |
356 | // Split keyboards need to trigger on key-up for edge-case issue | ||
357 | #ifndef SPLIT_KEYBOARD | ||
342 | if (record->event.pressed) { | 358 | if (record->event.pressed) { |
359 | #else | ||
360 | if (!record->event.pressed) { | ||
361 | #endif | ||
343 | rgblight_increase_hue(); | 362 | rgblight_increase_hue(); |
363 | #ifdef SPLIT_KEYBOARD | ||
364 | RGB_DIRTY = true; | ||
365 | #endif | ||
344 | } | 366 | } |
345 | return false; | 367 | return false; |
346 | case RGB_HUD: | 368 | case RGB_HUD: |
369 | // Split keyboards need to trigger on key-up for edge-case issue | ||
370 | #ifndef SPLIT_KEYBOARD | ||
347 | if (record->event.pressed) { | 371 | if (record->event.pressed) { |
372 | #else | ||
373 | if (!record->event.pressed) { | ||
374 | #endif | ||
348 | rgblight_decrease_hue(); | 375 | rgblight_decrease_hue(); |
376 | #ifdef SPLIT_KEYBOARD | ||
377 | RGB_DIRTY = true; | ||
378 | #endif | ||
349 | } | 379 | } |
350 | return false; | 380 | return false; |
351 | case RGB_SAI: | 381 | case RGB_SAI: |
382 | // Split keyboards need to trigger on key-up for edge-case issue | ||
383 | #ifndef SPLIT_KEYBOARD | ||
352 | if (record->event.pressed) { | 384 | if (record->event.pressed) { |
385 | #else | ||
386 | if (!record->event.pressed) { | ||
387 | #endif | ||
353 | rgblight_increase_sat(); | 388 | rgblight_increase_sat(); |
389 | #ifdef SPLIT_KEYBOARD | ||
390 | RGB_DIRTY = true; | ||
391 | #endif | ||
354 | } | 392 | } |
355 | return false; | 393 | return false; |
356 | case RGB_SAD: | 394 | case RGB_SAD: |
395 | // Split keyboards need to trigger on key-up for edge-case issue | ||
396 | #ifndef SPLIT_KEYBOARD | ||
357 | if (record->event.pressed) { | 397 | if (record->event.pressed) { |
398 | #else | ||
399 | if (!record->event.pressed) { | ||
400 | #endif | ||
358 | rgblight_decrease_sat(); | 401 | rgblight_decrease_sat(); |
402 | #ifdef SPLIT_KEYBOARD | ||
403 | RGB_DIRTY = true; | ||
404 | #endif | ||
359 | } | 405 | } |
360 | return false; | 406 | return false; |
361 | case RGB_VAI: | 407 | case RGB_VAI: |
408 | // Split keyboards need to trigger on key-up for edge-case issue | ||
409 | #ifndef SPLIT_KEYBOARD | ||
362 | if (record->event.pressed) { | 410 | if (record->event.pressed) { |
411 | #else | ||
412 | if (!record->event.pressed) { | ||
413 | #endif | ||
363 | rgblight_increase_val(); | 414 | rgblight_increase_val(); |
415 | #ifdef SPLIT_KEYBOARD | ||
416 | RGB_DIRTY = true; | ||
417 | #endif | ||
364 | } | 418 | } |
365 | return false; | 419 | return false; |
366 | case RGB_VAD: | 420 | case RGB_VAD: |
421 | // Split keyboards need to trigger on key-up for edge-case issue | ||
422 | #ifndef SPLIT_KEYBOARD | ||
367 | if (record->event.pressed) { | 423 | if (record->event.pressed) { |
424 | #else | ||
425 | if (!record->event.pressed) { | ||
426 | #endif | ||
368 | rgblight_decrease_val(); | 427 | rgblight_decrease_val(); |
428 | #ifdef SPLIT_KEYBOARD | ||
429 | RGB_DIRTY = true; | ||
430 | #endif | ||
369 | } | 431 | } |
370 | return false; | 432 | return false; |
371 | case RGB_SPI: | 433 | case RGB_SPI: |
@@ -381,6 +443,9 @@ bool process_record_quantum(keyrecord_t *record) { | |||
381 | case RGB_MODE_PLAIN: | 443 | case RGB_MODE_PLAIN: |
382 | if (record->event.pressed) { | 444 | if (record->event.pressed) { |
383 | rgblight_mode(1); | 445 | rgblight_mode(1); |
446 | #ifdef SPLIT_KEYBOARD | ||
447 | RGB_DIRTY = true; | ||
448 | #endif | ||
384 | } | 449 | } |
385 | return false; | 450 | return false; |
386 | case RGB_MODE_BREATHE: | 451 | case RGB_MODE_BREATHE: |
diff --git a/quantum/quantum.h b/quantum/quantum.h index 223846412..0675a90ac 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
@@ -33,9 +33,15 @@ | |||
33 | #ifdef RGBLIGHT_ENABLE | 33 | #ifdef RGBLIGHT_ENABLE |
34 | #include "rgblight.h" | 34 | #include "rgblight.h" |
35 | #endif | 35 | #endif |
36 | |||
37 | #ifdef SPLIT_KEYBOARD | ||
38 | #include "split_flags.h" | ||
39 | #endif | ||
40 | |||
36 | #ifdef RGB_MATRIX_ENABLE | 41 | #ifdef RGB_MATRIX_ENABLE |
37 | #include "rgb_matrix.h" | 42 | #include "rgb_matrix.h" |
38 | #endif | 43 | #endif |
44 | |||
39 | #include "action_layer.h" | 45 | #include "action_layer.h" |
40 | #include "eeconfig.h" | 46 | #include "eeconfig.h" |
41 | #include <stddef.h> | 47 | #include <stddef.h> |
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 2490a1d9f..aa70cbd9e 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
@@ -127,7 +127,7 @@ void eeconfig_update_rgblight(uint32_t val) { | |||
127 | #endif | 127 | #endif |
128 | } | 128 | } |
129 | void eeconfig_update_rgblight_default(void) { | 129 | void eeconfig_update_rgblight_default(void) { |
130 | dprintf("eeconfig_update_rgblight_default\n"); | 130 | //dprintf("eeconfig_update_rgblight_default\n"); |
131 | rgblight_config.enable = 1; | 131 | rgblight_config.enable = 1; |
132 | rgblight_config.mode = 1; | 132 | rgblight_config.mode = 1; |
133 | rgblight_config.hue = 0; | 133 | rgblight_config.hue = 0; |
diff --git a/quantum/rgblight.h b/quantum/rgblight.h index e9c192a4e..0f7b5ffb5 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h | |||
@@ -76,6 +76,10 @@ | |||
76 | #include "rgblight_types.h" | 76 | #include "rgblight_types.h" |
77 | #include "rgblight_list.h" | 77 | #include "rgblight_list.h" |
78 | 78 | ||
79 | #if defined(__AVR__) | ||
80 | #include <avr/pgmspace.h> | ||
81 | #endif | ||
82 | |||
79 | extern LED_TYPE led[RGBLED_NUM]; | 83 | extern LED_TYPE led[RGBLED_NUM]; |
80 | 84 | ||
81 | extern const uint8_t RGBLED_BREATHING_INTERVALS[4] PROGMEM; | 85 | extern const uint8_t RGBLED_BREATHING_INTERVALS[4] PROGMEM; |
diff --git a/quantum/split_common/eeprom-lefthand.eep b/quantum/split_common/eeprom-lefthand.eep new file mode 100644 index 000000000..bda23cdb6 --- /dev/null +++ b/quantum/split_common/eeprom-lefthand.eep | |||
@@ -0,0 +1,2 @@ | |||
1 | :0F000000000000000000000000000000000001F0 | ||
2 | :00000001FF | ||
diff --git a/quantum/split_common/eeprom-righthand.eep b/quantum/split_common/eeprom-righthand.eep new file mode 100644 index 000000000..549cd1ef0 --- /dev/null +++ b/quantum/split_common/eeprom-righthand.eep | |||
@@ -0,0 +1,2 @@ | |||
1 | :0F000000000000000000000000000000000000F1 | ||
2 | :00000001FF | ||
diff --git a/quantum/split_common/i2c.c b/quantum/split_common/i2c.c new file mode 100644 index 000000000..b3d7fcc68 --- /dev/null +++ b/quantum/split_common/i2c.c | |||
@@ -0,0 +1,187 @@ | |||
1 | #include <util/twi.h> | ||
2 | #include <avr/io.h> | ||
3 | #include <stdlib.h> | ||
4 | #include <avr/interrupt.h> | ||
5 | #include <util/twi.h> | ||
6 | #include <stdbool.h> | ||
7 | #include "i2c.h" | ||
8 | #include "split_flags.h" | ||
9 | |||
10 | #if defined(USE_I2C) || defined(EH) | ||
11 | |||
12 | // Limits the amount of we wait for any one i2c transaction. | ||
13 | // Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is | ||
14 | // 9 bits, a single transaction will take around 90μs to complete. | ||
15 | // | ||
16 | // (F_CPU/SCL_CLOCK) => # of μC cycles to transfer a bit | ||
17 | // poll loop takes at least 8 clock cycles to execute | ||
18 | #define I2C_LOOP_TIMEOUT (9+1)*(F_CPU/SCL_CLOCK)/8 | ||
19 | |||
20 | #define BUFFER_POS_INC() (slave_buffer_pos = (slave_buffer_pos+1)%SLAVE_BUFFER_SIZE) | ||
21 | |||
22 | volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE]; | ||
23 | |||
24 | static volatile uint8_t slave_buffer_pos; | ||
25 | static volatile bool slave_has_register_set = false; | ||
26 | |||
27 | // Wait for an i2c operation to finish | ||
28 | inline static | ||
29 | void i2c_delay(void) { | ||
30 | uint16_t lim = 0; | ||
31 | while(!(TWCR & (1<<TWINT)) && lim < I2C_LOOP_TIMEOUT) | ||
32 | lim++; | ||
33 | |||
34 | // easier way, but will wait slightly longer | ||
35 | // _delay_us(100); | ||
36 | } | ||
37 | |||
38 | // Setup twi to run at 100kHz | ||
39 | void i2c_master_init(void) { | ||
40 | // no prescaler | ||
41 | TWSR = 0; | ||
42 | // Set TWI clock frequency to SCL_CLOCK. Need TWBR>10. | ||
43 | // Check datasheets for more info. | ||
44 | TWBR = ((F_CPU/SCL_CLOCK)-16)/2; | ||
45 | } | ||
46 | |||
47 | // Start a transaction with the given i2c slave address. The direction of the | ||
48 | // transfer is set with I2C_READ and I2C_WRITE. | ||
49 | // returns: 0 => success | ||
50 | // 1 => error | ||
51 | uint8_t i2c_master_start(uint8_t address) { | ||
52 | TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTA); | ||
53 | |||
54 | i2c_delay(); | ||
55 | |||
56 | // check that we started successfully | ||
57 | if ( (TW_STATUS != TW_START) && (TW_STATUS != TW_REP_START)) | ||
58 | return 1; | ||
59 | |||
60 | TWDR = address; | ||
61 | TWCR = (1<<TWINT) | (1<<TWEN); | ||
62 | |||
63 | i2c_delay(); | ||
64 | |||
65 | if ( (TW_STATUS != TW_MT_SLA_ACK) && (TW_STATUS != TW_MR_SLA_ACK) ) | ||
66 | return 1; // slave did not acknowledge | ||
67 | else | ||
68 | return 0; // success | ||
69 | } | ||
70 | |||
71 | |||
72 | // Finish the i2c transaction. | ||
73 | void i2c_master_stop(void) { | ||
74 | TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO); | ||
75 | |||
76 | uint16_t lim = 0; | ||
77 | while(!(TWCR & (1<<TWSTO)) && lim < I2C_LOOP_TIMEOUT) | ||
78 | lim++; | ||
79 | } | ||
80 | |||
81 | // Write one byte to the i2c slave. | ||
82 | // returns 0 => slave ACK | ||
83 | // 1 => slave NACK | ||
84 | uint8_t i2c_master_write(uint8_t data) { | ||
85 | TWDR = data; | ||
86 | TWCR = (1<<TWINT) | (1<<TWEN); | ||
87 | |||
88 | i2c_delay(); | ||
89 | |||
90 | // check if the slave acknowledged us | ||
91 | return (TW_STATUS == TW_MT_DATA_ACK) ? 0 : 1; | ||
92 | } | ||
93 | |||
94 | uint8_t i2c_master_write_data(void *const TXdata, uint8_t dataLen) { | ||
95 | |||
96 | uint8_t *data = (uint8_t *)TXdata; | ||
97 | int err = 0; | ||
98 | |||
99 | for (int i = 0; i < dataLen; i++) { | ||
100 | err = i2c_master_write(data[i]); | ||
101 | |||
102 | if ( err ) | ||
103 | return err; | ||
104 | } | ||
105 | |||
106 | return err; | ||
107 | |||
108 | } | ||
109 | |||
110 | // Read one byte from the i2c slave. If ack=1 the slave is acknowledged, | ||
111 | // if ack=0 the acknowledge bit is not set. | ||
112 | // returns: byte read from i2c device | ||
113 | uint8_t i2c_master_read(int ack) { | ||
114 | TWCR = (1<<TWINT) | (1<<TWEN) | (ack<<TWEA); | ||
115 | |||
116 | i2c_delay(); | ||
117 | return TWDR; | ||
118 | } | ||
119 | |||
120 | void i2c_reset_state(void) { | ||
121 | TWCR = 0; | ||
122 | } | ||
123 | |||
124 | void i2c_slave_init(uint8_t address) { | ||
125 | TWAR = address << 0; // slave i2c address | ||
126 | // TWEN - twi enable | ||
127 | // TWEA - enable address acknowledgement | ||
128 | // TWINT - twi interrupt flag | ||
129 | // TWIE - enable the twi interrupt | ||
130 | TWCR = (1<<TWIE) | (1<<TWEA) | (1<<TWINT) | (1<<TWEN); | ||
131 | } | ||
132 | |||
133 | ISR(TWI_vect); | ||
134 | |||
135 | ISR(TWI_vect) { | ||
136 | uint8_t ack = 1; | ||
137 | switch(TW_STATUS) { | ||
138 | case TW_SR_SLA_ACK: | ||
139 | // this device has been addressed as a slave receiver | ||
140 | slave_has_register_set = false; | ||
141 | break; | ||
142 | |||
143 | case TW_SR_DATA_ACK: | ||
144 | // this device has received data as a slave receiver | ||
145 | // The first byte that we receive in this transaction sets the location | ||
146 | // of the read/write location of the slaves memory that it exposes over | ||
147 | // i2c. After that, bytes will be written at slave_buffer_pos, incrementing | ||
148 | // slave_buffer_pos after each write. | ||
149 | if(!slave_has_register_set) { | ||
150 | slave_buffer_pos = TWDR; | ||
151 | // don't acknowledge the master if this memory loctaion is out of bounds | ||
152 | if ( slave_buffer_pos >= SLAVE_BUFFER_SIZE ) { | ||
153 | ack = 0; | ||
154 | slave_buffer_pos = 0; | ||
155 | } | ||
156 | |||
157 | slave_has_register_set = true; | ||
158 | } else { | ||
159 | i2c_slave_buffer[slave_buffer_pos] = TWDR; | ||
160 | |||
161 | if ( slave_buffer_pos == I2C_BACKLIT_START) { | ||
162 | BACKLIT_DIRTY = true; | ||
163 | } else if ( slave_buffer_pos == (I2C_RGB_START+3)) { | ||
164 | RGB_DIRTY = true; | ||
165 | } | ||
166 | |||
167 | BUFFER_POS_INC(); | ||
168 | } | ||
169 | break; | ||
170 | |||
171 | case TW_ST_SLA_ACK: | ||
172 | case TW_ST_DATA_ACK: | ||
173 | // master has addressed this device as a slave transmitter and is | ||
174 | // requesting data. | ||
175 | TWDR = i2c_slave_buffer[slave_buffer_pos]; | ||
176 | BUFFER_POS_INC(); | ||
177 | break; | ||
178 | |||
179 | case TW_BUS_ERROR: // something went wrong, reset twi state | ||
180 | TWCR = 0; | ||
181 | default: | ||
182 | break; | ||
183 | } | ||
184 | // Reset everything, so we are ready for the next TWI interrupt | ||
185 | TWCR |= (1<<TWIE) | (1<<TWINT) | (ack<<TWEA) | (1<<TWEN); | ||
186 | } | ||
187 | #endif | ||
diff --git a/quantum/split_common/i2c.h b/quantum/split_common/i2c.h new file mode 100644 index 000000000..b4c72bde0 --- /dev/null +++ b/quantum/split_common/i2c.h | |||
@@ -0,0 +1,60 @@ | |||
1 | #ifndef I2C_H | ||
2 | #define I2C_H | ||
3 | |||
4 | #include <stdint.h> | ||
5 | |||
6 | #ifndef F_CPU | ||
7 | #define F_CPU 16000000UL | ||
8 | #endif | ||
9 | |||
10 | #define I2C_READ 1 | ||
11 | #define I2C_WRITE 0 | ||
12 | |||
13 | #define I2C_ACK 1 | ||
14 | #define I2C_NACK 0 | ||
15 | |||
16 | // Address location defines (Keymap should be last, as it's size is dynamic) | ||
17 | #define I2C_BACKLIT_START 0x00 | ||
18 | // Need 4 bytes for RGB (32 bit) | ||
19 | #define I2C_RGB_START 0x01 | ||
20 | #define I2C_KEYMAP_START 0x06 | ||
21 | |||
22 | // Slave buffer (8bit per) | ||
23 | // Rows per hand + backlit space + rgb space | ||
24 | // TODO : Make this dynamically sized | ||
25 | #define SLAVE_BUFFER_SIZE 0x20 | ||
26 | |||
27 | // i2c SCL clock frequency | ||
28 | #define SCL_CLOCK 400000L | ||
29 | |||
30 | // Support 8bits right now (8 cols) will need to edit to take higher (code exists in delta split?) | ||
31 | extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE]; | ||
32 | |||
33 | void i2c_master_init(void); | ||
34 | uint8_t i2c_master_start(uint8_t address); | ||
35 | void i2c_master_stop(void); | ||
36 | uint8_t i2c_master_write(uint8_t data); | ||
37 | uint8_t i2c_master_write_data(void *const TXdata, uint8_t dataLen); | ||
38 | uint8_t i2c_master_read(int); | ||
39 | void i2c_reset_state(void); | ||
40 | void i2c_slave_init(uint8_t address); | ||
41 | |||
42 | |||
43 | static inline unsigned char i2c_start_read(unsigned char addr) { | ||
44 | return i2c_master_start((addr << 1) | I2C_READ); | ||
45 | } | ||
46 | |||
47 | static inline unsigned char i2c_start_write(unsigned char addr) { | ||
48 | return i2c_master_start((addr << 1) | I2C_WRITE); | ||
49 | } | ||
50 | |||
51 | // from SSD1306 scrips | ||
52 | extern unsigned char i2c_rep_start(unsigned char addr); | ||
53 | extern void i2c_start_wait(unsigned char addr); | ||
54 | extern unsigned char i2c_readAck(void); | ||
55 | extern unsigned char i2c_readNak(void); | ||
56 | extern unsigned char i2c_read(unsigned char ack); | ||
57 | |||
58 | #define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak(); | ||
59 | |||
60 | #endif | ||
diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c new file mode 100644 index 000000000..071f0481a --- /dev/null +++ b/quantum/split_common/matrix.c | |||
@@ -0,0 +1,510 @@ | |||
1 | /* | ||
2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation, either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | /* | ||
19 | * scan matrix | ||
20 | */ | ||
21 | #include <stdint.h> | ||
22 | #include <stdbool.h> | ||
23 | #include <avr/io.h> | ||
24 | #include "wait.h" | ||
25 | #include "print.h" | ||
26 | #include "debug.h" | ||
27 | #include "util.h" | ||
28 | #include "matrix.h" | ||
29 | #include "split_util.h" | ||
30 | #include "pro_micro.h" | ||
31 | #include "config.h" | ||
32 | #include "timer.h" | ||
33 | #include "split_flags.h" | ||
34 | |||
35 | #ifdef RGBLIGHT_ENABLE | ||
36 | # include "rgblight.h" | ||
37 | #endif | ||
38 | #ifdef BACKLIGHT_ENABLE | ||
39 | # include "backlight.h" | ||
40 | #endif | ||
41 | |||
42 | #if defined(USE_I2C) || defined(EH) | ||
43 | # include "i2c.h" | ||
44 | #else // USE_SERIAL | ||
45 | # include "serial.h" | ||
46 | #endif | ||
47 | |||
48 | #ifndef DEBOUNCING_DELAY | ||
49 | # define DEBOUNCING_DELAY 5 | ||
50 | #endif | ||
51 | |||
52 | #if (DEBOUNCING_DELAY > 0) | ||
53 | static uint16_t debouncing_time; | ||
54 | static bool debouncing = false; | ||
55 | #endif | ||
56 | |||
57 | #if (MATRIX_COLS <= 8) | ||
58 | # define print_matrix_header() print("\nr/c 01234567\n") | ||
59 | # define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) | ||
60 | # define matrix_bitpop(i) bitpop(matrix[i]) | ||
61 | # define ROW_SHIFTER ((uint8_t)1) | ||
62 | #else | ||
63 | # error "Currently only supports 8 COLS" | ||
64 | #endif | ||
65 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
66 | |||
67 | #define ERROR_DISCONNECT_COUNT 5 | ||
68 | |||
69 | #define ROWS_PER_HAND (MATRIX_ROWS/2) | ||
70 | |||
71 | static uint8_t error_count = 0; | ||
72 | |||
73 | static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; | ||
74 | static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; | ||
75 | |||
76 | /* matrix state(1:on, 0:off) */ | ||
77 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
78 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
79 | |||
80 | #if (DIODE_DIRECTION == COL2ROW) | ||
81 | static void init_cols(void); | ||
82 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row); | ||
83 | static void unselect_rows(void); | ||
84 | static void select_row(uint8_t row); | ||
85 | static void unselect_row(uint8_t row); | ||
86 | #elif (DIODE_DIRECTION == ROW2COL) | ||
87 | static void init_rows(void); | ||
88 | static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col); | ||
89 | static void unselect_cols(void); | ||
90 | static void unselect_col(uint8_t col); | ||
91 | static void select_col(uint8_t col); | ||
92 | #endif | ||
93 | |||
94 | __attribute__ ((weak)) | ||
95 | void matrix_init_kb(void) { | ||
96 | matrix_init_user(); | ||
97 | } | ||
98 | |||
99 | __attribute__ ((weak)) | ||
100 | void matrix_scan_kb(void) { | ||
101 | matrix_scan_user(); | ||
102 | } | ||
103 | |||
104 | __attribute__ ((weak)) | ||
105 | void matrix_init_user(void) { | ||
106 | } | ||
107 | |||
108 | __attribute__ ((weak)) | ||
109 | void matrix_scan_user(void) { | ||
110 | } | ||
111 | |||
112 | __attribute__ ((weak)) | ||
113 | void matrix_slave_scan_user(void) { | ||
114 | } | ||
115 | |||
116 | inline | ||
117 | uint8_t matrix_rows(void) | ||
118 | { | ||
119 | return MATRIX_ROWS; | ||
120 | } | ||
121 | |||
122 | inline | ||
123 | uint8_t matrix_cols(void) | ||
124 | { | ||
125 | return MATRIX_COLS; | ||
126 | } | ||
127 | |||
128 | void matrix_init(void) | ||
129 | { | ||
130 | #ifdef DISABLE_JTAG | ||
131 | // JTAG disable for PORT F. write JTD bit twice within four cycles. | ||
132 | MCUCR |= (1<<JTD); | ||
133 | MCUCR |= (1<<JTD); | ||
134 | #endif | ||
135 | |||
136 | debug_enable = true; | ||
137 | debug_matrix = true; | ||
138 | debug_mouse = true; | ||
139 | // initialize row and col | ||
140 | #if (DIODE_DIRECTION == COL2ROW) | ||
141 | unselect_rows(); | ||
142 | init_cols(); | ||
143 | #elif (DIODE_DIRECTION == ROW2COL) | ||
144 | unselect_cols(); | ||
145 | init_rows(); | ||
146 | #endif | ||
147 | |||
148 | // initialize matrix state: all keys off | ||
149 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
150 | matrix[i] = 0; | ||
151 | matrix_debouncing[i] = 0; | ||
152 | } | ||
153 | |||
154 | matrix_init_quantum(); | ||
155 | |||
156 | } | ||
157 | |||
158 | uint8_t _matrix_scan(void) | ||
159 | { | ||
160 | int offset = isLeftHand ? 0 : (ROWS_PER_HAND); | ||
161 | #if (DIODE_DIRECTION == COL2ROW) | ||
162 | // Set row, read cols | ||
163 | for (uint8_t current_row = 0; current_row < ROWS_PER_HAND; current_row++) { | ||
164 | # if (DEBOUNCING_DELAY > 0) | ||
165 | bool matrix_changed = read_cols_on_row(matrix_debouncing+offset, current_row); | ||
166 | |||
167 | if (matrix_changed) { | ||
168 | debouncing = true; | ||
169 | debouncing_time = timer_read(); | ||
170 | } | ||
171 | |||
172 | # else | ||
173 | read_cols_on_row(matrix+offset, current_row); | ||
174 | # endif | ||
175 | |||
176 | } | ||
177 | |||
178 | #elif (DIODE_DIRECTION == ROW2COL) | ||
179 | // Set col, read rows | ||
180 | for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { | ||
181 | # if (DEBOUNCING_DELAY > 0) | ||
182 | bool matrix_changed = read_rows_on_col(matrix_debouncing+offset, current_col); | ||
183 | if (matrix_changed) { | ||
184 | debouncing = true; | ||
185 | debouncing_time = timer_read(); | ||
186 | } | ||
187 | # else | ||
188 | read_rows_on_col(matrix+offset, current_col); | ||
189 | # endif | ||
190 | |||
191 | } | ||
192 | #endif | ||
193 | |||
194 | # if (DEBOUNCING_DELAY > 0) | ||
195 | if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCING_DELAY)) { | ||
196 | for (uint8_t i = 0; i < ROWS_PER_HAND; i++) { | ||
197 | matrix[i+offset] = matrix_debouncing[i+offset]; | ||
198 | } | ||
199 | debouncing = false; | ||
200 | } | ||
201 | # endif | ||
202 | |||
203 | return 1; | ||
204 | } | ||
205 | |||
206 | #if defined(USE_I2C) || defined(EH) | ||
207 | |||
208 | // Get rows from other half over i2c | ||
209 | int i2c_transaction(void) { | ||
210 | int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0; | ||
211 | int err = 0; | ||
212 | |||
213 | // write backlight info | ||
214 | #ifdef BACKLIGHT_ENABLE | ||
215 | if (BACKLIT_DIRTY) { | ||
216 | err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE); | ||
217 | if (err) goto i2c_error; | ||
218 | |||
219 | // Backlight location | ||
220 | err = i2c_master_write(I2C_BACKLIT_START); | ||
221 | if (err) goto i2c_error; | ||
222 | |||
223 | // Write backlight | ||
224 | i2c_master_write(get_backlight_level()); | ||
225 | |||
226 | BACKLIT_DIRTY = false; | ||
227 | } | ||
228 | #endif | ||
229 | |||
230 | err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE); | ||
231 | if (err) goto i2c_error; | ||
232 | |||
233 | // start of matrix stored at I2C_KEYMAP_START | ||
234 | err = i2c_master_write(I2C_KEYMAP_START); | ||
235 | if (err) goto i2c_error; | ||
236 | |||
237 | // Start read | ||
238 | err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_READ); | ||
239 | if (err) goto i2c_error; | ||
240 | |||
241 | if (!err) { | ||
242 | int i; | ||
243 | for (i = 0; i < ROWS_PER_HAND-1; ++i) { | ||
244 | matrix[slaveOffset+i] = i2c_master_read(I2C_ACK); | ||
245 | } | ||
246 | matrix[slaveOffset+i] = i2c_master_read(I2C_NACK); | ||
247 | i2c_master_stop(); | ||
248 | } else { | ||
249 | i2c_error: // the cable is disconnceted, or something else went wrong | ||
250 | i2c_reset_state(); | ||
251 | return err; | ||
252 | } | ||
253 | |||
254 | #ifdef RGBLIGHT_ENABLE | ||
255 | if (RGB_DIRTY) { | ||
256 | err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE); | ||
257 | if (err) goto i2c_error; | ||
258 | |||
259 | // RGB Location | ||
260 | err = i2c_master_write(I2C_RGB_START); | ||
261 | if (err) goto i2c_error; | ||
262 | |||
263 | uint32_t dword = eeconfig_read_rgblight(); | ||
264 | |||
265 | // Write RGB | ||
266 | err = i2c_master_write_data(&dword, 4); | ||
267 | if (err) goto i2c_error; | ||
268 | |||
269 | RGB_DIRTY = false; | ||
270 | i2c_master_stop(); | ||
271 | } | ||
272 | #endif | ||
273 | |||
274 | return 0; | ||
275 | } | ||
276 | |||
277 | #else // USE_SERIAL | ||
278 | |||
279 | int serial_transaction(void) { | ||
280 | int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0; | ||
281 | |||
282 | if (serial_update_buffers()) { | ||
283 | return 1; | ||
284 | } | ||
285 | |||
286 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | ||
287 | matrix[slaveOffset+i] = serial_slave_buffer[i]; | ||
288 | } | ||
289 | return 0; | ||
290 | } | ||
291 | #endif | ||
292 | |||
293 | uint8_t matrix_scan(void) | ||
294 | { | ||
295 | uint8_t ret = _matrix_scan(); | ||
296 | |||
297 | #if defined(USE_I2C) || defined(EH) | ||
298 | if( i2c_transaction() ) { | ||
299 | #else // USE_SERIAL | ||
300 | if( serial_transaction() ) { | ||
301 | #endif | ||
302 | |||
303 | error_count++; | ||
304 | |||
305 | if (error_count > ERROR_DISCONNECT_COUNT) { | ||
306 | // reset other half if disconnected | ||
307 | int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0; | ||
308 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | ||
309 | matrix[slaveOffset+i] = 0; | ||
310 | } | ||
311 | } | ||
312 | } else { | ||
313 | error_count = 0; | ||
314 | } | ||
315 | matrix_scan_quantum(); | ||
316 | return ret; | ||
317 | } | ||
318 | |||
319 | void matrix_slave_scan(void) { | ||
320 | _matrix_scan(); | ||
321 | |||
322 | int offset = (isLeftHand) ? 0 : ROWS_PER_HAND; | ||
323 | |||
324 | #if defined(USE_I2C) || defined(EH) | ||
325 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | ||
326 | i2c_slave_buffer[I2C_KEYMAP_START+i] = matrix[offset+i]; | ||
327 | } | ||
328 | #else // USE_SERIAL | ||
329 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | ||
330 | serial_slave_buffer[i] = matrix[offset+i]; | ||
331 | } | ||
332 | #endif | ||
333 | matrix_slave_scan_user(); | ||
334 | } | ||
335 | |||
336 | bool matrix_is_modified(void) | ||
337 | { | ||
338 | if (debouncing) return false; | ||
339 | return true; | ||
340 | } | ||
341 | |||
342 | inline | ||
343 | bool matrix_is_on(uint8_t row, uint8_t col) | ||
344 | { | ||
345 | return (matrix[row] & ((matrix_row_t)1<<col)); | ||
346 | } | ||
347 | |||
348 | inline | ||
349 | matrix_row_t matrix_get_row(uint8_t row) | ||
350 | { | ||
351 | return matrix[row]; | ||
352 | } | ||
353 | |||
354 | void matrix_print(void) | ||
355 | { | ||
356 | print("\nr/c 0123456789ABCDEF\n"); | ||
357 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
358 | phex(row); print(": "); | ||
359 | pbin_reverse16(matrix_get_row(row)); | ||
360 | print("\n"); | ||
361 | } | ||
362 | } | ||
363 | |||
364 | uint8_t matrix_key_count(void) | ||
365 | { | ||
366 | uint8_t count = 0; | ||
367 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
368 | count += bitpop16(matrix[i]); | ||
369 | } | ||
370 | return count; | ||
371 | } | ||
372 | |||
373 | #if (DIODE_DIRECTION == COL2ROW) | ||
374 | |||
375 | static void init_cols(void) | ||
376 | { | ||
377 | for(uint8_t x = 0; x < MATRIX_COLS; x++) { | ||
378 | uint8_t pin = col_pins[x]; | ||
379 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
380 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
381 | } | ||
382 | } | ||
383 | |||
384 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) | ||
385 | { | ||
386 | // Store last value of row prior to reading | ||
387 | matrix_row_t last_row_value = current_matrix[current_row]; | ||
388 | |||
389 | // Clear data in matrix row | ||
390 | current_matrix[current_row] = 0; | ||
391 | |||
392 | // Select row and wait for row selecton to stabilize | ||
393 | select_row(current_row); | ||
394 | wait_us(30); | ||
395 | |||
396 | // For each col... | ||
397 | for(uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) { | ||
398 | |||
399 | // Select the col pin to read (active low) | ||
400 | uint8_t pin = col_pins[col_index]; | ||
401 | uint8_t pin_state = (_SFR_IO8(pin >> 4) & _BV(pin & 0xF)); | ||
402 | |||
403 | // Populate the matrix row with the state of the col pin | ||
404 | current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index); | ||
405 | } | ||
406 | |||
407 | // Unselect row | ||
408 | unselect_row(current_row); | ||
409 | |||
410 | return (last_row_value != current_matrix[current_row]); | ||
411 | } | ||
412 | |||
413 | static void select_row(uint8_t row) | ||
414 | { | ||
415 | uint8_t pin = row_pins[row]; | ||
416 | _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); // OUT | ||
417 | _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW | ||
418 | } | ||
419 | |||
420 | static void unselect_row(uint8_t row) | ||
421 | { | ||
422 | uint8_t pin = row_pins[row]; | ||
423 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
424 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
425 | } | ||
426 | |||
427 | static void unselect_rows(void) | ||
428 | { | ||
429 | for(uint8_t x = 0; x < ROWS_PER_HAND; x++) { | ||
430 | uint8_t pin = row_pins[x]; | ||
431 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
432 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
433 | } | ||
434 | } | ||
435 | |||
436 | #elif (DIODE_DIRECTION == ROW2COL) | ||
437 | |||
438 | static void init_rows(void) | ||
439 | { | ||
440 | for(uint8_t x = 0; x < ROWS_PER_HAND; x++) { | ||
441 | uint8_t pin = row_pins[x]; | ||
442 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
443 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
444 | } | ||
445 | } | ||
446 | |||
447 | static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) | ||
448 | { | ||
449 | bool matrix_changed = false; | ||
450 | |||
451 | // Select col and wait for col selecton to stabilize | ||
452 | select_col(current_col); | ||
453 | wait_us(30); | ||
454 | |||
455 | // For each row... | ||
456 | for(uint8_t row_index = 0; row_index < ROWS_PER_HAND; row_index++) | ||
457 | { | ||
458 | |||
459 | // Store last value of row prior to reading | ||
460 | matrix_row_t last_row_value = current_matrix[row_index]; | ||
461 | |||
462 | // Check row pin state | ||
463 | if ((_SFR_IO8(row_pins[row_index] >> 4) & _BV(row_pins[row_index] & 0xF)) == 0) | ||
464 | { | ||
465 | // Pin LO, set col bit | ||
466 | current_matrix[row_index] |= (ROW_SHIFTER << current_col); | ||
467 | } | ||
468 | else | ||
469 | { | ||
470 | // Pin HI, clear col bit | ||
471 | current_matrix[row_index] &= ~(ROW_SHIFTER << current_col); | ||
472 | } | ||
473 | |||
474 | // Determine if the matrix changed state | ||
475 | if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) | ||
476 | { | ||
477 | matrix_changed = true; | ||
478 | } | ||
479 | } | ||
480 | |||
481 | // Unselect col | ||
482 | unselect_col(current_col); | ||
483 | |||
484 | return matrix_changed; | ||
485 | } | ||
486 | |||
487 | static void select_col(uint8_t col) | ||
488 | { | ||
489 | uint8_t pin = col_pins[col]; | ||
490 | _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); // OUT | ||
491 | _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW | ||
492 | } | ||
493 | |||
494 | static void unselect_col(uint8_t col) | ||
495 | { | ||
496 | uint8_t pin = col_pins[col]; | ||
497 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
498 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
499 | } | ||
500 | |||
501 | static void unselect_cols(void) | ||
502 | { | ||
503 | for(uint8_t x = 0; x < MATRIX_COLS; x++) { | ||
504 | uint8_t pin = col_pins[x]; | ||
505 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
506 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
507 | } | ||
508 | } | ||
509 | |||
510 | #endif | ||
diff --git a/quantum/split_common/serial.c b/quantum/split_common/serial.c new file mode 100644 index 000000000..74bcbb6bf --- /dev/null +++ b/quantum/split_common/serial.c | |||
@@ -0,0 +1,228 @@ | |||
1 | /* | ||
2 | * WARNING: be careful changing this code, it is very timing dependent | ||
3 | */ | ||
4 | |||
5 | #ifndef F_CPU | ||
6 | #define F_CPU 16000000 | ||
7 | #endif | ||
8 | |||
9 | #include <avr/io.h> | ||
10 | #include <avr/interrupt.h> | ||
11 | #include <util/delay.h> | ||
12 | #include <stdbool.h> | ||
13 | #include "serial.h" | ||
14 | |||
15 | #ifndef USE_I2C | ||
16 | |||
17 | // Serial pulse period in microseconds. Its probably a bad idea to lower this | ||
18 | // value. | ||
19 | #define SERIAL_DELAY 24 | ||
20 | |||
21 | uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0}; | ||
22 | uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0}; | ||
23 | |||
24 | #define SLAVE_DATA_CORRUPT (1<<0) | ||
25 | volatile uint8_t status = 0; | ||
26 | |||
27 | inline static | ||
28 | void serial_delay(void) { | ||
29 | _delay_us(SERIAL_DELAY); | ||
30 | } | ||
31 | |||
32 | inline static | ||
33 | void serial_output(void) { | ||
34 | SERIAL_PIN_DDR |= SERIAL_PIN_MASK; | ||
35 | } | ||
36 | |||
37 | // make the serial pin an input with pull-up resistor | ||
38 | inline static | ||
39 | void serial_input(void) { | ||
40 | SERIAL_PIN_DDR &= ~SERIAL_PIN_MASK; | ||
41 | SERIAL_PIN_PORT |= SERIAL_PIN_MASK; | ||
42 | } | ||
43 | |||
44 | inline static | ||
45 | uint8_t serial_read_pin(void) { | ||
46 | return !!(SERIAL_PIN_INPUT & SERIAL_PIN_MASK); | ||
47 | } | ||
48 | |||
49 | inline static | ||
50 | void serial_low(void) { | ||
51 | SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK; | ||
52 | } | ||
53 | |||
54 | inline static | ||
55 | void serial_high(void) { | ||
56 | SERIAL_PIN_PORT |= SERIAL_PIN_MASK; | ||
57 | } | ||
58 | |||
59 | void serial_master_init(void) { | ||
60 | serial_output(); | ||
61 | serial_high(); | ||
62 | } | ||
63 | |||
64 | void serial_slave_init(void) { | ||
65 | serial_input(); | ||
66 | |||
67 | // Enable INT0 | ||
68 | EIMSK |= _BV(INT0); | ||
69 | // Trigger on falling edge of INT0 | ||
70 | EICRA &= ~(_BV(ISC00) | _BV(ISC01)); | ||
71 | } | ||
72 | |||
73 | // Used by the master to synchronize timing with the slave. | ||
74 | static | ||
75 | void sync_recv(void) { | ||
76 | serial_input(); | ||
77 | // This shouldn't hang if the slave disconnects because the | ||
78 | // serial line will float to high if the slave does disconnect. | ||
79 | while (!serial_read_pin()); | ||
80 | serial_delay(); | ||
81 | } | ||
82 | |||
83 | // Used by the slave to send a synchronization signal to the master. | ||
84 | static | ||
85 | void sync_send(void) { | ||
86 | serial_output(); | ||
87 | |||
88 | serial_low(); | ||
89 | serial_delay(); | ||
90 | |||
91 | serial_high(); | ||
92 | } | ||
93 | |||
94 | // Reads a byte from the serial line | ||
95 | static | ||
96 | uint8_t serial_read_byte(void) { | ||
97 | uint8_t byte = 0; | ||
98 | serial_input(); | ||
99 | for ( uint8_t i = 0; i < 8; ++i) { | ||
100 | byte = (byte << 1) | serial_read_pin(); | ||
101 | serial_delay(); | ||
102 | _delay_us(1); | ||
103 | } | ||
104 | |||
105 | return byte; | ||
106 | } | ||
107 | |||
108 | // Sends a byte with MSB ordering | ||
109 | static | ||
110 | void serial_write_byte(uint8_t data) { | ||
111 | uint8_t b = 8; | ||
112 | serial_output(); | ||
113 | while( b-- ) { | ||
114 | if(data & (1 << b)) { | ||
115 | serial_high(); | ||
116 | } else { | ||
117 | serial_low(); | ||
118 | } | ||
119 | serial_delay(); | ||
120 | } | ||
121 | } | ||
122 | |||
123 | // interrupt handle to be used by the slave device | ||
124 | ISR(SERIAL_PIN_INTERRUPT) { | ||
125 | sync_send(); | ||
126 | |||
127 | uint8_t checksum = 0; | ||
128 | for (int i = 0; i < SERIAL_SLAVE_BUFFER_LENGTH; ++i) { | ||
129 | serial_write_byte(serial_slave_buffer[i]); | ||
130 | sync_send(); | ||
131 | checksum += serial_slave_buffer[i]; | ||
132 | } | ||
133 | serial_write_byte(checksum); | ||
134 | sync_send(); | ||
135 | |||
136 | // wait for the sync to finish sending | ||
137 | serial_delay(); | ||
138 | |||
139 | // read the middle of pulses | ||
140 | _delay_us(SERIAL_DELAY/2); | ||
141 | |||
142 | uint8_t checksum_computed = 0; | ||
143 | for (int i = 0; i < SERIAL_MASTER_BUFFER_LENGTH; ++i) { | ||
144 | serial_master_buffer[i] = serial_read_byte(); | ||
145 | sync_send(); | ||
146 | checksum_computed += serial_master_buffer[i]; | ||
147 | } | ||
148 | uint8_t checksum_received = serial_read_byte(); | ||
149 | sync_send(); | ||
150 | |||
151 | serial_input(); // end transaction | ||
152 | |||
153 | if ( checksum_computed != checksum_received ) { | ||
154 | status |= SLAVE_DATA_CORRUPT; | ||
155 | } else { | ||
156 | status &= ~SLAVE_DATA_CORRUPT; | ||
157 | } | ||
158 | } | ||
159 | |||
160 | inline | ||
161 | bool serial_slave_DATA_CORRUPT(void) { | ||
162 | return status & SLAVE_DATA_CORRUPT; | ||
163 | } | ||
164 | |||
165 | // Copies the serial_slave_buffer to the master and sends the | ||
166 | // serial_master_buffer to the slave. | ||
167 | // | ||
168 | // Returns: | ||
169 | // 0 => no error | ||
170 | // 1 => slave did not respond | ||
171 | int serial_update_buffers(void) { | ||
172 | // this code is very time dependent, so we need to disable interrupts | ||
173 | cli(); | ||
174 | |||
175 | // signal to the slave that we want to start a transaction | ||
176 | serial_output(); | ||
177 | serial_low(); | ||
178 | _delay_us(1); | ||
179 | |||
180 | // wait for the slaves response | ||
181 | serial_input(); | ||
182 | serial_high(); | ||
183 | _delay_us(SERIAL_DELAY); | ||
184 | |||
185 | // check if the slave is present | ||
186 | if (serial_read_pin()) { | ||
187 | // slave failed to pull the line low, assume not present | ||
188 | sei(); | ||
189 | return 1; | ||
190 | } | ||
191 | |||
192 | // if the slave is present syncronize with it | ||
193 | sync_recv(); | ||
194 | |||
195 | uint8_t checksum_computed = 0; | ||
196 | // receive data from the slave | ||
197 | for (int i = 0; i < SERIAL_SLAVE_BUFFER_LENGTH; ++i) { | ||
198 | serial_slave_buffer[i] = serial_read_byte(); | ||
199 | sync_recv(); | ||
200 | checksum_computed += serial_slave_buffer[i]; | ||
201 | } | ||
202 | uint8_t checksum_received = serial_read_byte(); | ||
203 | sync_recv(); | ||
204 | |||
205 | if (checksum_computed != checksum_received) { | ||
206 | sei(); | ||
207 | return 1; | ||
208 | } | ||
209 | |||
210 | uint8_t checksum = 0; | ||
211 | // send data to the slave | ||
212 | for (int i = 0; i < SERIAL_MASTER_BUFFER_LENGTH; ++i) { | ||
213 | serial_write_byte(serial_master_buffer[i]); | ||
214 | sync_recv(); | ||
215 | checksum += serial_master_buffer[i]; | ||
216 | } | ||
217 | serial_write_byte(checksum); | ||
218 | sync_recv(); | ||
219 | |||
220 | // always, release the line when not in use | ||
221 | serial_output(); | ||
222 | serial_high(); | ||
223 | |||
224 | sei(); | ||
225 | return 0; | ||
226 | } | ||
227 | |||
228 | #endif | ||
diff --git a/quantum/split_common/serial.h b/quantum/split_common/serial.h new file mode 100644 index 000000000..15fe4db7b --- /dev/null +++ b/quantum/split_common/serial.h | |||
@@ -0,0 +1,26 @@ | |||
1 | #ifndef MY_SERIAL_H | ||
2 | #define MY_SERIAL_H | ||
3 | |||
4 | #include "config.h" | ||
5 | #include <stdbool.h> | ||
6 | |||
7 | /* TODO: some defines for interrupt setup */ | ||
8 | #define SERIAL_PIN_DDR DDRD | ||
9 | #define SERIAL_PIN_PORT PORTD | ||
10 | #define SERIAL_PIN_INPUT PIND | ||
11 | #define SERIAL_PIN_MASK _BV(PD0) | ||
12 | #define SERIAL_PIN_INTERRUPT INT0_vect | ||
13 | |||
14 | #define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2 | ||
15 | #define SERIAL_MASTER_BUFFER_LENGTH 1 | ||
16 | |||
17 | // Buffers for master - slave communication | ||
18 | extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH]; | ||
19 | extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH]; | ||
20 | |||
21 | void serial_master_init(void); | ||
22 | void serial_slave_init(void); | ||
23 | int serial_update_buffers(void); | ||
24 | bool serial_slave_data_corrupt(void); | ||
25 | |||
26 | #endif | ||
diff --git a/quantum/split_common/split_flags.c b/quantum/split_common/split_flags.c new file mode 100644 index 000000000..1f5825d65 --- /dev/null +++ b/quantum/split_common/split_flags.c | |||
@@ -0,0 +1,5 @@ | |||
1 | #include "split_flags.h" | ||
2 | |||
3 | volatile bool RGB_DIRTY = false; | ||
4 | |||
5 | volatile bool BACKLIT_DIRTY = false; \ No newline at end of file | ||
diff --git a/quantum/split_common/split_flags.h b/quantum/split_common/split_flags.h new file mode 100644 index 000000000..f101fff5b --- /dev/null +++ b/quantum/split_common/split_flags.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef SPLIT_FLAGS_H | ||
2 | #define SPLIT_FLAGS_H | ||
3 | |||
4 | #include <stdbool.h> | ||
5 | #include <stdint.h> | ||
6 | |||
7 | /** | ||
8 | * Global Flags | ||
9 | **/ | ||
10 | |||
11 | //RGB Stuff | ||
12 | extern volatile bool RGB_DIRTY; | ||
13 | |||
14 | |||
15 | //Backlight Stuff | ||
16 | extern volatile bool BACKLIT_DIRTY; | ||
17 | |||
18 | |||
19 | |||
20 | #endif \ No newline at end of file | ||
diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c new file mode 100644 index 000000000..340a63137 --- /dev/null +++ b/quantum/split_common/split_util.c | |||
@@ -0,0 +1,145 @@ | |||
1 | #include <avr/io.h> | ||
2 | #include <avr/wdt.h> | ||
3 | #include <avr/power.h> | ||
4 | #include <avr/interrupt.h> | ||
5 | #include <util/delay.h> | ||
6 | #include <avr/eeprom.h> | ||
7 | #include "split_util.h" | ||
8 | #include "matrix.h" | ||
9 | #include "keyboard.h" | ||
10 | #include "config.h" | ||
11 | #include "timer.h" | ||
12 | #include "split_flags.h" | ||
13 | |||
14 | #ifdef RGBLIGHT_ENABLE | ||
15 | # include "rgblight.h" | ||
16 | #endif | ||
17 | #ifdef BACKLIGHT_ENABLE | ||
18 | # include "backlight.h" | ||
19 | #endif | ||
20 | |||
21 | #ifdef SPLIT_HAND_PIN | ||
22 | # include "pincontrol.h" | ||
23 | #endif | ||
24 | |||
25 | #if defined(USE_I2C) || defined(EH) | ||
26 | # include "i2c.h" | ||
27 | #else | ||
28 | # include "serial.h" | ||
29 | #endif | ||
30 | |||
31 | volatile bool isLeftHand = true; | ||
32 | |||
33 | volatile uint8_t setTries = 0; | ||
34 | |||
35 | static void setup_handedness(void) { | ||
36 | #ifdef SPLIT_HAND_PIN | ||
37 | // Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand | ||
38 | pinMode(SPLIT_HAND_PIN, PinDirectionInput); | ||
39 | isLeftHand = digitalRead(SPLIT_HAND_PIN); | ||
40 | #else | ||
41 | #ifdef EE_HANDS | ||
42 | isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS); | ||
43 | #else | ||
44 | // I2C_MASTER_RIGHT is deprecated, use MASTER_RIGHT instead, since this works for both serial and i2c | ||
45 | #if defined(I2C_MASTER_RIGHT) || defined(MASTER_RIGHT) | ||
46 | isLeftHand = !has_usb(); | ||
47 | #else | ||
48 | isLeftHand = has_usb(); | ||
49 | #endif | ||
50 | #endif | ||
51 | #endif | ||
52 | } | ||
53 | |||
54 | static void keyboard_master_setup(void) { | ||
55 | #if defined(USE_I2C) || defined(EH) | ||
56 | i2c_master_init(); | ||
57 | #ifdef SSD1306OLED | ||
58 | matrix_master_OLED_init (); | ||
59 | #endif | ||
60 | #else | ||
61 | serial_master_init(); | ||
62 | #endif | ||
63 | |||
64 | // For master the Backlight info needs to be sent on startup | ||
65 | // Otherwise the salve won't start with the proper info until an update | ||
66 | BACKLIT_DIRTY = true; | ||
67 | } | ||
68 | |||
69 | static void keyboard_slave_setup(void) { | ||
70 | timer_init(); | ||
71 | #if defined(USE_I2C) || defined(EH) | ||
72 | i2c_slave_init(SLAVE_I2C_ADDRESS); | ||
73 | #else | ||
74 | serial_slave_init(); | ||
75 | #endif | ||
76 | } | ||
77 | |||
78 | bool has_usb(void) { | ||
79 | USBCON |= (1 << OTGPADE); //enables VBUS pad | ||
80 | _delay_us(5); | ||
81 | return (USBSTA & (1<<VBUS)); //checks state of VBUS | ||
82 | } | ||
83 | |||
84 | void split_keyboard_setup(void) { | ||
85 | setup_handedness(); | ||
86 | |||
87 | if (has_usb()) { | ||
88 | keyboard_master_setup(); | ||
89 | } else { | ||
90 | keyboard_slave_setup(); | ||
91 | } | ||
92 | sei(); | ||
93 | } | ||
94 | |||
95 | void keyboard_slave_loop(void) { | ||
96 | matrix_init(); | ||
97 | |||
98 | //Init RGB | ||
99 | #ifdef RGBLIGHT_ENABLE | ||
100 | rgblight_init(); | ||
101 | #endif | ||
102 | |||
103 | while (1) { | ||
104 | matrix_slave_scan(); | ||
105 | |||
106 | // read backlight info | ||
107 | #ifdef BACKLIGHT_ENABLE | ||
108 | if (BACKLIT_DIRTY) { | ||
109 | backlight_set(i2c_slave_buffer[I2C_BACKLIT_START]); | ||
110 | BACKLIT_DIRTY = false; | ||
111 | } | ||
112 | #endif | ||
113 | #ifdef RGBLIGHT_ENABLE | ||
114 | if (RGB_DIRTY) { | ||
115 | cli(); | ||
116 | uint32_t dword; | ||
117 | |||
118 | /*dword = i2c_slave_buffer[I2C_RGB_START + 3]; | ||
119 | dword = (dword << 8) + i2c_slave_buffer[I2C_RGB_START + 2]; | ||
120 | dword = (dword << 8) + i2c_slave_buffer[I2C_RGB_START + 1]; | ||
121 | dword = (dword << 8) + i2c_slave_buffer[I2C_RGB_START];*/ | ||
122 | |||
123 | |||
124 | uint8_t *dword_dat = (uint8_t *)(&dword); | ||
125 | for (int i = 0; i < 4; i++) { | ||
126 | dword_dat[i] = i2c_slave_buffer[I2C_RGB_START+i]; | ||
127 | } | ||
128 | |||
129 | rgblight_update_dword(dword); | ||
130 | RGB_DIRTY = false; | ||
131 | sei(); | ||
132 | } | ||
133 | #endif | ||
134 | } | ||
135 | } | ||
136 | |||
137 | // this code runs before the usb and keyboard is initialized | ||
138 | void matrix_setup(void) { | ||
139 | split_keyboard_setup(); | ||
140 | |||
141 | if (!has_usb()) { | ||
142 | //rgblight_init(); | ||
143 | keyboard_slave_loop(); | ||
144 | } | ||
145 | } | ||
diff --git a/quantum/split_common/split_util.h b/quantum/split_common/split_util.h new file mode 100644 index 000000000..d6cf3e72a --- /dev/null +++ b/quantum/split_common/split_util.h | |||
@@ -0,0 +1,23 @@ | |||
1 | #ifndef SPLIT_KEYBOARD_UTIL_H | ||
2 | #define SPLIT_KEYBOARD_UTIL_H | ||
3 | |||
4 | #include <stdbool.h> | ||
5 | #include <stdint.h> | ||
6 | #include <stdio.h> | ||
7 | #include <stdlib.h> | ||
8 | #include "eeconfig.h" | ||
9 | |||
10 | #define SLAVE_I2C_ADDRESS 0x32 | ||
11 | |||
12 | extern volatile bool isLeftHand; | ||
13 | |||
14 | // slave version of matix scan, defined in matrix.c | ||
15 | void matrix_slave_scan(void); | ||
16 | |||
17 | void split_keyboard_setup(void); | ||
18 | bool has_usb(void); | ||
19 | void keyboard_slave_loop(void); | ||
20 | |||
21 | void matrix_master_OLED_init (void); | ||
22 | |||
23 | #endif | ||