aboutsummaryrefslogtreecommitdiff
path: root/keyboards/helix/rev2
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/helix/rev2')
-rw-r--r--keyboards/helix/rev2/config.h97
-rw-r--r--keyboards/helix/rev2/keymaps/default/config.h54
-rw-r--r--keyboards/helix/rev2/keymaps/default/keymap.c616
-rw-r--r--keyboards/helix/rev2/keymaps/default/readme.md25
-rw-r--r--keyboards/helix/rev2/keymaps/default/rules.mk25
-rw-r--r--keyboards/helix/rev2/matrix.c359
-rw-r--r--keyboards/helix/rev2/rev2.c32
-rw-r--r--keyboards/helix/rev2/rev2.h115
-rw-r--r--keyboards/helix/rev2/rules.mk3
-rw-r--r--keyboards/helix/rev2/split_util.c71
-rw-r--r--keyboards/helix/rev2/split_util.h23
11 files changed, 1420 insertions, 0 deletions
diff --git a/keyboards/helix/rev2/config.h b/keyboards/helix/rev2/config.h
new file mode 100644
index 000000000..42878d5c0
--- /dev/null
+++ b/keyboards/helix/rev2/config.h
@@ -0,0 +1,97 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3Copyright 2015 Jack Humbert
4
5This program is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 2 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef REV2_CONFIG_H
20#define REV2_CONFIG_H
21
22#include "../config.h"
23
24/* USB Device descriptor parameter */
25#define VENDOR_ID 0xFEED
26#define PRODUCT_ID 0x3060
27#define DEVICE_VER 0x0001
28#define MANUFACTURER Yushakobo
29#define PRODUCT Helix Beta
30#define DESCRIPTION A split keyboard for the cheap makers
31
32#define HELIX_ROWS 5
33
34/* key matrix size */
35// Rows are doubled-up
36#if HELIX_ROWS == 4
37 #define MATRIX_ROWS 8
38 #define MATRIX_COLS 7
39 #define MATRIX_ROW_PINS { D4, C6, D7, E6 }
40#elif HELIX_ROWS == 5
41 #define MATRIX_ROWS 10
42 #define MATRIX_COLS 7
43 #define MATRIX_ROW_PINS { D4, C6, D7, E6, B4 }
44#else
45 #error "expected HELIX_ROWS 4 or 5"
46#endif
47
48// wiring of each half
49#define MATRIX_COL_PINS { F4, F5, F6, F7, B1, B3, B2 }
50// #define MATRIX_COL_PINS { B2, B3, B1, F7, F6, F5, F4 } //uncomment this line and comment line above if you need to reverse left-to-right key order
51
52/* define if matrix has ghost */
53//#define MATRIX_HAS_GHOST
54
55/* number of backlight levels */
56// #define BACKLIGHT_LEVELS 3
57
58/* Set 0 if debouncing isn't needed */
59#define DEBOUNCING_DELAY 5
60
61/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
62//#define LOCKING_SUPPORT_ENABLE
63/* Locking resynchronize hack */
64//#define LOCKING_RESYNC_ENABLE
65
66/* key combination for command */
67#define IS_COMMAND() ( \
68 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
69)
70
71/* ws2812 RGB LED */
72#define RGB_DI_PIN D3
73#define RGBLIGHT_TIMER
74#define RGBLED_NUM 12 // Number of LEDs
75#define ws2812_PORTREG PORTD
76#define ws2812_DDRREG DDRD
77
78/*
79 * Feature disable options
80 * These options are also useful to firmware size reduction.
81 */
82
83/* disable debug print */
84// #define NO_DEBUG
85
86/* disable print */
87// #define NO_PRINT
88
89/* disable action features */
90//#define NO_ACTION_LAYER
91//#define NO_ACTION_TAPPING
92//#define NO_ACTION_ONESHOT
93//#define NO_ACTION_MACRO
94//#define NO_ACTION_FUNCTION
95
96
97#endif
diff --git a/keyboards/helix/rev2/keymaps/default/config.h b/keyboards/helix/rev2/keymaps/default/config.h
new file mode 100644
index 000000000..1b3875fcd
--- /dev/null
+++ b/keyboards/helix/rev2/keymaps/default/config.h
@@ -0,0 +1,54 @@
1/*
2This is the c configuration file for the keymap
3
4Copyright 2012 Jun Wako <wakojun@gmail.com>
5Copyright 2015 Jack Humbert
6
7This program is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along 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/* Use I2C or Serial */
27
28#define USE_I2C
29#define USE_SERIAL
30//#define USE_MATRIX_I2C
31
32/* Select hand configuration */
33
34#define MASTER_LEFT
35// #define MASTER_RIGHT
36// #define EE_HANDS
37
38//#define SSD1306OLED
39
40#define USE_SERIAL_PD2
41
42#define PREVENT_STUCK_MODIFIERS
43#define TAPPING_FORCE_HOLD
44#define TAPPING_TERM 100
45
46
47#undef RGBLED_NUM
48#define RGBLIGHT_ANIMATIONS
49#define RGBLED_NUM 6
50#define RGBLIGHT_LIMIT_VAL 255
51#define RGBLIGHT_HUE_STEP 10
52#define RGBLIGHT_SAT_STEP 17
53#define RGBLIGHT_VAL_STEP 17
54#endif
diff --git a/keyboards/helix/rev2/keymaps/default/keymap.c b/keyboards/helix/rev2/keymaps/default/keymap.c
new file mode 100644
index 000000000..b8a9baee3
--- /dev/null
+++ b/keyboards/helix/rev2/keymaps/default/keymap.c
@@ -0,0 +1,616 @@
1#include "helix.h"
2#include "bootloader.h"
3#include "action_layer.h"
4#include "eeconfig.h"
5#ifdef PROTOCOL_LUFA
6#include "lufa.h"
7#include "split_util.h"
8#endif
9#include "LUFA/Drivers/Peripheral/TWI.h"
10#ifdef AUDIO_ENABLE
11 #include "audio.h"
12#endif
13#ifdef SSD1306OLED
14 #include "ssd1306.h"
15#endif
16
17extern keymap_config_t keymap_config;
18
19#ifdef RGBLIGHT_ENABLE
20//Following line allows macro to read current RGB settings
21extern rgblight_config_t rgblight_config;
22#endif
23
24extern uint8_t is_master;
25
26// Each layer gets a name for readability, which is then used in the keymap matrix below.
27// The underscores don't mean anything - you can have a layer called STUFF or any other name.
28// Layer names don't all need to be of the same length, obviously, and you can also skip them
29// entirely and just use numbers.
30#define _QWERTY 0
31#define _COLEMAK 1
32#define _DVORAK 2
33#define _LOWER 3
34#define _RAISE 4
35#define _ADJUST 16
36
37enum custom_keycodes {
38 QWERTY = SAFE_RANGE,
39 COLEMAK,
40 DVORAK,
41 LOWER,
42 RAISE,
43 ADJUST,
44 BACKLIT,
45 EISU,
46 KANA,
47 RGBRST
48};
49
50enum macro_keycodes {
51 KC_SAMPLEMACRO,
52};
53
54
55// Fillers to make layering more clear
56#define _______ KC_TRNS
57#define XXXXXXX KC_NO
58//Macros
59#define M_SAMPLE M(KC_SAMPLEMACRO)
60
61#if HELIX_ROWS == 5
62const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
63
64 /* Qwerty
65 * ,-----------------------------------------. ,-----------------------------------------.
66 * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del |
67 * |------+------+------+------+------+------| |------+------+------+------+------+------|
68 * | Tab | Q | W | E | R | T | | Y | U | I | O | P | Bksp |
69 * |------+------+------+------+------+------| |------+------+------+------+------+------|
70 * | Ctrl | A | S | D | F | G | | H | J | K | L | ; | ' |
71 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
72 * | Shift| Z | X | C | V | B | [ | ] | N | M | , | . | / |Enter |
73 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
74 * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right |
75 * `-------------------------------------------------------------------------------------------------'
76 */
77 [_QWERTY] = KEYMAP( \
78 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
79 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
80 KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
81 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LBRC, KC_RBRC, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
82 ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
83 ),
84
85 /* Colemak
86 * ,-----------------------------------------. ,-----------------------------------------.
87 * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del |
88 * |------+------+------+------+------+------| |------+------+------+------+------+------|
89 * | Tab | Q | W | F | P | G | | J | L | U | Y | ; | Bksp |
90 * |------+------+------+------+------+------| |------+------+------+------+------+------|
91 * | Ctrl | A | R | S | T | D | | H | N | E | I | O | ' |
92 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
93 * | Shift| Z | X | C | V | B | [ | ] | K | M | , | . | / |Enter |
94 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
95 * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right |
96 * `-------------------------------------------------------------------------------------------------'
97 */
98 [_COLEMAK] = KEYMAP( \
99 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
100 KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, \
101 KC_LCTL, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \
102 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LBRC, KC_RBRC, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
103 ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
104 ),
105
106 /* Dvorak
107 * ,-----------------------------------------. ,-----------------------------------------.
108 * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Bksp |
109 * |------+------+------+------+------+------| |------+------+------+------+------+------|
110 * | Tab | ' | , | . | P | Y | | F | G | C | R | L | Del |
111 * |------+------+------+------+------+------| |------+------+------+------+------+------|
112 * | Ctrl | A | O | E | U | I | | D | H | T | N | S | / |
113 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
114 * | Shift| ; | Q | J | K | X | [ | ] | B | M | W | V | Z |Enter |
115 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
116 * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right |
117 * `-------------------------------------------------------------------------------------------------'
118 */
119 [_DVORAK] = KEYMAP( \
120 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
121 KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_DEL, \
122 KC_LCTL, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \
123 KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_LBRC, KC_RBRC, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \
124 ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
125 ),
126
127 /* Lower
128 * ,-----------------------------------------. ,-----------------------------------------.
129 * | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | |
130 * |------+------+------+------+------+------| |------+------+------+------+------+------|
131 * | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | |
132 * |------+------+------+------+------+------| |------+------+------+------+------+------|
133 * | | F1 | F2 | F3 | F4 | F5 | | F6 | _ | + | { | } | | |
134 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
135 * | | F7 | F8 | F9 | F10 | F11 | ( | ) | F12 | | | Home | End | |
136 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
137 * | | | | | | | | | | | Next | Vol- | Vol+ | Play |
138 * `-------------------------------------------------------------------------------------------------'
139 */
140 [_LOWER] = KEYMAP( \
141 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, \
142 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, \
143 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
144 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_LPRN, KC_RPRN, KC_F12, _______, _______, KC_HOME, KC_END, _______, \
145 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
146 ),
147
148 /* Raise
149 * ,-----------------------------------------. ,-----------------------------------------.
150 * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Bksp |
151 * |------+------+------+------+------+------| |------+------+------+------+------+------|
152 * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del |
153 * |------+------+------+------+------+------| |------+------+------+------+------+------|
154 * | | F1 | F2 | F3 | F4 | F5 | | F6 | - | = | [ | ] | \ |
155 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
156 * | | F7 | F8 | F9 | F10 | F11 | | | F12 | | |PageDn|PageUp| |
157 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
158 * | | | | | | | | | | | Next | Vol- | Vol+ | Play |
159 * `-------------------------------------------------------------------------------------------------'
160 */
161 [_RAISE] = KEYMAP( \
162 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
163 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
164 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
165 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, KC_F12, _______, _______, KC_PGDN, KC_PGUP, _______, \
166 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
167 ),
168
169 /* Adjust (Lower + Raise)
170 * ,-----------------------------------------. ,-----------------------------------------.
171 * | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 |
172 * |------+------+------+------+------+------| |------+------+------+------+------+------|
173 * | | Reset|RGBRST| | | | | | | | | | Del |
174 * |------+------+------+------+------+------| |------+------+------+------+------+------|
175 * | | | |Aud on|Audoff| Mac | | Win |Qwerty|Colemk|Dvorak| | |
176 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
177 * | | | | | | | | | | |RGB ON| HUE+ | SAT+ | VAL+ |
178 * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
179 * | | | | | | | | | | | MODE | HUE- | SAT- | VAL- |
180 * `-------------------------------------------------------------------------------------------------'
181 */
182 [_ADJUST] = KEYMAP( \
183 KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
184 _______, RESET, RGBRST, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \
185 _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \
186 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, \
187 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SMOD,RGB_HUD, RGB_SAD, RGB_VAD \
188 )
189};
190
191#elif HELIX_ROWS == 4
192
193const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
194
195 /* Qwerty
196 * ,-----------------------------------------. ,-----------------------------------------.
197 * | Tab | Q | W | E | R | T | | Y | U | I | O | P | Bksp |
198 * |------+------+------+------+------+------| |------+------+------+------+------+------|
199 * | Ctrl | A | S | D | F | G | | H | J | K | L | ; | ' |
200 * |------+------+------+------+------+------| |------+------+------+------+------+------|
201 * | Shift| Z | X | C | V | B | | N | M | , | . | / |Enter |
202 * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
203 * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right |
204 * `-------------------------------------------------------------------------------------------------'
205 */
206 [_QWERTY] = KEYMAP( \
207 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
208 KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
209 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
210 ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
211 ),
212
213 /* Colemak
214 * ,-----------------------------------------. ,-----------------------------------------.
215 * | Tab | Q | W | F | P | G | | J | L | U | Y | ; | Bksp |
216 * |------+------+------+------+------+------| |------+------+------+------+------+------|
217 * | Ctrl | A | R | S | T | D | | H | N | E | I | O | ' |
218 * |------+------+------+------+------+------| |------+------+------+------+------+------|
219 * | Shift| Z | X | C | V | B | | K | M | , | . | / |Enter |
220 * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
221 * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right |
222 * `-------------------------------------------------------------------------------------------------'
223 */
224 [_COLEMAK] = KEYMAP( \
225 KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, \
226 KC_LCTL, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \
227 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
228 ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
229 ),
230
231 /* Dvorak
232 * ,-----------------------------------------. ,-----------------------------------------.
233 * | Tab | ' | , | . | P | Y | | F | G | C | R | L | Del |
234 * |------+------+------+------+------+------| |------+------+------+------+------+------|
235 * | Ctrl | A | O | E | U | I | | D | H | T | N | S | / |
236 * |------+------+------+------+------+------| |------+------+------+------+------+------|
237 * | Shift| ; | Q | J | K | X | | B | M | W | V | Z |Enter |
238 * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
239 * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right |
240 * `-------------------------------------------------------------------------------------------------'
241 */
242 [_DVORAK] = KEYMAP( \
243 KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_DEL, \
244 KC_LCTL, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \
245 KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \
246 ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
247 ),
248
249 /* Lower
250 * ,-----------------------------------------. ,-----------------------------------------.
251 * | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | |
252 * |------+------+------+------+------+------| |------+------+------+------+------+------|
253 * | | F1 | F2 | F3 | F4 | F5 | | F6 | _ | + | { | } | | |
254 * |------+------+------+------+------+------| |------+------+------+------+------+------|
255 * | | F7 | F8 | F9 | F10 | F11 | | F12 | | | Home | End | |
256 * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
257 * | | | | | | | | | | | Next | Vol- | Vol+ | Play |
258 * `-------------------------------------------------------------------------------------------------'
259 */
260 [_LOWER] = KEYMAP( \
261 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, \
262 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
263 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, KC_HOME, KC_END, _______, \
264 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
265 ),
266
267 /* Raise
268 * ,-----------------------------------------. ,-----------------------------------------.
269 * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del |
270 * |------+------+------+------+------+------| |------+------+------+------+------+------|
271 * | | F1 | F2 | F3 | F4 | F5 | | F6 | - | = | [ | ] | \ |
272 * |------+------+------+------+------+------| |------+------+------+------+------+------|
273 * | | F7 | F8 | F9 | F10 | F11 | | F12 | | |PageDn|PageUp| |
274 * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
275 * | | | | | | | | | | | Next | Vol- | Vol+ | Play |
276 * `-------------------------------------------------------------------------------------------------'
277 */
278 [_RAISE] = KEYMAP( \
279 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
280 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
281 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, KC_PGDN, KC_PGUP, _______, \
282 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
283 ),
284
285 /* Adjust (Lower + Raise)
286 * ,-----------------------------------------. ,-----------------------------------------.
287 * | | Reset| | | | | | | | | | | Del |
288 * |------+------+------+------+------+------| |------+------+------+------+------+------|
289 * | | | |Aud on|Audoff| Mac | | Win |Qwerty|Colemk|Dvorak| | |
290 * |------+------+------+------+------+------| |------+------+------+------+------+------|
291 * | | | | | | | | | |RGB ON| HUE+ | SAT+ | VAL+ |
292 * |------+------+------+------+------+------+-------------+------+------+------+------+------+------|
293 * | | | | | | | | | | | MODE | HUE- | SAT- | VAL- |
294 * `-------------------------------------------------------------------------------------------------'
295 */
296 [_ADJUST] = KEYMAP( \
297 _______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \
298 _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \
299 _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, \
300 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SMOD,RGB_HUD, RGB_SAD, RGB_VAD \
301 )
302};
303
304#else
305#error "undefined keymaps"
306#endif
307
308
309#ifdef AUDIO_ENABLE
310
311float tone_qwerty[][2] = SONG(QWERTY_SOUND);
312float tone_dvorak[][2] = SONG(DVORAK_SOUND);
313float tone_colemak[][2] = SONG(COLEMAK_SOUND);
314float tone_plover[][2] = SONG(PLOVER_SOUND);
315float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND);
316float music_scale[][2] = SONG(MUSIC_SCALE_SOUND);
317#endif
318
319// define variables for reactive RGB
320bool TOG_STATUS = false;
321int RGB_current_mode;
322
323void persistent_default_layer_set(uint16_t default_layer) {
324 eeconfig_update_default_layer(default_layer);
325 default_layer_set(default_layer);
326}
327
328// Setting ADJUST layer RGB back to default
329void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
330 if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
331 #ifdef RGBLIGHT_ENABLE
332 //rgblight_mode(RGB_current_mode);
333 #endif
334 layer_on(layer3);
335 } else {
336 layer_off(layer3);
337 }
338}
339
340bool process_record_user(uint16_t keycode, keyrecord_t *record) {
341 switch (keycode) {
342 case QWERTY:
343 if (record->event.pressed) {
344 #ifdef AUDIO_ENABLE
345 PLAY_SONG(tone_qwerty);
346 #endif
347 persistent_default_layer_set(1UL<<_QWERTY);
348 }
349 return false;
350 break;
351 case COLEMAK:
352 if (record->event.pressed) {
353 #ifdef AUDIO_ENABLE
354 PLAY_SONG(tone_colemak);
355 #endif
356 persistent_default_layer_set(1UL<<_COLEMAK);
357 }
358 return false;
359 break;
360 case DVORAK:
361 if (record->event.pressed) {
362 #ifdef AUDIO_ENABLE
363 PLAY_SONG(tone_dvorak);
364 #endif
365 persistent_default_layer_set(1UL<<_DVORAK);
366 }
367 return false;
368 break;
369 case LOWER:
370 if (record->event.pressed) {
371 //not sure how to have keyboard check mode and set it to a variable, so my work around
372 //uses another variable that would be set to true after the first time a reactive key is pressed.
373 if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
374 } else {
375 TOG_STATUS = !TOG_STATUS;
376 #ifdef RGBLIGHT_ENABLE
377 //rgblight_mode(16);
378 #endif
379 }
380 layer_on(_LOWER);
381 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
382 } else {
383 #ifdef RGBLIGHT_ENABLE
384 //rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
385 #endif
386 TOG_STATUS = false;
387 layer_off(_LOWER);
388 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
389 }
390 return false;
391 break;
392 case RAISE:
393 if (record->event.pressed) {
394 //not sure how to have keyboard check mode and set it to a variable, so my work around
395 //uses another variable that would be set to true after the first time a reactive key is pressed.
396 if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
397 } else {
398 TOG_STATUS = !TOG_STATUS;
399 #ifdef RGBLIGHT_ENABLE
400 //rgblight_mode(15);
401 #endif
402 }
403 layer_on(_RAISE);
404 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
405 } else {
406 #ifdef RGBLIGHT_ENABLE
407 //rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
408 #endif
409 layer_off(_RAISE);
410 TOG_STATUS = false;
411 update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
412 }
413 return false;
414 break;
415 case ADJUST:
416 if (record->event.pressed) {
417 layer_on(_ADJUST);
418 } else {
419 layer_off(_ADJUST);
420 }
421 return false;
422 break;
423 //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released
424 case RGB_MOD:
425 #ifdef RGBLIGHT_ENABLE
426 if (record->event.pressed) {
427 rgblight_mode(RGB_current_mode);
428 rgblight_step();
429 RGB_current_mode = rgblight_config.mode;
430 }
431 #endif
432 return false;
433 break;
434 case EISU:
435 if (record->event.pressed) {
436 if(keymap_config.swap_lalt_lgui==false){
437 register_code(KC_LANG2);
438 }else{
439 SEND_STRING(SS_LALT("`"));
440 }
441 } else {
442 unregister_code(KC_LANG2);
443 }
444 return false;
445 break;
446 case KANA:
447 if (record->event.pressed) {
448 if(keymap_config.swap_lalt_lgui==false){
449 register_code(KC_LANG1);
450 }else{
451 SEND_STRING(SS_LALT("`"));
452 }
453 } else {
454 unregister_code(KC_LANG1);
455 }
456 return false;
457 break;
458 case RGBRST:
459 #ifdef RGBLIGHT_ENABLE
460 if (record->event.pressed) {
461 eeconfig_update_rgblight_default();
462 rgblight_enable();
463 RGB_current_mode = rgblight_config.mode;
464 }
465 #endif
466 break;
467 }
468 return true;
469}
470
471void matrix_init_user(void) {
472 #ifdef AUDIO_ENABLE
473 startup_user();
474 #endif
475 #ifdef RGBLIGHT_ENABLE
476 RGB_current_mode = rgblight_config.mode;
477 #endif
478 //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
479 #ifdef SSD1306OLED
480 TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000));
481 iota_gfx_init(!has_usb()); // turns on the display
482 #endif
483}
484
485
486#ifdef AUDIO_ENABLE
487
488void startup_user()
489{
490 _delay_ms(20); // gets rid of tick
491}
492
493void shutdown_user()
494{
495 _delay_ms(150);
496 stop_all_notes();
497}
498
499void music_on_user(void)
500{
501 music_scale_user();
502}
503
504void music_scale_user(void)
505{
506 PLAY_SONG(music_scale);
507}
508
509#endif
510
511
512//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
513#ifdef SSD1306OLED
514
515void matrix_scan_user(void) {
516 iota_gfx_task(); // this is what updates the display continuously
517}
518
519void matrix_update(struct CharacterMatrix *dest,
520 const struct CharacterMatrix *source) {
521 if (memcmp(dest->display, source->display, sizeof(dest->display))) {
522 memcpy(dest->display, source->display, sizeof(dest->display));
523 dest->dirty = true;
524 }
525}
526
527//assign the right code to your layers for OLED display
528#define L_BASE 0
529#define L_LOWER 8
530#define L_RAISE 16
531#define L_FNLAYER 64
532#define L_NUMLAY 128
533#define L_NLOWER 136
534#define L_NFNLAYER 192
535#define L_MOUSECURSOR 256
536#define L_ADJUST 65536
537#define L_ADJUST_TRI 65560
538
539static void render_logo(struct CharacterMatrix *matrix) {
540
541 static char logo[]={
542 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
543 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
544 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,
545 0};
546 matrix_write(matrix, logo);
547 //matrix_write_P(&matrix, PSTR(" Split keyboard kit"));
548}
549
550
551
552void render_status(struct CharacterMatrix *matrix) {
553
554 // Render to mode icon
555 static char logo[][2][3]={{{0x95,0x96,0},{0xb5,0xb6,0}},{{0x97,0x98,0},{0xb7,0xb8,0}}};
556 if(keymap_config.swap_lalt_lgui==false){
557 matrix_write(matrix, logo[0][0]);
558 matrix_write_P(matrix, PSTR("\n"));
559 matrix_write(matrix, logo[0][1]);
560 }else{
561 matrix_write(matrix, logo[1][0]);
562 matrix_write_P(matrix, PSTR("\n"));
563 matrix_write(matrix, logo[1][1]);
564 }
565
566 // Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below
567 char buf[40];
568 snprintf(buf,sizeof(buf), "Undef-%ld", layer_state);
569 matrix_write_P(matrix, PSTR("\nLayer: "));
570 switch (layer_state) {
571 case L_BASE:
572 matrix_write_P(matrix, PSTR("Default"));
573 break;
574 case L_RAISE:
575 matrix_write_P(matrix, PSTR("Raise"));
576 break;
577 case L_LOWER:
578 matrix_write_P(matrix, PSTR("Lower"));
579 break;
580 case L_ADJUST:
581 case L_ADJUST_TRI:
582 matrix_write_P(matrix, PSTR("Adjust"));
583 break;
584 default:
585 matrix_write(matrix, buf);
586 }
587
588 // Host Keyboard LED Status
589 char led[40];
590 snprintf(led, sizeof(led), "\n%s %s %s",
591 (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ",
592 (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ",
593 (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
594 matrix_write(matrix, led);
595}
596
597
598void iota_gfx_task_user(void) {
599 struct CharacterMatrix matrix;
600
601#if DEBUG_TO_SCREEN
602 if (debug_enable) {
603 return;
604 }
605#endif
606
607 matrix_clear(&matrix);
608 if(is_master){
609 render_status(&matrix);
610 }else{
611 render_logo(&matrix);
612 }
613 matrix_update(&display, &matrix);
614}
615
616#endif
diff --git a/keyboards/helix/rev2/keymaps/default/readme.md b/keyboards/helix/rev2/keymaps/default/readme.md
new file mode 100644
index 000000000..02888855b
--- /dev/null
+++ b/keyboards/helix/rev2/keymaps/default/readme.md
@@ -0,0 +1,25 @@
1SSD1306 OLED Display via I2C
2======
3
4Features
5--------
6
7Some features supported by the firmware:
8
9
10* I2C connection between the two halves is required as the OLED display will use this connection as well. Note this
11 requires pull-up resistors on the data and clock lines.
12* OLED display will connect from either side
13
14
15Wiring
16------
17
18
19Work in progress...
20
21
22OLED Configuration
23-------------------------------
24
25Work in progress...
diff --git a/keyboards/helix/rev2/keymaps/default/rules.mk b/keyboards/helix/rev2/keymaps/default/rules.mk
new file mode 100644
index 000000000..ce3ef6cd9
--- /dev/null
+++ b/keyboards/helix/rev2/keymaps/default/rules.mk
@@ -0,0 +1,25 @@
1
2# Build Options
3# change to "no" to disable the options, or define them in the Makefile in
4# the appropriate keymap folder that will get included automatically
5#
6BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
7MOUSEKEY_ENABLE = no # Mouse keys(+4700)
8EXTRAKEY_ENABLE = no # Audio control and System control(+450)
9CONSOLE_ENABLE = no # Console for debug(+400)
10COMMAND_ENABLE = no # Commands for debug and configuration
11NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
12BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
13MIDI_ENABLE = no # MIDI controls
14AUDIO_ENABLE = no # Audio output on port C6
15UNICODE_ENABLE = no # Unicode
16BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
17RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
18ONEHAND_ENABLE = no # Enable one-hand typing
19
20# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
21SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
22
23ifndef QUANTUM_DIR
24 include ../../../../Makefile
25endif
diff --git a/keyboards/helix/rev2/matrix.c b/keyboards/helix/rev2/matrix.c
new file mode 100644
index 000000000..7ddbc2107
--- /dev/null
+++ b/keyboards/helix/rev2/matrix.c
@@ -0,0 +1,359 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18/*
19 * scan matrix
20 */
21#include <stdint.h>
22#include <stdbool.h>
23#include <avr/io.h>
24#include <avr/wdt.h>
25#include <avr/interrupt.h>
26#include <util/delay.h>
27#include "print.h"
28#include "debug.h"
29#include "util.h"
30#include "matrix.h"
31#include "split_util.h"
32#include "pro_micro.h"
33#include "config.h"
34
35#ifdef USE_MATRIX_I2C
36# include "i2c.h"
37#else // USE_SERIAL
38# include "serial.h"
39#endif
40
41#ifndef DEBOUNCE
42# define DEBOUNCE 5
43#endif
44
45#define ERROR_DISCONNECT_COUNT 5
46
47static uint8_t debouncing = DEBOUNCE;
48static const int ROWS_PER_HAND = MATRIX_ROWS/2;
49static uint8_t error_count = 0;
50uint8_t is_master = 0 ;
51
52static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
53static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
54
55/* matrix state(1:on, 0:off) */
56static matrix_row_t matrix[MATRIX_ROWS];
57static matrix_row_t matrix_debouncing[MATRIX_ROWS];
58
59static matrix_row_t read_cols(void);
60static void init_cols(void);
61static void unselect_rows(void);
62static void select_row(uint8_t row);
63static uint8_t matrix_master_scan(void);
64
65__attribute__ ((weak))
66void matrix_init_quantum(void) {
67 matrix_init_kb();
68}
69
70__attribute__ ((weak))
71void matrix_scan_quantum(void) {
72 matrix_scan_kb();
73}
74
75__attribute__ ((weak))
76void matrix_init_kb(void) {
77 matrix_init_user();
78}
79
80__attribute__ ((weak))
81void matrix_scan_kb(void) {
82 matrix_scan_user();
83}
84
85__attribute__ ((weak))
86void matrix_init_user(void) {
87}
88
89__attribute__ ((weak))
90void matrix_scan_user(void) {
91}
92
93inline
94uint8_t matrix_rows(void)
95{
96 return MATRIX_ROWS;
97}
98
99inline
100uint8_t matrix_cols(void)
101{
102 return MATRIX_COLS;
103}
104
105void matrix_init(void)
106{
107 debug_enable = true;
108 debug_matrix = true;
109 debug_mouse = true;
110 // initialize row and col
111 unselect_rows();
112 init_cols();
113
114 TX_RX_LED_INIT;
115
116 // initialize matrix state: all keys off
117 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
118 matrix[i] = 0;
119 matrix_debouncing[i] = 0;
120 }
121
122 is_master = has_usb();
123
124 matrix_init_quantum();
125}
126
127uint8_t _matrix_scan(void)
128{
129 // Right hand is stored after the left in the matirx so, we need to offset it
130 int offset = isLeftHand ? 0 : (ROWS_PER_HAND);
131
132 for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
133 select_row(i);
134 _delay_us(30); // without this wait read unstable value.
135 matrix_row_t cols = read_cols();
136 if (matrix_debouncing[i+offset] != cols) {
137 matrix_debouncing[i+offset] = cols;
138 debouncing = DEBOUNCE;
139 }
140 unselect_rows();
141 }
142
143 if (debouncing) {
144 if (--debouncing) {
145 _delay_ms(1);
146 } else {
147 for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
148 matrix[i+offset] = matrix_debouncing[i+offset];
149 }
150 }
151 }
152
153 return 1;
154}
155
156#ifdef USE_MATRIX_I2C
157
158// Get rows from other half over i2c
159int i2c_transaction(void) {
160 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
161
162 int err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE);
163 if (err) goto i2c_error;
164
165 // start of matrix stored at 0x00
166 err = i2c_master_write(0x00);
167 if (err) goto i2c_error;
168
169 // Start read
170 err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_READ);
171 if (err) goto i2c_error;
172
173 if (!err) {
174 int i;
175 for (i = 0; i < ROWS_PER_HAND-1; ++i) {
176 matrix[slaveOffset+i] = i2c_master_read(I2C_ACK);
177 }
178 matrix[slaveOffset+i] = i2c_master_read(I2C_NACK);
179 i2c_master_stop();
180 } else {
181i2c_error: // the cable is disconnceted, or something else went wrong
182 i2c_reset_state();
183 return err;
184 }
185
186 return 0;
187}
188
189#else // USE_SERIAL
190
191int serial_transaction(void) {
192 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
193 int ret=serial_update_buffers();
194 if (ret ) {
195 if(ret==2)RXLED1;
196 return 1;
197 }
198RXLED0;
199 for (int i = 0; i < ROWS_PER_HAND; ++i) {
200 matrix[slaveOffset+i] = serial_slave_buffer[i];
201 }
202 return 0;
203}
204#endif
205
206uint8_t matrix_scan(void)
207{
208 if (is_master) {
209 matrix_master_scan();
210 }else{
211 matrix_slave_scan();
212
213// if(serial_slave_DATA_CORRUPT()){
214// TXLED0;
215 int offset = (isLeftHand) ? ROWS_PER_HAND : 0;
216
217 for (int i = 0; i < ROWS_PER_HAND; ++i) {
218 matrix[offset+i] = serial_master_buffer[i];
219 }
220
221// }else{
222// TXLED1;
223// }
224
225 matrix_scan_quantum();
226 }
227 return 1;
228}
229
230
231uint8_t matrix_master_scan(void) {
232
233 int ret = _matrix_scan();
234
235#ifndef KEYBOARD_helix_rev1
236 int offset = (isLeftHand) ? 0 : ROWS_PER_HAND;
237
238#ifdef USE_MATRIX_I2C
239// for (int i = 0; i < ROWS_PER_HAND; ++i) {
240 /* i2c_slave_buffer[i] = matrix[offset+i]; */
241// i2c_slave_buffer[i] = matrix[offset+i];
242// }
243#else // USE_SERIAL
244 for (int i = 0; i < ROWS_PER_HAND; ++i) {
245 serial_master_buffer[i] = matrix[offset+i];
246 }
247#endif
248#endif
249
250#ifdef USE_MATRIX_I2C
251 if( i2c_transaction() ) {
252#else // USE_SERIAL
253 if( serial_transaction() ) {
254#endif
255 // turn on the indicator led when halves are disconnected
256 TXLED1;
257
258 error_count++;
259
260 if (error_count > ERROR_DISCONNECT_COUNT) {
261 // reset other half if disconnected
262 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
263 for (int i = 0; i < ROWS_PER_HAND; ++i) {
264 matrix[slaveOffset+i] = 0;
265 }
266 }
267 } else {
268 // turn off the indicator led on no error
269 TXLED0;
270 error_count = 0;
271 }
272 matrix_scan_quantum();
273 return ret;
274}
275
276void matrix_slave_scan(void) {
277 _matrix_scan();
278
279 int offset = (isLeftHand) ? 0 : ROWS_PER_HAND;
280
281#ifdef USE_MATRIX_I2C
282 for (int i = 0; i < ROWS_PER_HAND; ++i) {
283 /* i2c_slave_buffer[i] = matrix[offset+i]; */
284 i2c_slave_buffer[i] = matrix[offset+i];
285 }
286#else // USE_SERIAL
287 for (int i = 0; i < ROWS_PER_HAND; ++i) {
288 serial_slave_buffer[i] = matrix[offset+i];
289 }
290#endif
291}
292
293bool matrix_is_modified(void)
294{
295 if (debouncing) return false;
296 return true;
297}
298
299inline
300bool matrix_is_on(uint8_t row, uint8_t col)
301{
302 return (matrix[row] & ((matrix_row_t)1<<col));
303}
304
305inline
306matrix_row_t matrix_get_row(uint8_t row)
307{
308 return matrix[row];
309}
310
311void matrix_print(void)
312{
313 print("\nr/c 0123456789ABCDEF\n");
314 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
315 phex(row); print(": ");
316 pbin_reverse16(matrix_get_row(row));
317 print("\n");
318 }
319}
320
321uint8_t matrix_key_count(void)
322{
323 uint8_t count = 0;
324 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
325 count += bitpop16(matrix[i]);
326 }
327 return count;
328}
329
330static void init_cols(void)
331{
332 for(int x = 0; x < MATRIX_COLS; x++) {
333 _SFR_IO8((col_pins[x] >> 4) + 1) &= ~_BV(col_pins[x] & 0xF);
334 _SFR_IO8((col_pins[x] >> 4) + 2) |= _BV(col_pins[x] & 0xF);
335 }
336}
337
338static matrix_row_t read_cols(void)
339{
340 matrix_row_t result = 0;
341 for(int x = 0; x < MATRIX_COLS; x++) {
342 result |= (_SFR_IO8(col_pins[x] >> 4) & _BV(col_pins[x] & 0xF)) ? 0 : (1 << x);
343 }
344 return result;
345}
346
347static void unselect_rows(void)
348{
349 for(int x = 0; x < ROWS_PER_HAND; x++) {
350 _SFR_IO8((row_pins[x] >> 4) + 1) &= ~_BV(row_pins[x] & 0xF);
351 _SFR_IO8((row_pins[x] >> 4) + 2) |= _BV(row_pins[x] & 0xF);
352 }
353}
354
355static void select_row(uint8_t row)
356{
357 _SFR_IO8((row_pins[row] >> 4) + 1) |= _BV(row_pins[row] & 0xF);
358 _SFR_IO8((row_pins[row] >> 4) + 2) &= ~_BV(row_pins[row] & 0xF);
359}
diff --git a/keyboards/helix/rev2/rev2.c b/keyboards/helix/rev2/rev2.c
new file mode 100644
index 000000000..1b23edb79
--- /dev/null
+++ b/keyboards/helix/rev2/rev2.c
@@ -0,0 +1,32 @@
1#include "helix.h"
2
3
4#ifdef AUDIO_ENABLE
5 float tone_startup[][2] = SONG(STARTUP_SOUND);
6 float tone_goodbye[][2] = SONG(GOODBYE_SOUND);
7#endif
8
9#ifdef SSD1306OLED
10void led_set_kb(uint8_t usb_led) {
11 // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
12 //led_set_user(usb_led);
13}
14#endif
15
16void matrix_init_kb(void) {
17
18 #ifdef AUDIO_ENABLE
19 _delay_ms(20); // gets rid of tick
20 PLAY_SONG(tone_startup);
21 #endif
22
23 matrix_init_user();
24};
25
26void shutdown_kb(void) {
27 #ifdef AUDIO_ENABLE
28 PLAY_SONG(tone_goodbye);
29 _delay_ms(150);
30 stop_all_notes();
31 #endif
32}
diff --git a/keyboards/helix/rev2/rev2.h b/keyboards/helix/rev2/rev2.h
new file mode 100644
index 000000000..7cab57ea0
--- /dev/null
+++ b/keyboards/helix/rev2/rev2.h
@@ -0,0 +1,115 @@
1#ifndef REV2_H
2#define REV2_CONFIG_H
3
4#include "../helix.h"
5
6//void promicro_bootloader_jmp(bool program);
7#include "quantum.h"
8
9#ifdef RGBLIGHT_ENABLE
10//rgb led driver
11#include "ws2812.h"
12#endif
13
14#ifdef USE_I2C
15#include <stddef.h>
16#ifdef __AVR__
17 #include <avr/io.h>
18 #include <avr/interrupt.h>
19#endif
20#endif
21
22//void promicro_bootloader_jmp(bool program);
23
24
25#if HELIX_ROWS == 4
26#ifndef FLIP_HALF
27// Standard Keymap
28// (TRRS jack on the left half is to the right, TRRS jack on the right half is to the left)
29#define KEYMAP( \
30 L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \
31 L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \
32 L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \
33 L30, L31, L32, L33, L34, L35, L36, R36, R30, R31, R32, R33, R34, R35 \
34 ) \
35 { \
36 { L00, L01, L02, L03, L04, L05, KC_NO }, \
37 { L10, L11, L12, L13, L14, L15, KC_NO }, \
38 { L20, L21, L22, L23, L24, L25, KC_NO }, \
39 { L30, L31, L32, L33, L34, L35, L36 }, \
40 { R05, R04, R03, R02, R01, R00, KC_NO }, \
41 { R15, R14, R13, R12, R11, R10, KC_NO }, \
42 { R25, R24, R23, R22, R21, R20, KC_NO }, \
43 { R35, R34, R33, R32, R31, R30, R36 }, \
44 }
45#else
46// Keymap with right side flipped
47// (TRRS jack on both halves are to the right)
48#define KEYMAP( \
49 L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \
50 L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \
51 L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \
52 L30, L31, L32, L33, L34, L35, L36, R36, R30, R31, R32, R33, R34, R35 \
53 ) \
54 { \
55 { L00, L01, L02, L03, L04, L05, KC_NO }, \
56 { L10, L11, L12, L13, L14, L15, KC_NO }, \
57 { L20, L21, L22, L23, L24, L25, KC_NO }, \
58 { L30, L31, L32, L33, L34, L35, L36 }, \
59 { KC_NO, R00, R01, R02, R03, R04, R05 }, \
60 { KC_NO, R10, R11, R12, R13, R14, R15 }, \
61 { KC_NO, R20, R21, R22, R23, R24, R25 }, \
62 { R36, R30, R31, R32, R33, R34, R35 }, \
63 }
64#endif
65#elif HELIX_ROWS == 5
66 #ifndef FLIP_HALF
67 // Standard Keymap
68 // (TRRS jack on the left half is to the right, TRRS jack on the right half is to the left)
69 #define KEYMAP( \
70 L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \
71 L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \
72 L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \
73 L30, L31, L32, L33, L34, L35, L36, R36, R30, R31, R32, R33, R34, R35, \
74 L40, L41, L42, L43, L44, L45, L46, R46, R40, R41, R42, R43, R44, R45 \
75 ) \
76 { \
77 { L00, L01, L02, L03, L04, L05, KC_NO }, \
78 { L10, L11, L12, L13, L14, L15, KC_NO }, \
79 { L20, L21, L22, L23, L24, L25, KC_NO }, \
80 { L30, L31, L32, L33, L34, L35, L36 }, \
81 { L40, L41, L42, L43, L44, L45, L46 }, \
82 { R05, R04, R03, R02, R01, R00, KC_NO }, \
83 { R15, R14, R13, R12, R11, R10, KC_NO }, \
84 { R25, R24, R23, R22, R21, R20, KC_NO }, \
85 { R35, R34, R33, R32, R31, R30, R36 }, \
86 { R45, R44, R43, R42, R41, R40, R46 } \
87 }
88 #else
89 // Keymap with right side flipped
90 // (TRRS jack on both halves are to the right)
91 #define KEYMAP( \
92 L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \
93 L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \
94 L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \
95 L30, L31, L32, L33, L34, L35, L36, R36, R30, R31, R32, R33, R34, R35, \
96 L40, L41, L42, L43, L44, L45, L46, R46, R40, R41, R42, R43, R44, R45 \
97 ) \
98 { \
99 { L00, L01, L02, L03, L04, L05, KC_NO }, \
100 { L10, L11, L12, L13, L14, L15, KC_NO }, \
101 { L20, L21, L22, L23, L24, L25, KC_NO }, \
102 { L30, L31, L32, L33, L34, L35, L36 }, \
103 { L40, L41, L42, L43, L44, L45, L46 }, \
104 { KC_NO, R00, R01, R02, R03, R04, R05 }, \
105 { KC_NO, R10, R11, R12, R13, R14, R15 }, \
106 { KC_NO, R20, R21, R22, R23, R24, R25 }, \
107 { R36, R30, R31, R32, R33, R34, R35 }, \
108 { R46, R40, R41, R42, R43, R44, R45 } \
109 }
110 #endif
111#else
112 #error "expected HELIX_ROWS 4 or 5"
113#endif
114
115#endif
diff --git a/keyboards/helix/rev2/rules.mk b/keyboards/helix/rev2/rules.mk
new file mode 100644
index 000000000..6ab01f44b
--- /dev/null
+++ b/keyboards/helix/rev2/rules.mk
@@ -0,0 +1,3 @@
1SRC += rev2/matrix.c \
2 rev2/split_util.c \
3 ws2812.c
diff --git a/keyboards/helix/rev2/split_util.c b/keyboards/helix/rev2/split_util.c
new file mode 100644
index 000000000..8bc064174
--- /dev/null
+++ b/keyboards/helix/rev2/split_util.c
@@ -0,0 +1,71 @@
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
12#ifdef USE_MATRIX_I2C
13# include "i2c.h"
14#else
15# include "serial.h"
16#endif
17
18volatile bool isLeftHand = true;
19
20static void setup_handedness(void) {
21 #ifdef EE_HANDS
22 isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS);
23 #else
24 // I2C_MASTER_RIGHT is deprecated, use MASTER_RIGHT instead, since this works for both serial and i2c
25 #if defined(I2C_MASTER_RIGHT) || defined(MASTER_RIGHT)
26 isLeftHand = !has_usb();
27 #else
28 isLeftHand = has_usb();
29 #endif
30 #endif
31}
32
33static void keyboard_master_setup(void) {
34
35#ifdef USE_MATRIX_I2C
36 i2c_master_init();
37#else
38 serial_master_init();
39#endif
40}
41
42static void keyboard_slave_setup(void) {
43
44#ifdef USE_MATRIX_I2C
45 i2c_slave_init(SLAVE_I2C_ADDRESS);
46#else
47 serial_slave_init();
48#endif
49}
50
51bool has_usb(void) {
52 USBCON |= (1 << OTGPADE); //enables VBUS pad
53 _delay_us(5);
54 return (USBSTA & (1<<VBUS)); //checks state of VBUS
55}
56
57void split_keyboard_setup(void) {
58 setup_handedness();
59
60 if (has_usb()) {
61 keyboard_master_setup();
62 } else {
63 keyboard_slave_setup();
64 }
65 sei();
66}
67
68// this code runs before the usb and keyboard is initialized
69void matrix_setup(void) {
70 split_keyboard_setup();
71}
diff --git a/keyboards/helix/rev2/split_util.h b/keyboards/helix/rev2/split_util.h
new file mode 100644
index 000000000..757e934c7
--- /dev/null
+++ b/keyboards/helix/rev2/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
6#ifdef EE_HANDS
7 #define EECONFIG_BOOTMAGIC_END (uint8_t *)10
8 #define EECONFIG_HANDEDNESS EECONFIG_BOOTMAGIC_END
9#endif
10
11#define SLAVE_I2C_ADDRESS 0x32
12
13extern volatile bool isLeftHand;
14
15// slave version of matix scan, defined in matrix.c
16void matrix_slave_scan(void);
17
18void split_keyboard_setup(void);
19bool has_usb(void);
20
21void matrix_master_OLED_init (void);
22
23#endif