aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2017-06-01 12:58:33 -0400
committerGitHub <noreply@github.com>2017-06-01 12:58:33 -0400
commit9069edd9344ae280cf7a638b3f8e6c9e53bbfd67 (patch)
treebbb404f2d53bca461e9e8b199b07bdc08d11f44c
parentd548693c8be93792605c413d7258aeeb0dcc4f34 (diff)
parentaae727d9ecce60906b26ee9a5a5d72f6fd25d9e4 (diff)
downloadqmk_firmware-9069edd9344ae280cf7a638b3f8e6c9e53bbfd67.tar.gz
qmk_firmware-9069edd9344ae280cf7a638b3f8e6c9e53bbfd67.zip
Merge pull request #1347 from nooges/nyquist
Add Nyquist keyboard support
-rw-r--r--keyboards/nyquist/Makefile5
-rw-r--r--keyboards/nyquist/config.h27
-rw-r--r--keyboards/nyquist/i2c.c162
-rw-r--r--keyboards/nyquist/i2c.h49
-rw-r--r--keyboards/nyquist/imgs/split-keyboard-i2c-schematic.pngbin0 -> 26565 bytes
-rw-r--r--keyboards/nyquist/imgs/split-keyboard-serial-schematic.pngbin0 -> 19487 bytes
-rw-r--r--keyboards/nyquist/keymaps/hexwire/Makefile5
-rw-r--r--keyboards/nyquist/keymaps/hexwire/README.md116
-rw-r--r--keyboards/nyquist/keymaps/hexwire/Underglow Pinouts.md20
-rw-r--r--keyboards/nyquist/keymaps/hexwire/config.h31
-rw-r--r--keyboards/nyquist/keymaps/hexwire/keymap.c218
-rwxr-xr-xkeyboards/nyquist/keymaps/hexwire/keymap_converter.py39
-rwxr-xr-xkeyboards/nyquist/keymaps/hexwire/keymap_to_readme.rb40
-rw-r--r--keyboards/nyquist/keymaps/i2c/config.h26
-rw-r--r--keyboards/nyquist/keymaps/i2c/keymap.c231
-rw-r--r--keyboards/nyquist/keymaps/serial/config.h26
-rw-r--r--keyboards/nyquist/keymaps/serial/keymap.c232
-rw-r--r--keyboards/nyquist/matrix.c316
-rw-r--r--keyboards/nyquist/nyquist.c1
-rw-r--r--keyboards/nyquist/nyquist.h26
-rw-r--r--keyboards/nyquist/pro_micro.h362
-rw-r--r--keyboards/nyquist/readme.md167
-rw-r--r--keyboards/nyquist/rev1/Makefile3
-rw-r--r--keyboards/nyquist/rev1/config.h89
-rw-r--r--keyboards/nyquist/rev1/rev1.c39
-rw-r--r--keyboards/nyquist/rev1/rev1.h66
-rw-r--r--keyboards/nyquist/rev1/rules.mk5
-rw-r--r--keyboards/nyquist/rules.mk87
-rw-r--r--keyboards/nyquist/serial.c228
-rw-r--r--keyboards/nyquist/serial.h26
-rw-r--r--keyboards/nyquist/split_util.c84
-rw-r--r--keyboards/nyquist/split_util.h24
32 files changed, 2750 insertions, 0 deletions
diff --git a/keyboards/nyquist/Makefile b/keyboards/nyquist/Makefile
new file mode 100644
index 000000000..0c519b323
--- /dev/null
+++ b/keyboards/nyquist/Makefile
@@ -0,0 +1,5 @@
1SUBPROJECT_DEFAULT = rev1
2
3ifndef MAKEFILE_INCLUDED
4 include ../../Makefile
5endif
diff --git a/keyboards/nyquist/config.h b/keyboards/nyquist/config.h
new file mode 100644
index 000000000..55500df79
--- /dev/null
+++ b/keyboards/nyquist/config.h
@@ -0,0 +1,27 @@
1/*
2Copyright 2017 Danny Nguyen <danny@hexwire.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#ifndef CONFIG_H
19#define CONFIG_H
20
21#include "config_common.h"
22
23#ifdef SUBPROJECT_rev1
24 #include "rev1/config.h"
25#endif
26
27#endif // CONFIG_H
diff --git a/keyboards/nyquist/i2c.c b/keyboards/nyquist/i2c.c
new file mode 100644
index 000000000..084c890c4
--- /dev/null
+++ b/keyboards/nyquist/i2c.c
@@ -0,0 +1,162 @@
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
9#ifdef USE_I2C
10
11// Limits the amount of we wait for any one i2c transaction.
12// Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is
13// 9 bits, a single transaction will take around 90μs to complete.
14//
15// (F_CPU/SCL_CLOCK) => # of μC cycles to transfer a bit
16// poll loop takes at least 8 clock cycles to execute
17#define I2C_LOOP_TIMEOUT (9+1)*(F_CPU/SCL_CLOCK)/8
18
19#define BUFFER_POS_INC() (slave_buffer_pos = (slave_buffer_pos+1)%SLAVE_BUFFER_SIZE)
20
21volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];
22
23static volatile uint8_t slave_buffer_pos;
24static volatile bool slave_has_register_set = false;
25
26// Wait for an i2c operation to finish
27inline static
28void i2c_delay(void) {
29 uint16_t lim = 0;
30 while(!(TWCR & (1<<TWINT)) && lim < I2C_LOOP_TIMEOUT)
31 lim++;
32
33 // easier way, but will wait slightly longer
34 // _delay_us(100);
35}
36
37// Setup twi to run at 100kHz
38void i2c_master_init(void) {
39 // no prescaler
40 TWSR = 0;
41 // Set TWI clock frequency to SCL_CLOCK. Need TWBR>10.
42 // Check datasheets for more info.
43 TWBR = ((F_CPU/SCL_CLOCK)-16)/2;
44}
45
46// Start a transaction with the given i2c slave address. The direction of the
47// transfer is set with I2C_READ and I2C_WRITE.
48// returns: 0 => success
49// 1 => error
50uint8_t i2c_master_start(uint8_t address) {
51 TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTA);
52
53 i2c_delay();
54
55 // check that we started successfully
56 if ( (TW_STATUS != TW_START) && (TW_STATUS != TW_REP_START))
57 return 1;
58
59 TWDR = address;
60 TWCR = (1<<TWINT) | (1<<TWEN);
61
62 i2c_delay();
63
64 if ( (TW_STATUS != TW_MT_SLA_ACK) && (TW_STATUS != TW_MR_SLA_ACK) )
65 return 1; // slave did not acknowledge
66 else
67 return 0; // success
68}
69
70
71// Finish the i2c transaction.
72void i2c_master_stop(void) {
73 TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
74
75 uint16_t lim = 0;
76 while(!(TWCR & (1<<TWSTO)) && lim < I2C_LOOP_TIMEOUT)
77 lim++;
78}
79
80// Write one byte to the i2c slave.
81// returns 0 => slave ACK
82// 1 => slave NACK
83uint8_t i2c_master_write(uint8_t data) {
84 TWDR = data;
85 TWCR = (1<<TWINT) | (1<<TWEN);
86
87 i2c_delay();
88
89 // check if the slave acknowledged us
90 return (TW_STATUS == TW_MT_DATA_ACK) ? 0 : 1;
91}
92
93// Read one byte from the i2c slave. If ack=1 the slave is acknowledged,
94// if ack=0 the acknowledge bit is not set.
95// returns: byte read from i2c device
96uint8_t i2c_master_read(int ack) {
97 TWCR = (1<<TWINT) | (1<<TWEN) | (ack<<TWEA);
98
99 i2c_delay();
100 return TWDR;
101}
102
103void i2c_reset_state(void) {
104 TWCR = 0;
105}
106
107void i2c_slave_init(uint8_t address) {
108 TWAR = address << 0; // slave i2c address
109 // TWEN - twi enable
110 // TWEA - enable address acknowledgement
111 // TWINT - twi interrupt flag
112 // TWIE - enable the twi interrupt
113 TWCR = (1<<TWIE) | (1<<TWEA) | (1<<TWINT) | (1<<TWEN);
114}
115
116ISR(TWI_vect);
117
118ISR(TWI_vect) {
119 uint8_t ack = 1;
120 switch(TW_STATUS) {
121 case TW_SR_SLA_ACK:
122 // this device has been addressed as a slave receiver
123 slave_has_register_set = false;
124 break;
125
126 case TW_SR_DATA_ACK:
127 // this device has received data as a slave receiver
128 // The first byte that we receive in this transaction sets the location
129 // of the read/write location of the slaves memory that it exposes over
130 // i2c. After that, bytes will be written at slave_buffer_pos, incrementing
131 // slave_buffer_pos after each write.
132 if(!slave_has_register_set) {
133 slave_buffer_pos = TWDR;
134 // don't acknowledge the master if this memory loctaion is out of bounds
135 if ( slave_buffer_pos >= SLAVE_BUFFER_SIZE ) {
136 ack = 0;
137 slave_buffer_pos = 0;
138 }
139 slave_has_register_set = true;
140 } else {
141 i2c_slave_buffer[slave_buffer_pos] = TWDR;
142 BUFFER_POS_INC();
143 }
144 break;
145
146 case TW_ST_SLA_ACK:
147 case TW_ST_DATA_ACK:
148 // master has addressed this device as a slave transmitter and is
149 // requesting data.
150 TWDR = i2c_slave_buffer[slave_buffer_pos];
151 BUFFER_POS_INC();
152 break;
153
154 case TW_BUS_ERROR: // something went wrong, reset twi state
155 TWCR = 0;
156 default:
157 break;
158 }
159 // Reset everything, so we are ready for the next TWI interrupt
160 TWCR |= (1<<TWIE) | (1<<TWINT) | (ack<<TWEA) | (1<<TWEN);
161}
162#endif
diff --git a/keyboards/nyquist/i2c.h b/keyboards/nyquist/i2c.h
new file mode 100644
index 000000000..43e596988
--- /dev/null
+++ b/keyboards/nyquist/i2c.h
@@ -0,0 +1,49 @@
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#define SLAVE_BUFFER_SIZE 0x10
17
18// i2c SCL clock frequency
19#define SCL_CLOCK 100000L
20
21extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];
22
23void i2c_master_init(void);
24uint8_t i2c_master_start(uint8_t address);
25void i2c_master_stop(void);
26uint8_t i2c_master_write(uint8_t data);
27uint8_t i2c_master_read(int);
28void i2c_reset_state(void);
29void i2c_slave_init(uint8_t address);
30
31
32static inline unsigned char i2c_start_read(unsigned char addr) {
33 return i2c_master_start((addr << 1) | I2C_READ);
34}
35
36static inline unsigned char i2c_start_write(unsigned char addr) {
37 return i2c_master_start((addr << 1) | I2C_WRITE);
38}
39
40// from SSD1306 scrips
41extern unsigned char i2c_rep_start(unsigned char addr);
42extern void i2c_start_wait(unsigned char addr);
43extern unsigned char i2c_readAck(void);
44extern unsigned char i2c_readNak(void);
45extern unsigned char i2c_read(unsigned char ack);
46
47#define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak();
48
49#endif
diff --git a/keyboards/nyquist/imgs/split-keyboard-i2c-schematic.png b/keyboards/nyquist/imgs/split-keyboard-i2c-schematic.png
new file mode 100644
index 000000000..888294718
--- /dev/null
+++ b/keyboards/nyquist/imgs/split-keyboard-i2c-schematic.png
Binary files differ
diff --git a/keyboards/nyquist/imgs/split-keyboard-serial-schematic.png b/keyboards/nyquist/imgs/split-keyboard-serial-schematic.png
new file mode 100644
index 000000000..7621d38ed
--- /dev/null
+++ b/keyboards/nyquist/imgs/split-keyboard-serial-schematic.png
Binary files differ
diff --git a/keyboards/nyquist/keymaps/hexwire/Makefile b/keyboards/nyquist/keymaps/hexwire/Makefile
new file mode 100644
index 000000000..1e5761278
--- /dev/null
+++ b/keyboards/nyquist/keymaps/hexwire/Makefile
@@ -0,0 +1,5 @@
1RGBLIGHT_ENABLE = yes
2
3ifndef QUANTUM_DIR
4 include ../../../../Makefile
5endif
diff --git a/keyboards/nyquist/keymaps/hexwire/README.md b/keyboards/nyquist/keymaps/hexwire/README.md
new file mode 100644
index 000000000..3ce3f6af3
--- /dev/null
+++ b/keyboards/nyquist/keymaps/hexwire/README.md
@@ -0,0 +1,116 @@
1Hexwire's Nyquist Layout
2============================
3
4### Changes from default layout
5
6- Main layer
7 - The right space bar key has been changed to backspace, as I only hit space with my left thumb
8 - Backtick is at the lower right and also serves goes to the 3rd function layer when held
9 - Enter key acts as shift when held
10 - Escape key acts as control when held
11 - Minus key at upper right
12- Lower layer
13 - Numbers are on the lower layer, to make it easier to use a numpad on the right hand
14 - Arrow keys
15 - Straight and curly brackets in the middle two columns
16 - Screenshot keys for MacOS
17- Upper layer
18 - Symbols are on the upper layer
19 - Media keys
20 - Page Up/Down, Home/End
21- 3rd function layer
22 - Function keys
23
24## Layouts
25
26### QWERTY
27
28```
29,----+----+----+----+----+----. ,----+----+----+----+----+----.
30|ESC , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC|
31|----+----+----+----+----+----| |----+----+----+----+----+----|
32|TAB , Q , W , E , R , T , Y , U , I , O , P ,MINS|
33|----+----+----+----+----+----| |----+----+----+----+----+----|
34| X0 , A , S , D , F , G , H , J , K , L ,SCLN,QUOT|
35|----+----+----+----+----+----| |----+----+----+----+----+----|
36|LSFT, Z , X , C , V , B , N , M ,COMM,DOT ,SLSH, X4 |
37|----+----+----+----+----+----| |----+----+----+----+----+----|
38| X3 ,LCTL,LALT,LGUI, X1 ,SPC , BSPC, X2 ,LEFT,DOWN, UP ,RGHT|
39`----+----+----+----+----+----' `----+----+----+----+----+----'
40```
41
42### Colemak
43```
44,----+----+----+----+----+----. ,----+----+----+----+----+----.
45|ESC , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC|
46|----+----+----+----+----+----| |----+----+----+----+----+----|
47|TAB , Q , W , F , P , G , J , L , U , Y ,SCLN,MINS|
48|----+----+----+----+----+----| |----+----+----+----+----+----|
49| X0 , A , R , S , T , D , H , N , E , I , O ,QUOT|
50|----+----+----+----+----+----| |----+----+----+----+----+----|
51|LSFT, Z , X , C , V , B , K , M ,COMM,DOT ,SLSH, X4 |
52|----+----+----+----+----+----| |----+----+----+----+----+----|
53| X3 ,LCTL,LALT,LGUI, X1 ,SPC , BSPC, X2 ,LEFT,DOWN, UP ,RGHT|
54`----+----+----+----+----+----' `----+----+----+----+----+----'
55```
56
57### Dvorak
58```
59,----+----+----+----+----+----. ,----+----+----+----+----+----.
60|ESC , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC|
61|----+----+----+----+----+----| |----+----+----+----+----+----|
62|TAB ,QUOT,COMM,DOT , P , Y , F , G , C , R , L ,MINS|
63|----+----+----+----+----+----| |----+----+----+----+----+----|
64| X0 , A , O , E , U , I , D , H , T , N , S ,SLSH|
65|----+----+----+----+----+----| |----+----+----+----+----+----|
66|LSFT,SCLN, Q , J , K , X , B , M , W , V , Z , X4 |
67|----+----+----+----+----+----| |----+----+----+----+----+----|
68| X3 ,LCTL,LALT,LGUI, X1 ,SPC , BSPC, X2 ,LEFT,DOWN, UP ,RGHT|
69`----+----+----+----+----+----' `----+----+----+----+----+----'
70```
71
72### Lower
73```
74,----+----+----+----+----+----. ,----+----+----+----+----+----.
75|TILD,EXLM, AT ,HASH,DLR ,PERC, CIRC,AMPR,ASTR,LPRN,RPRN,BSPC|
76|----+----+----+----+----+----| |----+----+----+----+----+----|
77| , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 , |
78|----+----+----+----+----+----| |----+----+----+----+----+----|
79|DEL ,CAPP,LEFT,RGHT, UP ,LBRC, RBRC, P4 , P5 , P6 ,PLUS,PIPE|
80|----+----+----+----+----+----| |----+----+----+----+----+----|
81| ,CPYP, , ,DOWN,LCBR, RCBR, P1 , P2 , P3 ,MINS, |
82|----+----+----+----+----+----| |----+----+----+----+----+----|
83| , , , , , , DEL , , P0 ,PDOT, , |
84`----+----+----+----+----+----' `----+----+----+----+----+----'
85```
86
87### Raise
88```
89,----+----+----+----+----+----. ,----+----+----+----+----+----.
90|TILD,EXLM, AT ,HASH,DLR ,PERC, CIRC,AMPR,ASTR,LPRN,RPRN,BSPC|
91|----+----+----+----+----+----| |----+----+----+----+----+----|
92| ,EXLM, AT ,HASH,DLR ,PERC, CIRC,AMPR,ASTR,LPRN,RPRN, |
93|----+----+----+----+----+----| |----+----+----+----+----+----|
94|DEL ,MPRV,MNXT,VOLU,PGUP,UNDS, EQL ,HOME, , , ,BSLS|
95|----+----+----+----+----+----| |----+----+----+----+----+----|
96|MUTE,MSTP,MPLY,VOLD,PGDN,MINS, PLUS,END , , , , |
97|----+----+----+----+----+----| |----+----+----+----+----+----|
98| , , , , , , , , , , , |
99`----+----+----+----+----+----' `----+----+----+----+----+----'
100```
101
102### 3rd function layer
103
104```
105,----+----+----+----+----+----. ,----+----+----+----+----+----.
106|F12 , F1 , F2 , F3 , F4 , F5 , F6 , F7 , F8 , F9 ,F10 ,F11 |
107|----+----+----+----+----+----| |----+----+----+----+----+----|
108| , , , , , , , , , , , |
109|----+----+----+----+----+----| |----+----+----+----+----+----|
110| , , , , , , , , , , , |
111|----+----+----+----+----+----| |----+----+----+----+----+----|
112| , , , , , , , , , , , |
113|----+----+----+----+----+----| |----+----+----+----+----+----|
114| , , , , , , , , , , , |
115`----+----+----+----+----+----' `----+----+----+----+----+----'
116```
diff --git a/keyboards/nyquist/keymaps/hexwire/Underglow Pinouts.md b/keyboards/nyquist/keymaps/hexwire/Underglow Pinouts.md
new file mode 100644
index 000000000..9a7633a52
--- /dev/null
+++ b/keyboards/nyquist/keymaps/hexwire/Underglow Pinouts.md
@@ -0,0 +1,20 @@
1# Let's Split RGB Underglow
2
3## Master
4
5### Pro Micro
6- Red: LED +5V -> Pro Micro VCC
7- Green: LED Din -> Pro Micro TX0
8- Black: LED GND -> Pro Micro GND
9
10### TRRS
11- Red: LED +5V -> PCB VCC
12- Green: LED Do -> PCB Extra Data
13- Black: LED GND -> PCB GND
14
15## Slave
16
17### TRRS
18- Red: LED +5V -> PCB VCC
19- Green: LED Din -> PCB Extra Data
20- Black: LED GND -> PCB GND
diff --git a/keyboards/nyquist/keymaps/hexwire/config.h b/keyboards/nyquist/keymaps/hexwire/config.h
new file mode 100644
index 000000000..9da7ff6b6
--- /dev/null
+++ b/keyboards/nyquist/keymaps/hexwire/config.h
@@ -0,0 +1,31 @@
1/*
2Copyright 2017 Danny Nguyen <danny@hexwire.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#define USE_SERIAL
19
20#define TAPPING_TERM 150
21
22#ifdef SUBPROJECT_rev1
23 #include "../../rev1/config.h"
24#endif
25
26#undef RGBLED_NUM
27#define RGBLIGHT_ANIMATIONS
28#define RGBLED_NUM 8
29#define RGBLIGHT_HUE_STEP 8
30#define RGBLIGHT_SAT_STEP 8
31#define RGBLIGHT_VAL_STEP 8
diff --git a/keyboards/nyquist/keymaps/hexwire/keymap.c b/keyboards/nyquist/keymaps/hexwire/keymap.c
new file mode 100644
index 000000000..803d257a9
--- /dev/null
+++ b/keyboards/nyquist/keymaps/hexwire/keymap.c
@@ -0,0 +1,218 @@
1#include "nyquist.h"
2#include "action_layer.h"
3#include "eeconfig.h"
4
5extern keymap_config_t keymap_config;
6
7#define _QWERTY 0
8#define _COLEMAK 1
9#define _DVORAK 2
10#define _LOWER 3
11#define _RAISE 4
12#define _FN3 5
13#define _FN4 6
14#define _ADJUST 16
15
16enum custom_keycodes {
17 QWERTY = SAFE_RANGE,
18 COLEMAK,
19 DVORAK,
20 LOWER,
21 RAISE,
22 FN3,
23 FN4,
24 ADJUST,
25};
26
27#define KC_ KC_TRNS
28#define _______ KC_TRNS
29
30#define KC_CAPW LGUI(LSFT(KC_3)) // Capture whole screen
31#define KC_CPYW LGUI(LSFT(LCTL(KC_3))) // Copy whole screen
32#define KC_CAPP LGUI(LSFT(KC_4)) // Capture portion of screen
33#define KC_CPYP LGUI(LSFT(LCTL(KC_4))) // Copy portion of screen
34#define KC_X0 MT(MOD_LCTL, KC_ESC)
35#define KC_X1 LOWER
36#define KC_X2 RAISE
37#define KC_X3 LT(_FN3, KC_GRV)
38#define KC_X4 MT(MOD_LSFT, KC_ENT)
39
40const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
41
42 [_QWERTY] = KC_KEYMAP(
43 //,----+----+----+----+----+----. ,----+----+----+----+----+----.
44 ESC , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
45 //|----+----+----+----+----+----| |----+----+----+----+----+----|
46 TAB , Q , W , E , R , T , Y , U , I , O , P ,MINS,
47 //|----+----+----+----+----+----| |----+----+----+----+----+----|
48 X0 , A , S , D , F , G , H , J , K , L ,SCLN,QUOT,
49 //|----+----+----+----+----+----| |----+----+----+----+----+----|
50 LSFT, Z , X , C , V , B , N , M ,COMM,DOT ,SLSH, X4 ,
51 //|----+----+----+----+----+----| |----+----+----+----+----+----|
52 X3 ,LCTL,LALT,LGUI, X1 ,SPC , BSPC, X2 ,LEFT,DOWN, UP ,RGHT
53 //`----+----+----+----+----+----' `----+----+----+----+----+----'
54 ),
55
56 [_COLEMAK] = KC_KEYMAP(
57 //,----+----+----+----+----+----. ,----+----+----+----+----+----.
58 ESC , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
59 //|----+----+----+----+----+----| |----+----+----+----+----+----|
60 TAB , Q , W , F , P , G , J , L , U , Y ,SCLN,MINS,
61 //|----+----+----+----+----+----| |----+----+----+----+----+----|
62 X0 , A , R , S , T , D , H , N , E , I , O ,QUOT,
63 //|----+----+----+----+----+----| |----+----+----+----+----+----|
64 LSFT, Z , X , C , V , B , K , M ,COMM,DOT ,SLSH, X4 ,
65 //|----+----+----+----+----+----| |----+----+----+----+----+----|
66 X3 ,LCTL,LALT,LGUI, X1 ,SPC , BSPC, X2 ,LEFT,DOWN, UP ,RGHT
67 //`----+----+----+----+----+----' `----+----+----+----+----+----'
68 ),
69
70 [_DVORAK] = KC_KEYMAP(
71 //,----+----+----+----+----+----. ,----+----+----+----+----+----.
72 ESC , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
73 //|----+----+----+----+----+----| |----+----+----+----+----+----|
74 TAB ,QUOT,COMM,DOT , P , Y , F , G , C , R , L ,MINS,
75 //|----+----+----+----+----+----| |----+----+----+----+----+----|
76 X0 , A , O , E , U , I , D , H , T , N , S ,SLSH,
77 //|----+----+----+----+----+----| |----+----+----+----+----+----|
78 LSFT,SCLN, Q , J , K , X , B , M , W , V , Z , X4 ,
79 //|----+----+----+----+----+----| |----+----+----+----+----+----|
80 X3 ,LCTL,LALT,LGUI, X1 ,SPC , BSPC, X2 ,LEFT,DOWN, UP ,RGHT
81 //`----+----+----+----+----+----' `----+----+----+----+----+----'
82 ),
83
84 [_LOWER] = KC_KEYMAP(
85 //,----+----+----+----+----+----. ,----+----+----+----+----+----.
86 TILD,EXLM, AT ,HASH,DLR ,PERC, CIRC,AMPR,ASTR,LPRN,RPRN,BSPC,
87 //|----+----+----+----+----+----| |----+----+----+----+----+----|
88 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 , ,
89 //|----+----+----+----+----+----| |----+----+----+----+----+----|
90 DEL ,CAPP,LEFT,RGHT, UP ,LBRC, RBRC, P4 , P5 , P6 ,PLUS,PIPE,
91 //|----+----+----+----+----+----| |----+----+----+----+----+----|
92 ,CPYP, , ,DOWN,LCBR, RCBR, P1 , P2 , P3 ,MINS, ,
93 //|----+----+----+----+----+----| |----+----+----+----+----+----|
94 , , , , , , DEL , , P0 ,PDOT, ,
95 //`----+----+----+----+----+----' `----+----+----+----+----+----'
96 ),
97
98 [_RAISE] = KC_KEYMAP(
99 //,----+----+----+----+----+----. ,----+----+----+----+----+----.
100 TILD,EXLM, AT ,HASH,DLR ,PERC, CIRC,AMPR,ASTR,LPRN,RPRN,BSPC,
101 //|----+----+----+----+----+----| |----+----+----+----+----+----|
102 ,EXLM, AT ,HASH,DLR ,PERC, CIRC,AMPR,ASTR,LPRN,RPRN, ,
103 //|----+----+----+----+----+----| |----+----+----+----+----+----|
104 DEL ,MPRV,MNXT,VOLU,PGUP,UNDS, EQL ,HOME, , , ,BSLS,
105 //|----+----+----+----+----+----| |----+----+----+----+----+----|
106 MUTE,MSTP,MPLY,VOLD,PGDN,MINS, PLUS,END , , , , ,
107 //|----+----+----+----+----+----| |----+----+----+----+----+----|
108 , , , , , , , , , , ,
109 //`----+----+----+----+----+----' `----+----+----+----+----+----'
110 ),
111
112 [_FN3] = KC_KEYMAP(
113 //,----+----+----+----+----+----. ,----+----+----+----+----+----.
114 F12 , F1 , F2 , F3 , F4 , F5 , F6 , F7 , F8 , F9 ,F10 ,F11 ,
115 //|----+----+----+----+----+----| |----+----+----+----+----+----|
116 , , , , , , , , , , , ,
117 //|----+----+----+----+----+----| |----+----+----+----+----+----|
118 , , , , , , , , , , , ,
119 //|----+----+----+----+----+----| |----+----+----+----+----+----|
120 , , , , , , , , , , , ,
121 //|----+----+----+----+----+----| |----+----+----+----+----+----|
122 , , , , , , , , , , ,
123 //`----+----+----+----+----+----' `----+----+----+----+----+----'
124 ),
125
126/* Adjust (Lower + Raise)
127 * ,-----------------------------------------------------------------------------------.
128 * | | Reset|RGB Tg|RGB Md|Hue Up|Hue Dn|Sat Up|Sat Dn|Val Up|Val Dn| | |
129 * |------+------+------+------+------+-------------+------+------+------+------+------|
130 * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak| | |
131 * |------+------+------+------+------+------|------+------+------+------+------+------|
132 * | | | | | | | | | | | | |
133 * |------+------+------+------+------+------+------+------+------+------+------+------|
134 * | | | | | | | | | | | |
135 * `-----------------------------------------------------------------------------------'
136 */
137 [_ADJUST] = KEYMAP( \
138 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
139 _______, RESET , RGB_TOG, RGB_MOD, RGB_HUD, RGB_HUI, RGB_SAD, RGB_SAI, RGB_VAD, RGB_VAI, _______, _______, \
140 _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \
141 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
142 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
143 )
144
145
146};
147
148#ifdef AUDIO_ENABLE
149float tone_qwerty[][2] = SONG(QWERTY_SOUND);
150float tone_dvorak[][2] = SONG(DVORAK_SOUND);
151float tone_colemak[][2] = SONG(COLEMAK_SOUND);
152#endif
153
154void persistent_default_layer_set(uint16_t default_layer) {
155 eeconfig_update_default_layer(default_layer);
156 default_layer_set(default_layer);
157}
158
159bool process_record_user(uint16_t keycode, keyrecord_t *record) {
160 switch (keycode) {
161 case QWERTY:
162 if (record->event.pressed) {
163 #ifdef AUDIO_ENABLE
164 PLAY_NOTE_ARRAY(tone_qwerty, false, 0);
165 #endif
166 persistent_default_layer_set(1UL<<_QWERTY);
167 }
168 return false;
169 break;
170 case COLEMAK:
171 if (record->event.pressed) {
172 #ifdef AUDIO_ENABLE
173 PLAY_NOTE_ARRAY(tone_colemak, false, 0);
174 #endif
175 persistent_default_layer_set(1UL<<_COLEMAK);
176 }
177 return false;
178 break;
179 case DVORAK:
180 if (record->event.pressed) {
181 #ifdef AUDIO_ENABLE
182 PLAY_NOTE_ARRAY(tone_dvorak, false, 0);
183 #endif
184 persistent_default_layer_set(1UL<<_DVORAK);
185 }
186 return false;
187 break;
188 case LOWER:
189 if (record->event.pressed) {
190 layer_on(_LOWER);
191 update_tri_layer(_LOWER, _RAISE, _ADJUST);
192 } else {
193 layer_off(_LOWER);
194 update_tri_layer(_LOWER, _RAISE, _ADJUST);
195 }
196 return false;
197 break;
198 case RAISE:
199 if (record->event.pressed) {
200 layer_on(_RAISE);
201 update_tri_layer(_LOWER, _RAISE, _ADJUST);
202 } else {
203 layer_off(_RAISE);
204 update_tri_layer(_LOWER, _RAISE, _ADJUST);
205 }
206 return false;
207 break;
208 case ADJUST:
209 if (record->event.pressed) {
210 layer_on(_ADJUST);
211 } else {
212 layer_off(_ADJUST);
213 }
214 return false;
215 break;
216 }
217 return true;
218}
diff --git a/keyboards/nyquist/keymaps/hexwire/keymap_converter.py b/keyboards/nyquist/keymaps/hexwire/keymap_converter.py
new file mode 100755
index 000000000..683f64da4
--- /dev/null
+++ b/keyboards/nyquist/keymaps/hexwire/keymap_converter.py
@@ -0,0 +1,39 @@
1#!/usr/bin/env python
2
3import re
4
5class KeymapConverter:
6
7 def __init__(self, filename):
8 self.filename = filename
9
10 def read_keymaps(self):
11 with open(self.filename) as f:
12 lines = f.readlines()
13
14 mode = 0
15 for line in lines:
16 line = line[:-1]
17 if mode == 0:
18 if "KC_KEYMAP" in line:
19 matches = re.match(r'.*\[(.*)\] = .*', line)
20 if matches:
21 layer_name = matches.group(1)
22 layer_name = layer_name[1:].capitalize()
23 print '###', layer_name
24 print '```'
25 mode = 1
26 elif mode == 1:
27 if "//" in line:
28 print line[4:]
29 elif ")" in line:
30 mode = 0
31 print '```'
32 print
33 elif line[-1] == ',':
34 print "|" + line[5:-1] + "|"
35 else:
36 print "|" + line[5:] + "|"
37
38converter = KeymapConverter('keymap.c')
39converter.read_keymaps()
diff --git a/keyboards/nyquist/keymaps/hexwire/keymap_to_readme.rb b/keyboards/nyquist/keymaps/hexwire/keymap_to_readme.rb
new file mode 100755
index 000000000..7285b008a
--- /dev/null
+++ b/keyboards/nyquist/keymaps/hexwire/keymap_to_readme.rb
@@ -0,0 +1,40 @@
1#!/usr/bin/env ruby
2
3class KeymapConverter
4
5 def initialize(filename)
6 @filename = filename
7 @mode = :search
8 end
9
10 def read_keymaps
11 lines = IO.readlines(@filename)
12 lines.each { |line| parse_line line[0..-2] }
13 end
14
15 def parse_line(line)
16 case @mode
17 when :search
18 if line =~ /KC_KEYMAP/
19 puts "### #{line}"
20 puts "```"
21 @mode = :parse
22 end
23 when :parse
24 if line =~ /\)/
25 @mode = :search
26 puts "```\n\n"
27 else
28 line = line[4..-1]
29 line.sub!(/(,)^-/m, "|")
30 line.sub!(/( {4})/, " |")
31
32 puts line
33 end
34 end
35 end
36
37end
38
39converter = KeymapConverter.new('keymap.c')
40converter.read_keymaps
diff --git a/keyboards/nyquist/keymaps/i2c/config.h b/keyboards/nyquist/keymaps/i2c/config.h
new file mode 100644
index 000000000..dc279f6e6
--- /dev/null
+++ b/keyboards/nyquist/keymaps/i2c/config.h
@@ -0,0 +1,26 @@
1/*
2Copyright 2017 Danny Nguyen <danny@hexwire.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#define USE_I2C
19
20#define MASTER_LEFT
21// #define _MASTER_RIGHT
22// #define EE_HANDS
23
24#ifdef SUBPROJECT_rev1
25 #include "../../rev1/config.h"
26#endif
diff --git a/keyboards/nyquist/keymaps/i2c/keymap.c b/keyboards/nyquist/keymaps/i2c/keymap.c
new file mode 100644
index 000000000..aa4b6800c
--- /dev/null
+++ b/keyboards/nyquist/keymaps/i2c/keymap.c
@@ -0,0 +1,231 @@
1#include "nyquist.h"
2#include "action_layer.h"
3#include "eeconfig.h"
4
5extern 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#define _COLEMAK 1
13#define _DVORAK 2
14#define _LOWER 3
15#define _RAISE 4
16#define _ADJUST 16
17
18enum custom_keycodes {
19 QWERTY = SAFE_RANGE,
20 COLEMAK,
21 DVORAK,
22 LOWER,
23 RAISE,
24 ADJUST,
25};
26
27// Fillers to make layering more clear
28#define _______ KC_TRNS
29#define XXXXXXX KC_NO
30
31const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
32
33/* Qwerty
34 * ,-----------------------------------------------------------------------------------.
35 * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
36 * |------+------+------+------+------+------+------+------+------+------+------+------|
37 * | Tab | Q | W | E | R | T | Y | U | I | O | P | Del |
38 * |------+------+------+------+------+-------------+------+------+------+------+------|
39 * | Esc | A | S | D | F | G | H | J | K | L | ; | " |
40 * |------+------+------+------+------+------|------+------+------+------+------+------|
41 * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
42 * |------+------+------+------+------+------+------+------+------+------+------+------|
43 * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
44 * `-----------------------------------------------------------------------------------'
45 */
46[_QWERTY] = KEYMAP( \
47 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
48 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_DEL, \
49 KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
50 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
51 ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
52),
53
54/* Colemak
55 * ,-----------------------------------------------------------------------------------.
56 * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
57 * |------+------+------+------+------+------+------+------+------+------+------+------|
58 * | Tab | Q | W | F | P | G | J | L | U | Y | ; | Del |
59 * |------+------+------+------+------+-------------+------+------+------+------+------|
60 * | Esc | A | R | S | T | D | H | N | E | I | O | " |
61 * |------+------+------+------+------+------|------+------+------+------+------+------|
62 * | Shift| Z | X | C | V | B | K | M | , | . | / |Enter |
63 * |------+------+------+------+------+------+------+------+------+------+------+------|
64 * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
65 * `-----------------------------------------------------------------------------------'
66 */
67[_COLEMAK] = KEYMAP( \
68 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
69 KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_DEL, \
70 KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \
71 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
72 ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
73),
74
75/* Dvorak
76 * ,-----------------------------------------------------------------------------------.
77 * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
78 * |------+------+------+------+------+------+------+------+------+------+------+------|
79 * | Tab | " | , | . | P | Y | F | G | C | R | L | Del |
80 * |------+------+------+------+------+-------------+------+------+------+------+------|
81 * | Esc | A | O | E | U | I | D | H | T | N | S | / |
82 * |------+------+------+------+------+------|------+------+------+------+------+------|
83 * | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter |
84 * |------+------+------+------+------+------+------+------+------+------+------+------|
85 * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
86 * `-----------------------------------------------------------------------------------'
87 */
88[_DVORAK] = KEYMAP( \
89 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
90 KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_DEL, \
91 KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \
92 KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \
93 ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
94),
95
96/* Lower
97 * ,-----------------------------------------------------------------------------------.
98 * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
99 * |------+------+------+------+------+-------------+------+------+------+------+------|
100 * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Del |
101 * |------+------+------+------+------+-------------+------+------+------+------+------|
102 * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | | \ | | |
103 * |------+------+------+------+------+------|------+------+------+------+------+------|
104 * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter |
105 * |------+------+------+------+------+------+------+------+------+------+------+------|
106 * | | | | | | | | Next | Vol- | Vol+ | Play |
107 * `-----------------------------------------------------------------------------------'
108 */
109[_LOWER] = KEYMAP( \
110 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \
111 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL, \
112 KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
113 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______, \
114 _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
115),
116
117/* Raise
118 * ,-----------------------------------------------------------------------------------.
119 * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
120 * |------+------+------+------+------+-------------+------+------+------+------+------|
121 * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Del |
122 * |------+------+------+------+------+-------------+------+------+------+------+------|
123 * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ |
124 * |------+------+------+------+------+------|------+------+------+------+------+------|
125 * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Enter |
126 * |------+------+------+------+------+------+------+------+------+------+------+------|
127 * | | | | | | | | Next | Vol- | Vol+ | Play |
128 * `-----------------------------------------------------------------------------------'
129 */
130[_RAISE] = KEYMAP( \
131 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
132 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
133 KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
134 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______, \
135 _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
136),
137
138/* Adjust (Lower + Raise)
139 * ,-----------------------------------------------------------------------------------.
140 * | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 |
141 * |------+------+------+------+------+------+------+------+------+------+------+------|
142 * | | Reset| | | | | | | | | | Del |
143 * |------+------+------+------+------+-------------+------+------+------+------+------|
144 * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak| | |
145 * |------+------+------+------+------+------|------+------+------+------+------+------|
146 * | | | | | | | | | | | | |
147 * |------+------+------+------+------+------+------+------+------+------+------+------|
148 * | | | | | | | | | | | |
149 * `-----------------------------------------------------------------------------------'
150 */
151[_ADJUST] = KEYMAP( \
152 KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
153 _______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \
154 _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \
155 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
156 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
157)
158
159};
160
161#ifdef AUDIO_ENABLE
162float tone_qwerty[][2] = SONG(QWERTY_SOUND);
163float tone_dvorak[][2] = SONG(DVORAK_SOUND);
164float tone_colemak[][2] = SONG(COLEMAK_SOUND);
165#endif
166
167void persistent_default_layer_set(uint16_t default_layer) {
168 eeconfig_update_default_layer(default_layer);
169 default_layer_set(default_layer);
170}
171
172bool process_record_user(uint16_t keycode, keyrecord_t *record) {
173 switch (keycode) {
174 case QWERTY:
175 if (record->event.pressed) {
176 #ifdef AUDIO_ENABLE
177 PLAY_NOTE_ARRAY(tone_qwerty, false, 0);
178 #endif
179 persistent_default_layer_set(1UL<<_QWERTY);
180 }
181 return false;
182 break;
183 case COLEMAK:
184 if (record->event.pressed) {
185 #ifdef AUDIO_ENABLE
186 PLAY_NOTE_ARRAY(tone_colemak, false, 0);
187 #endif
188 persistent_default_layer_set(1UL<<_COLEMAK);
189 }
190 return false;
191 break;
192 case DVORAK:
193 if (record->event.pressed) {
194 #ifdef AUDIO_ENABLE
195 PLAY_NOTE_ARRAY(tone_dvorak, false, 0);
196 #endif
197 persistent_default_layer_set(1UL<<_DVORAK);
198 }
199 return false;
200 break;
201 case LOWER:
202 if (record->event.pressed) {
203 layer_on(_LOWER);
204 update_tri_layer(_LOWER, _RAISE, _ADJUST);
205 } else {
206 layer_off(_LOWER);
207 update_tri_layer(_LOWER, _RAISE, _ADJUST);
208 }
209 return false;
210 break;
211 case RAISE:
212 if (record->event.pressed) {
213 layer_on(_RAISE);
214 update_tri_layer(_LOWER, _RAISE, _ADJUST);
215 } else {
216 layer_off(_RAISE);
217 update_tri_layer(_LOWER, _RAISE, _ADJUST);
218 }
219 return false;
220 break;
221 case ADJUST:
222 if (record->event.pressed) {
223 layer_on(_ADJUST);
224 } else {
225 layer_off(_ADJUST);
226 }
227 return false;
228 break;
229 }
230 return true;
231} \ No newline at end of file
diff --git a/keyboards/nyquist/keymaps/serial/config.h b/keyboards/nyquist/keymaps/serial/config.h
new file mode 100644
index 000000000..ff79b6fb9
--- /dev/null
+++ b/keyboards/nyquist/keymaps/serial/config.h
@@ -0,0 +1,26 @@
1/*
2Copyright 2017 Danny Nguyen <danny@hexwire.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#define USE_SERIAL
19
20#define MASTER_LEFT
21// #define _MASTER_RIGHT
22// #define EE_HANDS
23
24#ifdef SUBPROJECT_rev1
25 #include "../../rev1/config.h"
26#endif
diff --git a/keyboards/nyquist/keymaps/serial/keymap.c b/keyboards/nyquist/keymaps/serial/keymap.c
new file mode 100644
index 000000000..dcb68a6e0
--- /dev/null
+++ b/keyboards/nyquist/keymaps/serial/keymap.c
@@ -0,0 +1,232 @@
1#include "nyquist.h"
2#include "action_layer.h"
3#include "eeconfig.h"
4
5extern 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#define _COLEMAK 1
13#define _DVORAK 2
14#define _LOWER 3
15#define _RAISE 4
16#define _ADJUST 16
17
18enum custom_keycodes {
19 QWERTY = SAFE_RANGE,
20 COLEMAK,
21 DVORAK,
22 LOWER,
23 RAISE,
24 ADJUST,
25};
26
27// Fillers to make layering more clear
28#define _______ KC_TRNS
29#define XXXXXXX KC_NO
30
31const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
32
33/* Qwerty
34 * ,-----------------------------------------------------------------------------------.
35 * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
36 * |------+------+------+------+------+------+------+------+------+------+------+------|
37 * | Tab | Q | W | E | R | T | Y | U | I | O | P | Del |
38 * |------+------+------+------+------+-------------+------+------+------+------+------|
39 * | Esc | A | S | D | F | G | H | J | K | L | ; | " |
40 * |------+------+------+------+------+------|------+------+------+------+------+------|
41 * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
42 * |------+------+------+------+------+------+------+------+------+------+------+------|
43 * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
44 * `-----------------------------------------------------------------------------------'
45 */
46[_QWERTY] = KEYMAP( \
47 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
48 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_DEL, \
49 KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
50 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
51 ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
52),
53
54/* Colemak
55 * ,-----------------------------------------------------------------------------------.
56 * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
57 * |------+------+------+------+------+------+------+------+------+------+------+------|
58 * | Tab | Q | W | F | P | G | J | L | U | Y | ; | Del |
59 * |------+------+------+------+------+-------------+------+------+------+------+------|
60 * | Esc | A | R | S | T | D | H | N | E | I | O | " |
61 * |------+------+------+------+------+------|------+------+------+------+------+------|
62 * | Shift| Z | X | C | V | B | K | M | , | . | / |Enter |
63 * |------+------+------+------+------+------+------+------+------+------+------+------|
64 * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
65 * `-----------------------------------------------------------------------------------'
66 */
67[_COLEMAK] = KEYMAP( \
68 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
69 KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_DEL, \
70 KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \
71 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
72 ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
73),
74
75/* Dvorak
76 * ,-----------------------------------------------------------------------------------.
77 * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
78 * |------+------+------+------+------+------+------+------+------+------+------+------|
79 * | Tab | " | , | . | P | Y | F | G | C | R | L | Del |
80 * |------+------+------+------+------+-------------+------+------+------+------+------|
81 * | Esc | A | O | E | U | I | D | H | T | N | S | / |
82 * |------+------+------+------+------+------|------+------+------+------+------+------|
83 * | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter |
84 * |------+------+------+------+------+------+------+------+------+------+------+------|
85 * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
86 * `-----------------------------------------------------------------------------------'
87 */
88[_DVORAK] = KEYMAP( \
89 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
90 KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_DEL, \
91 KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \
92 KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \
93 ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
94),
95
96/* Lower
97 * ,-----------------------------------------------------------------------------------.
98 * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
99 * |------+------+------+------+------+-------------+------+------+------+------+------|
100 * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Del |
101 * |------+------+------+------+------+-------------+------+------+------+------+------|
102 * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | | \ | | |
103 * |------+------+------+------+------+------|------+------+------+------+------+------|
104 * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter |
105 * |------+------+------+------+------+------+------+------+------+------+------+------|
106 * | | | | | | | | Next | Vol- | Vol+ | Play |
107 * `-----------------------------------------------------------------------------------'
108 */
109[_LOWER] = KEYMAP( \
110 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \
111 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL, \
112 KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
113 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______, \
114 _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
115),
116
117/* Raise
118 * ,-----------------------------------------------------------------------------------.
119 * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
120 * |------+------+------+------+------+-------------+------+------+------+------+------|
121 * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Del |
122 * |------+------+------+------+------+-------------+------+------+------+------+------|
123 * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ |
124 * |------+------+------+------+------+------|------+------+------+------+------+------|
125 * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Enter |
126 * |------+------+------+------+------+------+------+------+------+------+------+------|
127 * | | | | | | | | Next | Vol- | Vol+ | Play |
128 * `-----------------------------------------------------------------------------------'
129 */
130[_RAISE] = KEYMAP( \
131 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
132 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
133 KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
134 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______, \
135 _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
136),
137
138/* Adjust (Lower + Raise)
139 * ,-----------------------------------------------------------------------------------.
140 * | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 |
141 * |------+------+------+------+------+------+------+------+------+------+------+------|
142 * | | Reset| | | | | | | | | | Del |
143 * |------+------+------+------+------+-------------+------+------+------+------+------|
144 * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak| | |
145 * |------+------+------+------+------+------|------+------+------+------+------+------|
146 * | | | | | | | | | | | | |
147 * |------+------+------+------+------+------+------+------+------+------+------+------|
148 * | | | | | | | | | | | |
149 * `-----------------------------------------------------------------------------------'
150 */
151[_ADJUST] = KEYMAP( \
152 KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
153 _______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \
154 _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \
155 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
156 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
157)
158
159
160};
161
162#ifdef AUDIO_ENABLE
163float tone_qwerty[][2] = SONG(QWERTY_SOUND);
164float tone_dvorak[][2] = SONG(DVORAK_SOUND);
165float tone_colemak[][2] = SONG(COLEMAK_SOUND);
166#endif
167
168void persistent_default_layer_set(uint16_t default_layer) {
169 eeconfig_update_default_layer(default_layer);
170 default_layer_set(default_layer);
171}
172
173bool process_record_user(uint16_t keycode, keyrecord_t *record) {
174 switch (keycode) {
175 case QWERTY:
176 if (record->event.pressed) {
177 #ifdef AUDIO_ENABLE
178 PLAY_NOTE_ARRAY(tone_qwerty, false, 0);
179 #endif
180 persistent_default_layer_set(1UL<<_QWERTY);
181 }
182 return false;
183 break;
184 case COLEMAK:
185 if (record->event.pressed) {
186 #ifdef AUDIO_ENABLE
187 PLAY_NOTE_ARRAY(tone_colemak, false, 0);
188 #endif
189 persistent_default_layer_set(1UL<<_COLEMAK);
190 }
191 return false;
192 break;
193 case DVORAK:
194 if (record->event.pressed) {
195 #ifdef AUDIO_ENABLE
196 PLAY_NOTE_ARRAY(tone_dvorak, false, 0);
197 #endif
198 persistent_default_layer_set(1UL<<_DVORAK);
199 }
200 return false;
201 break;
202 case LOWER:
203 if (record->event.pressed) {
204 layer_on(_LOWER);
205 update_tri_layer(_LOWER, _RAISE, _ADJUST);
206 } else {
207 layer_off(_LOWER);
208 update_tri_layer(_LOWER, _RAISE, _ADJUST);
209 }
210 return false;
211 break;
212 case RAISE:
213 if (record->event.pressed) {
214 layer_on(_RAISE);
215 update_tri_layer(_LOWER, _RAISE, _ADJUST);
216 } else {
217 layer_off(_RAISE);
218 update_tri_layer(_LOWER, _RAISE, _ADJUST);
219 }
220 return false;
221 break;
222 case ADJUST:
223 if (record->event.pressed) {
224 layer_on(_ADJUST);
225 } else {
226 layer_off(_ADJUST);
227 }
228 return false;
229 break;
230 }
231 return true;
232} \ No newline at end of file
diff --git a/keyboards/nyquist/matrix.c b/keyboards/nyquist/matrix.c
new file mode 100644
index 000000000..dcb94c67c
--- /dev/null
+++ b/keyboards/nyquist/matrix.c
@@ -0,0 +1,316 @@
1/*
2Copyright 2017 Danny Nguyen <danny@hexwire.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_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;
50
51static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
52static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
53
54/* matrix state(1:on, 0:off) */
55static matrix_row_t matrix[MATRIX_ROWS];
56static matrix_row_t matrix_debouncing[MATRIX_ROWS];
57
58static matrix_row_t read_cols(void);
59static void init_cols(void);
60static void unselect_rows(void);
61static void select_row(uint8_t row);
62
63__attribute__ ((weak))
64void matrix_init_quantum(void) {
65 matrix_init_kb();
66}
67
68__attribute__ ((weak))
69void matrix_scan_quantum(void) {
70 matrix_scan_kb();
71}
72
73__attribute__ ((weak))
74void matrix_init_kb(void) {
75 matrix_init_user();
76}
77
78__attribute__ ((weak))
79void matrix_scan_kb(void) {
80 matrix_scan_user();
81}
82
83__attribute__ ((weak))
84void matrix_init_user(void) {
85}
86
87__attribute__ ((weak))
88void matrix_scan_user(void) {
89}
90
91inline
92uint8_t matrix_rows(void)
93{
94 return MATRIX_ROWS;
95}
96
97inline
98uint8_t matrix_cols(void)
99{
100 return MATRIX_COLS;
101}
102
103void matrix_init(void)
104{
105 debug_enable = true;
106 debug_matrix = true;
107 debug_mouse = true;
108 // initialize row and col
109 unselect_rows();
110 init_cols();
111
112 TX_RX_LED_INIT;
113
114 // initialize matrix state: all keys off
115 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
116 matrix[i] = 0;
117 matrix_debouncing[i] = 0;
118 }
119
120 matrix_init_quantum();
121}
122
123uint8_t _matrix_scan(void)
124{
125 // Right hand is stored after the left in the matirx so, we need to offset it
126 int offset = isLeftHand ? 0 : (ROWS_PER_HAND);
127
128 for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
129 select_row(i);
130 _delay_us(30); // without this wait read unstable value.
131 matrix_row_t cols = read_cols();
132 if (matrix_debouncing[i+offset] != cols) {
133 matrix_debouncing[i+offset] = cols;
134 debouncing = DEBOUNCE;
135 }
136 unselect_rows();
137 }
138
139 if (debouncing) {
140 if (--debouncing) {
141 _delay_ms(1);
142 } else {
143 for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
144 matrix[i+offset] = matrix_debouncing[i+offset];
145 }
146 }
147 }
148
149 return 1;
150}
151
152#ifdef USE_I2C
153
154// Get rows from other half over i2c
155int i2c_transaction(void) {
156 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
157
158 int err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE);
159 if (err) goto i2c_error;
160
161 // start of matrix stored at 0x00
162 err = i2c_master_write(0x00);
163 if (err) goto i2c_error;
164
165 // Start read
166 err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_READ);
167 if (err) goto i2c_error;
168
169 if (!err) {
170 int i;
171 for (i = 0; i < ROWS_PER_HAND-1; ++i) {
172 matrix[slaveOffset+i] = i2c_master_read(I2C_ACK);
173 }
174 matrix[slaveOffset+i] = i2c_master_read(I2C_NACK);
175 i2c_master_stop();
176 } else {
177i2c_error: // the cable is disconnceted, or something else went wrong
178 i2c_reset_state();
179 return err;
180 }
181
182 return 0;
183}
184
185#else // USE_SERIAL
186
187int serial_transaction(void) {
188 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
189
190 if (serial_update_buffers()) {
191 return 1;
192 }
193
194 for (int i = 0; i < ROWS_PER_HAND; ++i) {
195 matrix[slaveOffset+i] = serial_slave_buffer[i];
196 }
197 return 0;
198}
199#endif
200
201uint8_t matrix_scan(void)
202{
203 int ret = _matrix_scan();
204
205
206
207#ifdef USE_I2C
208 if( i2c_transaction() ) {
209#else // USE_SERIAL
210 if( serial_transaction() ) {
211#endif
212 // turn on the indicator led when halves are disconnected
213 TXLED1;
214
215 error_count++;
216
217 if (error_count > ERROR_DISCONNECT_COUNT) {
218 // reset other half if disconnected
219 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
220 for (int i = 0; i < ROWS_PER_HAND; ++i) {
221 matrix[slaveOffset+i] = 0;
222 }
223 }
224 } else {
225 // turn off the indicator led on no error
226 TXLED0;
227 error_count = 0;
228 }
229 matrix_scan_quantum();
230 return ret;
231}
232
233void matrix_slave_scan(void) {
234 _matrix_scan();
235
236 int offset = (isLeftHand) ? 0 : (MATRIX_ROWS / 2);
237
238#ifdef USE_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_slave_buffer[i] = matrix[offset+i];
246 }
247#endif
248}
249
250bool matrix_is_modified(void)
251{
252 if (debouncing) return false;
253 return true;
254}
255
256inline
257bool matrix_is_on(uint8_t row, uint8_t col)
258{
259 return (matrix[row] & ((matrix_row_t)1<<col));
260}
261
262inline
263matrix_row_t matrix_get_row(uint8_t row)
264{
265 return matrix[row];
266}
267
268void matrix_print(void)
269{
270 print("\nr/c 0123456789ABCDEF\n");
271 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
272 phex(row); print(": ");
273 pbin_reverse16(matrix_get_row(row));
274 print("\n");
275 }
276}
277
278uint8_t matrix_key_count(void)
279{
280 uint8_t count = 0;
281 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
282 count += bitpop16(matrix[i]);
283 }
284 return count;
285}
286
287static void init_cols(void)
288{
289 for(int x = 0; x < MATRIX_COLS; x++) {
290 _SFR_IO8((col_pins[x] >> 4) + 1) &= ~_BV(col_pins[x] & 0xF);
291 _SFR_IO8((col_pins[x] >> 4) + 2) |= _BV(col_pins[x] & 0xF);
292 }
293}
294
295static matrix_row_t read_cols(void)
296{
297 matrix_row_t result = 0;
298 for(int x = 0; x < MATRIX_COLS; x++) {
299 result |= (_SFR_IO8(col_pins[x] >> 4) & _BV(col_pins[x] & 0xF)) ? 0 : (1 << x);
300 }
301 return result;
302}
303
304static void unselect_rows(void)
305{
306 for(int x = 0; x < ROWS_PER_HAND; x++) {
307 _SFR_IO8((row_pins[x] >> 4) + 1) &= ~_BV(row_pins[x] & 0xF);
308 _SFR_IO8((row_pins[x] >> 4) + 2) |= _BV(row_pins[x] & 0xF);
309 }
310}
311
312static void select_row(uint8_t row)
313{
314 _SFR_IO8((row_pins[row] >> 4) + 1) |= _BV(row_pins[row] & 0xF);
315 _SFR_IO8((row_pins[row] >> 4) + 2) &= ~_BV(row_pins[row] & 0xF);
316}
diff --git a/keyboards/nyquist/nyquist.c b/keyboards/nyquist/nyquist.c
new file mode 100644
index 000000000..2face09d4
--- /dev/null
+++ b/keyboards/nyquist/nyquist.c
@@ -0,0 +1 @@
#include "nyquist.h"
diff --git a/keyboards/nyquist/nyquist.h b/keyboards/nyquist/nyquist.h
new file mode 100644
index 000000000..e8cccecf5
--- /dev/null
+++ b/keyboards/nyquist/nyquist.h
@@ -0,0 +1,26 @@
1#ifndef NYQUIST_H
2#define NYQUIST_H
3
4#ifdef SUBPROJECT_rev1
5 #include "rev1.h"
6#endif
7
8// Used to create a keymap using only KC_ prefixed keys
9#define KC_KEYMAP( \
10 L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \
11 L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \
12 L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \
13 L30, L31, L32, L33, L34, L35, R30, R31, R32, R33, R34, R35, \
14 L40, L41, L42, L43, L44, L45, R40, R41, R42, R43, R44, R45 \
15 ) \
16 KEYMAP( \
17 KC_##L00, KC_##L01, KC_##L02, KC_##L03, KC_##L04, KC_##L05, KC_##R00, KC_##R01, KC_##R02, KC_##R03, KC_##R04, KC_##R05, \
18 KC_##L10, KC_##L11, KC_##L12, KC_##L13, KC_##L14, KC_##L15, KC_##R10, KC_##R11, KC_##R12, KC_##R13, KC_##R14, KC_##R15, \
19 KC_##L20, KC_##L21, KC_##L22, KC_##L23, KC_##L24, KC_##L25, KC_##R20, KC_##R21, KC_##R22, KC_##R23, KC_##R24, KC_##R25, \
20 KC_##L30, KC_##L31, KC_##L32, KC_##L33, KC_##L34, KC_##L35, KC_##R30, KC_##R31, KC_##R32, KC_##R33, KC_##R34, KC_##R35, \
21 KC_##L40, KC_##L41, KC_##L42, KC_##L43, KC_##L44, KC_##L45, KC_##R40, KC_##R41, KC_##R42, KC_##R43, KC_##R44, KC_##R45 \
22 )
23
24#include "quantum.h"
25
26#endif \ No newline at end of file
diff --git a/keyboards/nyquist/pro_micro.h b/keyboards/nyquist/pro_micro.h
new file mode 100644
index 000000000..f9e7ed75d
--- /dev/null
+++ b/keyboards/nyquist/pro_micro.h
@@ -0,0 +1,362 @@
1/*
2 pins_arduino.h - Pin definition functions for Arduino
3 Part of Arduino - http://www.arduino.cc/
4
5 Copyright (c) 2007 David A. Mellis
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library 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 GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General
18 Public License along with this library; if not, write to the
19 Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20 Boston, MA 02111-1307 USA
21
22 $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
23*/
24
25#ifndef Pins_Arduino_h
26#define Pins_Arduino_h
27
28#include <avr/pgmspace.h>
29
30// Workaround for wrong definitions in "iom32u4.h".
31// This should be fixed in the AVR toolchain.
32#undef UHCON
33#undef UHINT
34#undef UHIEN
35#undef UHADDR
36#undef UHFNUM
37#undef UHFNUML
38#undef UHFNUMH
39#undef UHFLEN
40#undef UPINRQX
41#undef UPINTX
42#undef UPNUM
43#undef UPRST
44#undef UPCONX
45#undef UPCFG0X
46#undef UPCFG1X
47#undef UPSTAX
48#undef UPCFG2X
49#undef UPIENX
50#undef UPDATX
51#undef TCCR2A
52#undef WGM20
53#undef WGM21
54#undef COM2B0
55#undef COM2B1
56#undef COM2A0
57#undef COM2A1
58#undef TCCR2B
59#undef CS20
60#undef CS21
61#undef CS22
62#undef WGM22
63#undef FOC2B
64#undef FOC2A
65#undef TCNT2
66#undef TCNT2_0
67#undef TCNT2_1
68#undef TCNT2_2
69#undef TCNT2_3
70#undef TCNT2_4
71#undef TCNT2_5
72#undef TCNT2_6
73#undef TCNT2_7
74#undef OCR2A
75#undef OCR2_0
76#undef OCR2_1
77#undef OCR2_2
78#undef OCR2_3
79#undef OCR2_4
80#undef OCR2_5
81#undef OCR2_6
82#undef OCR2_7
83#undef OCR2B
84#undef OCR2_0
85#undef OCR2_1
86#undef OCR2_2
87#undef OCR2_3
88#undef OCR2_4
89#undef OCR2_5
90#undef OCR2_6
91#undef OCR2_7
92
93#define NUM_DIGITAL_PINS 30
94#define NUM_ANALOG_INPUTS 12
95
96#define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0)
97#define TXLED0 PORTD |= (1<<5)
98#define TXLED1 PORTD &= ~(1<<5)
99#define RXLED0 PORTB |= (1<<0)
100#define RXLED1 PORTB &= ~(1<<0)
101
102static const uint8_t SDA = 2;
103static const uint8_t SCL = 3;
104#define LED_BUILTIN 13
105
106// Map SPI port to 'new' pins D14..D17
107static const uint8_t SS = 17;
108static const uint8_t MOSI = 16;
109static const uint8_t MISO = 14;
110static const uint8_t SCK = 15;
111
112// Mapping of analog pins as digital I/O
113// A6-A11 share with digital pins
114static const uint8_t ADC0 = 18;
115static const uint8_t ADC1 = 19;
116static const uint8_t ADC2 = 20;
117static const uint8_t ADC3 = 21;
118static const uint8_t ADC4 = 22;
119static const uint8_t ADC5 = 23;
120static const uint8_t ADC6 = 24; // D4
121static const uint8_t ADC7 = 25; // D6
122static const uint8_t ADC8 = 26; // D8
123static const uint8_t ADC9 = 27; // D9
124static const uint8_t ADC10 = 28; // D10
125static const uint8_t ADC11 = 29; // D12
126
127#define digitalPinToPCICR(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0))
128#define digitalPinToPCICRbit(p) 0
129#define digitalPinToPCMSK(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0))
130#define digitalPinToPCMSKbit(p) ( ((p) >= 8 && (p) <= 11) ? (p) - 4 : ((p) == 14 ? 3 : ((p) == 15 ? 1 : ((p) == 16 ? 2 : ((p) == 17 ? 0 : (p - A8 + 4))))))
131
132// __AVR_ATmega32U4__ has an unusual mapping of pins to channels
133extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];
134#define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) )
135
136#define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT)))))
137
138#ifdef ARDUINO_MAIN
139
140// On the Arduino board, digital pins are also used
141// for the analog output (software PWM). Analog input
142// pins are a separate set.
143
144// ATMEL ATMEGA32U4 / ARDUINO LEONARDO
145//
146// D0 PD2 RXD1/INT2
147// D1 PD3 TXD1/INT3
148// D2 PD1 SDA SDA/INT1
149// D3# PD0 PWM8/SCL OC0B/SCL/INT0
150// D4 A6 PD4 ADC8
151// D5# PC6 ??? OC3A/#OC4A
152// D6# A7 PD7 FastPWM #OC4D/ADC10
153// D7 PE6 INT6/AIN0
154//
155// D8 A8 PB4 ADC11/PCINT4
156// D9# A9 PB5 PWM16 OC1A/#OC4B/ADC12/PCINT5
157// D10# A10 PB6 PWM16 OC1B/0c4B/ADC13/PCINT6
158// D11# PB7 PWM8/16 0C0A/OC1C/#RTS/PCINT7
159// D12 A11 PD6 T1/#OC4D/ADC9
160// D13# PC7 PWM10 CLK0/OC4A
161//
162// A0 D18 PF7 ADC7
163// A1 D19 PF6 ADC6
164// A2 D20 PF5 ADC5
165// A3 D21 PF4 ADC4
166// A4 D22 PF1 ADC1
167// A5 D23 PF0 ADC0
168//
169// New pins D14..D17 to map SPI port to digital pins
170//
171// MISO D14 PB3 MISO,PCINT3
172// SCK D15 PB1 SCK,PCINT1
173// MOSI D16 PB2 MOSI,PCINT2
174// SS D17 PB0 RXLED,SS/PCINT0
175//
176// Connected LEDs on board for TX and RX
177// TXLED D24 PD5 XCK1
178// RXLED D17 PB0
179// HWB PE2 HWB
180
181// these arrays map port names (e.g. port B) to the
182// appropriate addresses for various functions (e.g. reading
183// and writing)
184const uint16_t PROGMEM port_to_mode_PGM[] = {
185 NOT_A_PORT,
186 NOT_A_PORT,
187 (uint16_t) &DDRB,
188 (uint16_t) &DDRC,
189 (uint16_t) &DDRD,
190 (uint16_t) &DDRE,
191 (uint16_t) &DDRF,
192};
193
194const uint16_t PROGMEM port_to_output_PGM[] = {
195 NOT_A_PORT,
196 NOT_A_PORT,
197 (uint16_t) &PORTB,
198 (uint16_t) &PORTC,
199 (uint16_t) &PORTD,
200 (uint16_t) &PORTE,
201 (uint16_t) &PORTF,
202};
203
204const uint16_t PROGMEM port_to_input_PGM[] = {
205 NOT_A_PORT,
206 NOT_A_PORT,
207 (uint16_t) &PINB,
208 (uint16_t) &PINC,
209 (uint16_t) &PIND,
210 (uint16_t) &PINE,
211 (uint16_t) &PINF,
212};
213
214const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
215 PD, // D0 - PD2
216 PD, // D1 - PD3
217 PD, // D2 - PD1
218 PD, // D3 - PD0
219 PD, // D4 - PD4
220 PC, // D5 - PC6
221 PD, // D6 - PD7
222 PE, // D7 - PE6
223
224 PB, // D8 - PB4
225 PB, // D9 - PB5
226 PB, // D10 - PB6
227 PB, // D11 - PB7
228 PD, // D12 - PD6
229 PC, // D13 - PC7
230
231 PB, // D14 - MISO - PB3
232 PB, // D15 - SCK - PB1
233 PB, // D16 - MOSI - PB2
234 PB, // D17 - SS - PB0
235
236 PF, // D18 - A0 - PF7
237 PF, // D19 - A1 - PF6
238 PF, // D20 - A2 - PF5
239 PF, // D21 - A3 - PF4
240 PF, // D22 - A4 - PF1
241 PF, // D23 - A5 - PF0
242
243 PD, // D24 - PD5
244 PD, // D25 / D6 - A7 - PD7
245 PB, // D26 / D8 - A8 - PB4
246 PB, // D27 / D9 - A9 - PB5
247 PB, // D28 / D10 - A10 - PB6
248 PD, // D29 / D12 - A11 - PD6
249};
250
251const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
252 _BV(2), // D0 - PD2
253 _BV(3), // D1 - PD3
254 _BV(1), // D2 - PD1
255 _BV(0), // D3 - PD0
256 _BV(4), // D4 - PD4
257 _BV(6), // D5 - PC6
258 _BV(7), // D6 - PD7
259 _BV(6), // D7 - PE6
260
261 _BV(4), // D8 - PB4
262 _BV(5), // D9 - PB5
263 _BV(6), // D10 - PB6
264 _BV(7), // D11 - PB7
265 _BV(6), // D12 - PD6
266 _BV(7), // D13 - PC7
267
268 _BV(3), // D14 - MISO - PB3
269 _BV(1), // D15 - SCK - PB1
270 _BV(2), // D16 - MOSI - PB2
271 _BV(0), // D17 - SS - PB0
272
273 _BV(7), // D18 - A0 - PF7
274 _BV(6), // D19 - A1 - PF6
275 _BV(5), // D20 - A2 - PF5
276 _BV(4), // D21 - A3 - PF4
277 _BV(1), // D22 - A4 - PF1
278 _BV(0), // D23 - A5 - PF0
279
280 _BV(5), // D24 - PD5
281 _BV(7), // D25 / D6 - A7 - PD7
282 _BV(4), // D26 / D8 - A8 - PB4
283 _BV(5), // D27 / D9 - A9 - PB5
284 _BV(6), // D28 / D10 - A10 - PB6
285 _BV(6), // D29 / D12 - A11 - PD6
286};
287
288const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
289 NOT_ON_TIMER,
290 NOT_ON_TIMER,
291 NOT_ON_TIMER,
292 TIMER0B, /* 3 */
293 NOT_ON_TIMER,
294 TIMER3A, /* 5 */
295 TIMER4D, /* 6 */
296 NOT_ON_TIMER,
297
298 NOT_ON_TIMER,
299 TIMER1A, /* 9 */
300 TIMER1B, /* 10 */
301 TIMER0A, /* 11 */
302
303 NOT_ON_TIMER,
304 TIMER4A, /* 13 */
305
306 NOT_ON_TIMER,
307 NOT_ON_TIMER,
308 NOT_ON_TIMER,
309 NOT_ON_TIMER,
310 NOT_ON_TIMER,
311 NOT_ON_TIMER,
312
313 NOT_ON_TIMER,
314 NOT_ON_TIMER,
315 NOT_ON_TIMER,
316 NOT_ON_TIMER,
317 NOT_ON_TIMER,
318 NOT_ON_TIMER,
319 NOT_ON_TIMER,
320 NOT_ON_TIMER,
321 NOT_ON_TIMER,
322 NOT_ON_TIMER,
323};
324
325const uint8_t PROGMEM analog_pin_to_channel_PGM[] = {
326 7, // A0 PF7 ADC7
327 6, // A1 PF6 ADC6
328 5, // A2 PF5 ADC5
329 4, // A3 PF4 ADC4
330 1, // A4 PF1 ADC1
331 0, // A5 PF0 ADC0
332 8, // A6 D4 PD4 ADC8
333 10, // A7 D6 PD7 ADC10
334 11, // A8 D8 PB4 ADC11
335 12, // A9 D9 PB5 ADC12
336 13, // A10 D10 PB6 ADC13
337 9 // A11 D12 PD6 ADC9
338};
339
340#endif /* ARDUINO_MAIN */
341
342// These serial port names are intended to allow libraries and architecture-neutral
343// sketches to automatically default to the correct port name for a particular type
344// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
345// the first hardware serial port whose RX/TX pins are not dedicated to another use.
346//
347// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
348//
349// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
350//
351// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
352//
353// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
354//
355// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
356// pins are NOT connected to anything by default.
357#define SERIAL_PORT_MONITOR Serial
358#define SERIAL_PORT_USBVIRTUAL Serial
359#define SERIAL_PORT_HARDWARE Serial1
360#define SERIAL_PORT_HARDWARE_OPEN Serial1
361
362#endif /* Pins_Arduino_h */
diff --git a/keyboards/nyquist/readme.md b/keyboards/nyquist/readme.md
new file mode 100644
index 000000000..b2bf01389
--- /dev/null
+++ b/keyboards/nyquist/readme.md
@@ -0,0 +1,167 @@
1The Nyquist Keyboard
2====================
3
4The Nyquist is a 60% split ortholinear board by [Keebio](https://keeb.io). It has been designed in a similar manner to the Let's Split v2 by /u/wootpatoot. Each half of the keyboard is arranged in a 5x6 grid. There is an option to use a 2u key with PCB mounted MX stablizers, in place of the two innermost 1u keys on the bottom row.
5
6
7## Build Guide
8
9Since the design is very similar to the Let's Split v2, the build guide for that can be used while the build guide for the Nyquist is being fully developed. A build guide for putting together the Let's Split v2 can be found here: [An Overly Verbose Guide to Building a Let's Split Keyboard](https://github.com/nicinabox/lets-split-guide)
10
11There is additional information there about flashing and adding RGB underglow.
12
13## First Time Setup
14
15Download or clone the whole firmware and navigate to the keyboards/nyquist directory. Once your development environment is setup, you'll be able to generate the default .hex using:
16
17```
18$ make serial
19```
20
21You will see a lot of output and if everything worked correctly you will see the built hex file:
22
23```
24nyquist_rev1_serial.hex
25```
26
27If you would like to use one of the alternative keymaps, or create your own, copy one of the existing [keymaps](keymaps/) and run make like so:
28
29
30```
31$ make YOUR_KEYMAP_NAME
32```
33
34If everything worked correctly you will see a file:
35
36```
37nyquist_rev1_YOUR_KEYMAP_NAME.hex
38```
39
40For more information on customizing keymaps, take a look at the primary documentation for [Customizing Your Keymap](/readme.md##customizing-your-keymap) in the main readme.md.
41
42Features
43--------
44
45For the full Quantum Mechanical Keyboard feature list, see [the parent readme.md](/readme.md).
46
47Some features supported by the firmware:
48
49* Either half can connect to the computer via USB, or both halves can be used
50 independently.
51* You only need 3 wires to connect the two halves. Two for VCC and GND and one
52 for serial communication.
53* Optional support for I2C connection between the two halves if for some
54 reason you require a faster connection between the two halves. Note this
55 requires an extra wire between halves and pull-up resistors on the data lines.
56
57### 2u Support
58In place of the two innermost 1u keys on the bottom row, a single 2u key can be used. If you choose to use this option, then in your keymap, set the innermost key on the bottom row to what you want the 2u key to be. For example, if using the 2u key on the left half of the board, set the keycode for the lower right key.
59
60Required Hardware
61-----------------
62
63Apart from diodes and key switches for the keyboard matrix in each half, you
64will need:
65
66* 2 Arduino Pro Micro's. You can find theses on aliexpress for ≈3.50USD each.
67* 2 TRRS sockets and 1 TRRS cable, or 2 TRS sockets and 1 TRS cable
68
69Alternatively, you can use any sort of cable and socket that has at least 3
70wires. If you want to use I2C to communicate between halves, you will need a
71cable with at least 4 wires and 2x 4.7kΩ pull-up resistors
72
73Optional Hardware
74-----------------
75
76A speaker can be hooked-up to either side to the `5` (`C6`) pin and `GND`, and turned on via `AUDIO_ENABLE`.
77
78Wiring
79------
80
81The 3 wires of the TRS/TRRS cable need to connect GND, VCC, and digital pin 3 (i.e.
82PD0 on the ATmega32u4) between the two Pro Micros.
83
84Then wire your key matrix to any of the remaining 17 IO pins of the pro micro
85and modify the `matrix.c` accordingly.
86
87The wiring for serial:
88
89![serial wiring](imgs/split-keyboard-serial-schematic.png)
90
91The wiring for i2c:
92
93![i2c wiring](imgs/split-keyboard-i2c-schematic.png)
94
95The pull-up resistors may be placed on either half. It is also possible
96to use 4 resistors and have the pull-ups in both halves, but this is
97unnecessary in simple use cases.
98
99Flashing
100-------
101From the keymap directory run `make SUBPROJECT-KEYMAP-avrdude` for automatic serial port resolution and flashing.
102Example: `make rev1-serial-avrdude`
103
104
105Choosing which board to plug the USB cable into (choosing Master)
106--------
107Because the two boards are identical, the firmware has logic to differentiate the left and right board.
108
109It uses two strategies to figure things out: look at the EEPROM (memory on the chip) or looks if the current board has the usb cable.
110
111The EEPROM approach requires additional setup (flashing the eeeprom) but allows you to swap the usb cable to either side.
112
113The USB cable approach is easier to setup and if you just want the usb cable on the left board, you do not need to do anything extra.
114
115### Setting the left hand as master
116If you always plug the usb cable into the left board, nothing extra is needed as this is the default. Comment out `EE_HANDS` and comment out `I2C_MASTER_RIGHT` or `MASTER_RIGHT` if for some reason it was set.
117
118### Setting the right hand as master
119If you always plug the usb cable into the right board, add an extra flag to your `config.h`
120```
121 #define MASTER_RIGHT
122```
123
124### Setting EE_hands to use either hands as master
125If you define `EE_HANDS` in your `config.h`, you will need to set the
126EEPROM for the left and right halves.
127
128The EEPROM is used to store whether the
129half is left handed or right handed. This makes it so that the same firmware
130file will run on both hands instead of having to flash left and right handed
131versions of the firmware to each half. To flash the EEPROM file for the left
132half run:
133```
134avrdude -p atmega32u4 -P $(COM_PORT) -c avr109 -U eeprom:w:eeprom-lefthand.eep
135// or the equivalent in dfu-programmer
136
137```
138and similarly for right half
139```
140avrdude -p atmega32u4 -P $(COM_PORT) -c avr109 -U eeprom:w:eeprom-righhand.eep
141// or the equivalent in dfu-programmer
142```
143
144NOTE: replace `$(COM_PORT)` with the port of your device (e.g. `/dev/ttyACM0`)
145
146After you have flashed the EEPROM, you then need to set `EE_HANDS` in your config.h, rebuild the hex files and reflash.
147
148Note that you need to program both halves, but you have the option of using
149different keymaps for each half. You could program the left half with a QWERTY
150layout and the right half with a Colemak layout using bootmagic's default layout option.
151Then if you connect the left half to a computer by USB the keyboard will use QWERTY and Colemak when the
152right half is connected.
153
154
155Notes on Using Pro Micro 3.3V
156-----------------------------
157
158Do update the `F_CPU` parameter in `rules.mk` to `8000000` which reflects
159the frequency on the 3.3V board.
160
161Also, if the slave board is producing weird characters in certain columns,
162update the following line in `matrix.c` to the following:
163
164```
165// _delay_us(30); // without this wait read unstable value.
166_delay_us(300); // without this wait read unstable value.
167```
diff --git a/keyboards/nyquist/rev1/Makefile b/keyboards/nyquist/rev1/Makefile
new file mode 100644
index 000000000..4e2a6f00f
--- /dev/null
+++ b/keyboards/nyquist/rev1/Makefile
@@ -0,0 +1,3 @@
1ifndef MAKEFILE_INCLUDED
2 include ../../Makefile
3endif \ No newline at end of file
diff --git a/keyboards/nyquist/rev1/config.h b/keyboards/nyquist/rev1/config.h
new file mode 100644
index 000000000..c2907cf5d
--- /dev/null
+++ b/keyboards/nyquist/rev1/config.h
@@ -0,0 +1,89 @@
1/*
2Copyright 2017 Danny Nguyen <danny@hexwire.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#ifndef CONFIG_H
19#define CONFIG_H
20
21#include "config_common.h"
22
23/* USB Device descriptor parameter */
24#define VENDOR_ID 0xCEEB
25#define PRODUCT_ID 0x1156
26#define DEVICE_VER 0x0100
27#define MANUFACTURER Keebio
28#define PRODUCT The Nyquist Keyboard
29#define DESCRIPTION Split 60 percent ortholinear keyboard
30
31/* key matrix size */
32// Rows are doubled-up
33#define MATRIX_ROWS 10
34#define MATRIX_COLS 6
35
36// wiring of each half
37#define MATRIX_ROW_PINS { D4, D7, E6, B4, B5 }
38#define MATRIX_COL_PINS { F6, F7, B1, B3, B2, B6 }
39
40#define CATERINA_BOOTLOADER
41
42/* COL2ROW or ROW2COL */
43#define DIODE_DIRECTION COL2ROW
44
45/* define if matrix has ghost */
46//#define MATRIX_HAS_GHOST
47
48/* number of backlight levels */
49// #define BACKLIGHT_LEVELS 3
50
51/* Set 0 if debouncing isn't needed */
52#define DEBOUNCING_DELAY 5
53
54/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
55#define LOCKING_SUPPORT_ENABLE
56/* Locking resynchronize hack */
57#define LOCKING_RESYNC_ENABLE
58
59/* key combination for command */
60#define IS_COMMAND() ( \
61 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
62)
63
64/* ws2812 RGB LED */
65#define RGB_DI_PIN D3
66#define RGBLIGHT_TIMER
67#define RGBLED_NUM 16 // Number of LEDs
68#define ws2812_PORTREG PORTD
69#define ws2812_DDRREG DDRD
70
71/*
72 * Feature disable options
73 * These options are also useful to firmware size reduction.
74 */
75
76/* disable debug print */
77// #define NO_DEBUG
78
79/* disable print */
80// #define NO_PRINT
81
82/* disable action features */
83//#define NO_ACTION_LAYER
84//#define NO_ACTION_TAPPING
85//#define NO_ACTION_ONESHOT
86//#define NO_ACTION_MACRO
87//#define NO_ACTION_FUNCTION
88
89#endif
diff --git a/keyboards/nyquist/rev1/rev1.c b/keyboards/nyquist/rev1/rev1.c
new file mode 100644
index 000000000..fc984e18c
--- /dev/null
+++ b/keyboards/nyquist/rev1/rev1.c
@@ -0,0 +1,39 @@
1#include "nyquist.h"
2
3#ifdef AUDIO_ENABLE
4 float tone_startup[][2] = SONG(STARTUP_SOUND);
5 float tone_goodbye[][2] = SONG(GOODBYE_SOUND);
6#endif
7
8#ifdef SSD1306OLED
9void led_set_kb(uint8_t usb_led) {
10 // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
11 led_set_user(usb_led);
12}
13#endif
14
15void matrix_init_kb(void) {
16
17 #ifdef AUDIO_ENABLE
18 _delay_ms(20); // gets rid of tick
19 PLAY_NOTE_ARRAY(tone_startup, false, 0);
20 #endif
21
22 // // green led on
23 // DDRD |= (1<<5);
24 // PORTD &= ~(1<<5);
25
26 // // orange led on
27 // DDRB |= (1<<0);
28 // PORTB &= ~(1<<0);
29
30 matrix_init_user();
31};
32
33void shutdown_user(void) {
34 #ifdef AUDIO_ENABLE
35 PLAY_NOTE_ARRAY(tone_goodbye, false, 0);
36 _delay_ms(150);
37 stop_all_notes();
38 #endif
39}
diff --git a/keyboards/nyquist/rev1/rev1.h b/keyboards/nyquist/rev1/rev1.h
new file mode 100644
index 000000000..f2d0ece79
--- /dev/null
+++ b/keyboards/nyquist/rev1/rev1.h
@@ -0,0 +1,66 @@
1#ifndef REV1_H
2#define REV1_H
3
4#include "../nyquist.h"
5
6//void promicro_bootloader_jmp(bool program);
7#include "quantum.h"
8
9
10#ifdef USE_I2C
11#include <stddef.h>
12#ifdef __AVR__
13 #include <avr/io.h>
14 #include <avr/interrupt.h>
15#endif
16#endif
17
18//void promicro_bootloader_jmp(bool program);
19
20#ifndef FLIP_HALF
21// Standard Keymap
22// (TRRS jack on the left half is to the right, TRRS jack on the right half is to the left)
23#define KEYMAP( \
24 L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \
25 L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \
26 L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \
27 L30, L31, L32, L33, L34, L35, R30, R31, R32, R33, R34, R35, \
28 L40, L41, L42, L43, L44, L45, R40, R41, R42, R43, R44, R45 \
29 ) \
30 { \
31 { L00, L01, L02, L03, L04, L05 }, \
32 { L10, L11, L12, L13, L14, L15 }, \
33 { L20, L21, L22, L23, L24, L25 }, \
34 { L30, L31, L32, L33, L34, L35 }, \
35 { L40, L41, L42, L43, L44, L45 }, \
36 { R05, R04, R03, R02, R01, R00 }, \
37 { R15, R14, R13, R12, R11, R10 }, \
38 { R25, R24, R23, R22, R21, R20 }, \
39 { R35, R34, R33, R32, R31, R30 }, \
40 { R45, R44, R43, R42, R41, R40 } \
41 }
42#else
43// Keymap with right side flipped
44// (TRRS jack on both halves are to the right)
45#define KEYMAP( \
46 L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \
47 L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \
48 L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \
49 L30, L31, L32, L33, L34, L35, R30, R31, R32, R33, R34, R35, \
50 L40, L41, L42, L43, L44, L45, R40, R41, R42, R43, R44, R45 \
51 ) \
52 { \
53 { L00, L01, L02, L03, L04, L05 }, \
54 { L10, L11, L12, L13, L14, L15 }, \
55 { L20, L21, L22, L23, L24, L25 }, \
56 { L30, L31, L32, L33, L34, L35 }, \
57 { L40, L41, L42, L43, L44, L45 }, \
58 { R00, R01, R02, R03, R04, R05 }, \
59 { R10, R11, R12, R13, R14, R15 }, \
60 { R20, R21, R22, R23, R24, R25 }, \
61 { R30, R31, R32, R33, R34, R35 }, \
62 { R40, R41, R42, R43, R44, R45 } \
63 }
64#endif
65
66#endif
diff --git a/keyboards/nyquist/rev1/rules.mk b/keyboards/nyquist/rev1/rules.mk
new file mode 100644
index 000000000..80a942d06
--- /dev/null
+++ b/keyboards/nyquist/rev1/rules.mk
@@ -0,0 +1,5 @@
1BACKLIGHT_ENABLE = no
2
3ifndef QUANTUM_DIR
4 include ../../../Makefile
5endif
diff --git a/keyboards/nyquist/rules.mk b/keyboards/nyquist/rules.mk
new file mode 100644
index 000000000..0efa78550
--- /dev/null
+++ b/keyboards/nyquist/rules.mk
@@ -0,0 +1,87 @@
1SRC += matrix.c \
2 i2c.c \
3 split_util.c \
4 serial.c
5
6# MCU name
7#MCU = at90usb1287
8MCU = atmega32u4
9
10# Processor frequency.
11# This will define a symbol, F_CPU, in all source code files equal to the
12# processor frequency in Hz. You can then use this symbol in your source code to
13# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
14# automatically to create a 32-bit value in your source code.
15#
16# This will be an integer division of F_USB below, as it is sourced by
17# F_USB after it has run through any CPU prescalers. Note that this value
18# does not *change* the processor frequency - it should merely be updated to
19# reflect the processor speed set externally so that the code can use accurate
20# software delays.
21F_CPU = 16000000
22
23#
24# LUFA specific
25#
26# Target architecture (see library "Board Types" documentation).
27ARCH = AVR8
28
29# Input clock frequency.
30# This will define a symbol, F_USB, in all source code files equal to the
31# input clock frequency (before any prescaling is performed) in Hz. This value may
32# differ from F_CPU if prescaling is used on the latter, and is required as the
33# raw input clock is fed directly to the PLL sections of the AVR for high speed
34# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
35# at the end, this will be done automatically to create a 32-bit value in your
36# source code.
37#
38# If no clock division is performed on the input clock inside the AVR (via the
39# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
40F_USB = $(F_CPU)
41
42# Interrupt driven control endpoint task(+60)
43OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
44
45
46# Boot Section Size in *bytes*
47# Teensy halfKay 512
48# Teensy++ halfKay 1024
49# Atmel DFU loader 4096
50# LUFA bootloader 4096
51# USBaspLoader 2048
52OPT_DEFS += -DBOOTLOADER_SIZE=4096
53
54# Build Options
55# change to "no" to disable the options, or define them in the Makefile in
56# the appropriate keymap folder that will get included automatically
57#
58BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000)
59MOUSEKEY_ENABLE ?= yes # Mouse keys(+4700)
60EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450)
61CONSOLE_ENABLE ?= no # Console for debug(+400)
62COMMAND_ENABLE ?= yes # Commands for debug and configuration
63NKRO_ENABLE ?= no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
64BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality
65MIDI_ENABLE ?= no # MIDI controls
66AUDIO_ENABLE ?= no # Audio output on port C6
67UNICODE_ENABLE ?= no # Unicode
68BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID
69RGBLIGHT_ENABLE ?= no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
70SUBPROJECT_rev1 ?= yes
71USE_I2C ?= yes
72# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
73SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend
74
75CUSTOM_MATRIX = yes
76
77avrdude: build
78 ls /dev/tty* > /tmp/1; \
79 echo "Reset your Pro Micro now"; \
80 while [[ -z $$USB ]]; do \
81 sleep 1; \
82 ls /dev/tty* > /tmp/2; \
83 USB=`diff /tmp/1 /tmp/2 | grep -o '/dev/tty.*'`; \
84 done; \
85 avrdude -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex
86
87.PHONY: avrdude
diff --git a/keyboards/nyquist/serial.c b/keyboards/nyquist/serial.c
new file mode 100644
index 000000000..6faed09ce
--- /dev/null
+++ b/keyboards/nyquist/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#ifdef USE_SERIAL
16
17// Serial pulse period in microseconds. Its probably a bad idea to lower this
18// value.
19#define SERIAL_DELAY 24
20
21uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0};
22uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0};
23
24#define SLAVE_DATA_CORRUPT (1<<0)
25volatile uint8_t status = 0;
26
27inline static
28void serial_delay(void) {
29 _delay_us(SERIAL_DELAY);
30}
31
32inline static
33void serial_output(void) {
34 SERIAL_PIN_DDR |= SERIAL_PIN_MASK;
35}
36
37// make the serial pin an input with pull-up resistor
38inline static
39void serial_input(void) {
40 SERIAL_PIN_DDR &= ~SERIAL_PIN_MASK;
41 SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
42}
43
44inline static
45uint8_t serial_read_pin(void) {
46 return !!(SERIAL_PIN_INPUT & SERIAL_PIN_MASK);
47}
48
49inline static
50void serial_low(void) {
51 SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK;
52}
53
54inline static
55void serial_high(void) {
56 SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
57}
58
59void serial_master_init(void) {
60 serial_output();
61 serial_high();
62}
63
64void 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.
74static
75void 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.
84static
85void 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
95static
96uint8_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
109static
110void 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
124ISR(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
160inline
161bool 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
171int 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/keyboards/nyquist/serial.h b/keyboards/nyquist/serial.h
new file mode 100644
index 000000000..15fe4db7b
--- /dev/null
+++ b/keyboards/nyquist/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
18extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH];
19extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH];
20
21void serial_master_init(void);
22void serial_slave_init(void);
23int serial_update_buffers(void);
24bool serial_slave_data_corrupt(void);
25
26#endif
diff --git a/keyboards/nyquist/split_util.c b/keyboards/nyquist/split_util.c
new file mode 100644
index 000000000..39639c3b4
--- /dev/null
+++ b/keyboards/nyquist/split_util.c
@@ -0,0 +1,84 @@
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_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#ifdef USE_I2C
35 i2c_master_init();
36#ifdef SSD1306OLED
37 matrix_master_OLED_init ();
38#endif
39#else
40 serial_master_init();
41#endif
42}
43
44static void keyboard_slave_setup(void) {
45#ifdef USE_I2C
46 i2c_slave_init(SLAVE_I2C_ADDRESS);
47#else
48 serial_slave_init();
49#endif
50}
51
52bool has_usb(void) {
53 USBCON |= (1 << OTGPADE); //enables VBUS pad
54 _delay_us(5);
55 return (USBSTA & (1<<VBUS)); //checks state of VBUS
56}
57
58void split_keyboard_setup(void) {
59 setup_handedness();
60
61 if (has_usb()) {
62 keyboard_master_setup();
63 } else {
64 keyboard_slave_setup();
65 }
66 sei();
67}
68
69void keyboard_slave_loop(void) {
70 matrix_init();
71
72 while (1) {
73 matrix_slave_scan();
74 }
75}
76
77// this code runs before the usb and keyboard is initialized
78void matrix_setup(void) {
79 split_keyboard_setup();
80
81 if (!has_usb()) {
82 keyboard_slave_loop();
83 }
84}
diff --git a/keyboards/nyquist/split_util.h b/keyboards/nyquist/split_util.h
new file mode 100644
index 000000000..3ae76c209
--- /dev/null
+++ b/keyboards/nyquist/split_util.h
@@ -0,0 +1,24 @@
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);
20void keyboard_slave_loop(void);
21
22void matrix_master_OLED_init (void);
23
24#endif