diff options
author | MakotoKurauchi <pluis@me.com> | 2018-01-29 02:14:12 +0900 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2018-01-28 12:14:12 -0500 |
commit | bceffdefcac30dd8b08ec3b803af372cbf254a7b (patch) | |
tree | 600173b95bdfc43a9efd75cdd3beec8b3577a4af | |
parent | 86225ccc9b22f6b7b3cbbb9c5c578ea31f2214fa (diff) | |
download | qmk_firmware-bceffdefcac30dd8b08ec3b803af372cbf254a7b.tar.gz qmk_firmware-bceffdefcac30dd8b08ec3b803af372cbf254a7b.zip |
Add helix keyboard (#2308)
* Fork from Let's Split
* Organizing files
* Delete some keymaps
* I2C and serial enabled at the same time
* Change readme
* add #define HELIX_ROWS for multiple rows
* Delete avrdude flashing script
* Delete makefiles
* Subproject elimination
* Fix lufa path
* Remove PLAY_NOTE_ARRAY usages to get rid of warning.
Fix conflicting function name
* Mousekey change default to off
* Fix to oled display adjust
* make rev2
change pin assign
change keymap
* use master_buffer
* Timing adjustment
* Organizing files
* Change Keymap
* Change Keymap
Add EISU and KANA
Correct 4rows
* NKRO default to disable
* EXTRAKEY_ENABLE default to disable
* add rgb reset key
* rgb custom function enable
* Extend font
* add RGBLED_POWER
default folder to helix/rev2
RGB_ENABLE to no
* renamed directory
* Disable RGBLIGHT_CUSTOM_DRIVER
* Disable LOCKING_SUPPORT_ENABLE
* Update bootloader setting
* Change readme
* Fixed argument error
38 files changed, 4811 insertions, 0 deletions
diff --git a/keyboards/helix/common/glcdfont.c b/keyboards/helix/common/glcdfont.c new file mode 100644 index 000000000..89665ba07 --- /dev/null +++ b/keyboards/helix/common/glcdfont.c | |||
@@ -0,0 +1,244 @@ | |||
1 | // This is the 'classic' fixed-space bitmap font for Adafruit_GFX since 1.0. | ||
2 | // See gfxfont.h for newer custom bitmap font info. | ||
3 | |||
4 | #ifndef FONT5X7_H | ||
5 | #define FONT5X7_H | ||
6 | |||
7 | #ifdef __AVR__ | ||
8 | #include <avr/io.h> | ||
9 | #include <avr/pgmspace.h> | ||
10 | #elif defined(ESP8266) | ||
11 | #include <pgmspace.h> | ||
12 | #else | ||
13 | #define PROGMEM | ||
14 | #endif | ||
15 | |||
16 | // Standard ASCII 5x7 font | ||
17 | |||
18 | static const unsigned char font[] PROGMEM = { | ||
19 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
20 | 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00, | ||
21 | 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00, | ||
22 | 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00, | ||
23 | 0x18, 0x3C, 0x7E, 0x3C, 0x18, 0x00, | ||
24 | 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00, | ||
25 | 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, | ||
26 | 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00, | ||
27 | 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, | ||
28 | 0x00, 0x18, 0x24, 0x18, 0x00, 0x00, | ||
29 | 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00, | ||
30 | 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00, | ||
31 | 0x26, 0x29, 0x79, 0x29, 0x26, 0x00, | ||
32 | 0x40, 0x7F, 0x05, 0x05, 0x07, 0x00, | ||
33 | 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00, | ||
34 | 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 0x00, | ||
35 | 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00, | ||
36 | 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00, | ||
37 | 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00, | ||
38 | 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00, | ||
39 | 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, | ||
40 | 0x00, 0x66, 0x89, 0x95, 0x6A, 0x00, | ||
41 | 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, | ||
42 | 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00, | ||
43 | 0x08, 0x04, 0x7E, 0x04, 0x08, 0x00, | ||
44 | 0x10, 0x20, 0x7E, 0x20, 0x10, 0x00, | ||
45 | 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00, | ||
46 | 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00, | ||
47 | 0x1E, 0x10, 0x10, 0x10, 0x10, 0x00, | ||
48 | 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00, | ||
49 | 0x30, 0x38, 0x3E, 0x38, 0x30, 0x00, | ||
50 | 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, | ||
51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
52 | 0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, | ||
53 | 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, | ||
54 | 0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, | ||
55 | 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, | ||
56 | 0x23, 0x13, 0x08, 0x64, 0x62, 0x00, | ||
57 | 0x36, 0x49, 0x56, 0x20, 0x50, 0x00, | ||
58 | 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, | ||
59 | 0x00, 0x1C, 0x22, 0x41, 0x00, 0x00, | ||
60 | 0x00, 0x41, 0x22, 0x1C, 0x00, 0x00, | ||
61 | 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 0x00, | ||
62 | 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, | ||
63 | 0x00, 0x80, 0x70, 0x30, 0x00, 0x00, | ||
64 | 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, | ||
65 | 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, | ||
66 | 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, | ||
67 | 0x3E, 0x51, 0x49, 0x45, 0x3E, 0x00, | ||
68 | 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, | ||
69 | 0x72, 0x49, 0x49, 0x49, 0x46, 0x00, | ||
70 | 0x21, 0x41, 0x49, 0x4D, 0x33, 0x00, | ||
71 | 0x18, 0x14, 0x12, 0x7F, 0x10, 0x00, | ||
72 | 0x27, 0x45, 0x45, 0x45, 0x39, 0x00, | ||
73 | 0x3C, 0x4A, 0x49, 0x49, 0x31, 0x00, | ||
74 | 0x41, 0x21, 0x11, 0x09, 0x07, 0x00, | ||
75 | 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, | ||
76 | 0x46, 0x49, 0x49, 0x29, 0x1E, 0x00, | ||
77 | 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, | ||
78 | 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, | ||
79 | 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, | ||
80 | 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, | ||
81 | 0x00, 0x41, 0x22, 0x14, 0x08, 0x00, | ||
82 | 0x02, 0x01, 0x59, 0x09, 0x06, 0x00, | ||
83 | 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x00, | ||
84 | 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x00, | ||
85 | 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, | ||
86 | 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, | ||
87 | 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00, | ||
88 | 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, | ||
89 | 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, | ||
90 | 0x3E, 0x41, 0x41, 0x51, 0x73, 0x00, | ||
91 | 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, | ||
92 | 0x00, 0x41, 0x7F, 0x41, 0x00, 0x00, | ||
93 | 0x20, 0x40, 0x41, 0x3F, 0x01, 0x00, | ||
94 | 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, | ||
95 | 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, | ||
96 | 0x7F, 0x02, 0x1C, 0x02, 0x7F, 0x00, | ||
97 | 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, | ||
98 | 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, | ||
99 | 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, | ||
100 | 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, | ||
101 | 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, | ||
102 | 0x26, 0x49, 0x49, 0x49, 0x32, 0x00, | ||
103 | 0x03, 0x01, 0x7F, 0x01, 0x03, 0x00, | ||
104 | 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, | ||
105 | 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, | ||
106 | 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, | ||
107 | 0x63, 0x14, 0x08, 0x14, 0x63, 0x00, | ||
108 | 0x03, 0x04, 0x78, 0x04, 0x03, 0x00, | ||
109 | 0x61, 0x59, 0x49, 0x4D, 0x43, 0x00, | ||
110 | 0x00, 0x7F, 0x41, 0x41, 0x41, 0x00, | ||
111 | 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, | ||
112 | 0x00, 0x41, 0x41, 0x41, 0x7F, 0x00, | ||
113 | 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, | ||
114 | 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, | ||
115 | 0x00, 0x03, 0x07, 0x08, 0x00, 0x00, | ||
116 | 0x20, 0x54, 0x54, 0x78, 0x40, 0x00, | ||
117 | 0x7F, 0x28, 0x44, 0x44, 0x38, 0x00, | ||
118 | 0x38, 0x44, 0x44, 0x44, 0x28, 0x00, | ||
119 | 0x38, 0x44, 0x44, 0x28, 0x7F, 0x00, | ||
120 | 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, | ||
121 | 0x00, 0x08, 0x7E, 0x09, 0x02, 0x00, | ||
122 | 0x18, 0xA4, 0xA4, 0x9C, 0x78, 0x00, | ||
123 | 0x7F, 0x08, 0x04, 0x04, 0x78, 0x00, | ||
124 | 0x00, 0x44, 0x7D, 0x40, 0x00, 0x00, | ||
125 | 0x20, 0x40, 0x40, 0x3D, 0x00, 0x00, | ||
126 | 0x7F, 0x10, 0x28, 0x44, 0x00, 0x00, | ||
127 | 0x00, 0x41, 0x7F, 0x40, 0x00, 0x00, | ||
128 | 0x7C, 0x04, 0x78, 0x04, 0x78, 0x00, | ||
129 | 0x7C, 0x08, 0x04, 0x04, 0x78, 0x00, | ||
130 | 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, | ||
131 | 0xFC, 0x18, 0x24, 0x24, 0x18, 0x00, | ||
132 | 0x18, 0x24, 0x24, 0x18, 0xFC, 0x00, | ||
133 | 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00, | ||
134 | 0x48, 0x54, 0x54, 0x54, 0x24, 0x00, | ||
135 | 0x04, 0x04, 0x3F, 0x44, 0x24, 0x00, | ||
136 | 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00, | ||
137 | 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, | ||
138 | 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, | ||
139 | 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, | ||
140 | 0x4C, 0x90, 0x90, 0x90, 0x7C, 0x00, | ||
141 | 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, | ||
142 | 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, | ||
143 | 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, | ||
144 | 0x00, 0x41, 0x36, 0x08, 0x00, 0x00, | ||
145 | 0x02, 0x01, 0x02, 0x04, 0x02, 0x00, | ||
146 | 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00, | ||
147 | 0x03, 0x07, 0x1F, 0x7F, 0xFF, 0xFF, | ||
148 | 0xFE, 0xF8, 0xF0, 0xC0, 0x20, 0xF8, | ||
149 | 0xFE, 0xFF, 0xFE, 0x79, 0x27, 0x1F, | ||
150 | 0x7F, 0xFF, 0xFF, 0xFE, 0xF8, 0xF0, | ||
151 | 0xC0, 0x20, 0xF8, 0xFE, 0xFF, 0xFF, | ||
152 | 0x7F, 0x3F, 0x3F, 0x7F, 0xFF, 0xFE, | ||
153 | 0xF8, 0xF0, 0xC0, 0x00, 0x00, 0x00, | ||
154 | 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | ||
155 | 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
156 | 0x00, 0x00, 0xFF, 0x7F, 0x7F, 0x7F, | ||
157 | 0xBF, 0xBF, 0xC0, 0xC0, 0xC0, 0xE0, | ||
158 | 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, | ||
159 | 0xF8, 0x78, 0x78, 0x7C, 0x3C, 0x3C, | ||
160 | 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, | ||
161 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
162 | 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, | ||
163 | 0xBF, 0xBF, 0xDF, 0xDF, 0xEF, 0xEF, | ||
164 | 0x00, 0x03, 0x07, 0x1F, 0x7F, 0xFF, | ||
165 | 0xFF, 0xFF, 0xFE, 0xF8, 0xE0, 0xC0, | ||
166 | 0xE0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, | ||
167 | 0x7F, 0x1F, 0x07, 0x03, 0x00, 0x00, | ||
168 | 0xE0, 0xF0, 0xF0, 0xF0, 0xE0, 0xEC, | ||
169 | 0xEE, 0xF7, 0xF3, 0x70, 0x20, 0x00, | ||
170 | 0x7C, 0x7C, 0x7C, 0x7E, 0x00, 0x7E, | ||
171 | 0x7E, 0x7E, 0x7F, 0x7F, 0x7F, 0x00, | ||
172 | 0x00, 0x80, 0xC0, 0xE0, 0x7E, 0x5B, | ||
173 | 0x4F, 0x5B, 0xFE, 0xC0, 0x00, 0x00, | ||
174 | 0xC0, 0x00, 0xDC, 0xD7, 0xDE, 0xDE, | ||
175 | 0xDE, 0xD7, 0xDC, 0x00, 0xC0, 0x00, | ||
176 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
177 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
178 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
179 | 0x00, 0x00, 0x00, 0x00, 0xC1, 0xF3, | ||
180 | 0xCF, 0xBF, 0x7F, 0xFF, 0xFF, 0xFC, | ||
181 | 0xFB, 0xE7, 0x81, 0x00, 0x00, 0x00, | ||
182 | 0x00, 0x80, 0xE3, 0xCF, 0x3F, 0xFF, | ||
183 | 0xFF, 0xFF, 0xFC, 0xFB, 0xE7, 0x81, | ||
184 | 0x00, 0x00, 0x00, 0x00, 0x81, 0xE7, | ||
185 | 0xFF, 0xFF, 0xFF, 0xFF, 0x3C, 0x00, | ||
186 | 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | ||
187 | 0xFF, 0xF8, 0xF8, 0xFC, 0x7C, 0x7E, | ||
188 | 0x7E, 0x3E, 0xFE, 0xFF, 0xFF, 0xFF, | ||
189 | 0xFF, 0xFF, 0xF7, 0xF7, 0xF7, 0xFB, | ||
190 | 0xFB, 0x7D, 0x7D, 0x7D, 0xBE, 0xBE, | ||
191 | 0xBE, 0xDF, 0xDF, 0xE0, 0xE0, 0x00, | ||
192 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | ||
193 | 0x00, 0xFC, 0xFC, 0x7C, 0x7E, 0x7E, | ||
194 | 0x3E, 0x3E, 0x1F, 0x1F, 0x1F, 0x0F, | ||
195 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | ||
196 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, | ||
197 | 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | ||
198 | 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0x81, | ||
199 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
200 | 0x0F, 0x1F, 0x3F, 0x7F, 0x7F, 0x7F, | ||
201 | 0x7F, 0x7F, 0x3F, 0x1E, 0x0C, 0x00, | ||
202 | 0x1F, 0x1F, 0x1F, 0x3F, 0x00, 0x3F, | ||
203 | 0x3F, 0x3F, 0x7F, 0x7F, 0x7F, 0x00, | ||
204 | 0x30, 0x7B, 0x7F, 0x78, 0x30, 0x20, | ||
205 | 0x20, 0x30, 0x78, 0x7F, 0x3B, 0x00, | ||
206 | 0x03, 0x00, 0x0F, 0x7F, 0x0F, 0x0F, | ||
207 | 0x0F, 0x7F, 0x0F, 0x00, 0x03, 0x00, | ||
208 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
209 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
210 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
211 | 0x60, 0x70, 0x7C, 0x7F, 0x7F, 0x7F, | ||
212 | 0x7F, 0x1F, 0x06, 0x01, 0x03, 0x0F, | ||
213 | 0x3F, 0x7F, 0x7F, 0x7E, 0x7C, 0x7C, | ||
214 | 0x7E, 0x7F, 0x7F, 0x7F, 0x1F, 0x06, | ||
215 | 0x01, 0x07, 0x0F, 0x3F, 0x7F, 0x7F, | ||
216 | 0x7E, 0x7C, 0x7C, 0x7E, 0x7F, 0x7F, | ||
217 | 0x3F, 0x0F, 0x03, 0x00, 0x00, 0x00, | ||
218 | 0x00, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, | ||
219 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
220 | 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x7F, | ||
221 | 0x7F, 0x7F, 0x7D, 0x7D, 0x3D, 0x3E, | ||
222 | 0x1E, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, | ||
223 | 0x07, 0x07, 0x07, 0x03, 0x03, 0x00, | ||
224 | 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, | ||
225 | 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, | ||
226 | 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x00, | ||
227 | 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, | ||
228 | 0x00, 0x40, 0x70, 0x78, 0x7E, 0x7F, | ||
229 | 0x7F, 0x7F, 0x3F, 0x0F, 0x03, 0x01, | ||
230 | 0x03, 0x0F, 0x3F, 0x7F, 0x7F, 0x7F, | ||
231 | 0x7E, 0x78, 0x70, 0x40, 0x00, 0x00, | ||
232 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
233 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
234 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
235 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
236 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
237 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
238 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
239 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
240 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
241 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
242 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | ||
243 | }; | ||
244 | #endif // FONT5X7_H | ||
diff --git a/keyboards/helix/config.h b/keyboards/helix/config.h new file mode 100644 index 000000000..8f0524f97 --- /dev/null +++ b/keyboards/helix/config.h | |||
@@ -0,0 +1,28 @@ | |||
1 | /* | ||
2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
3 | Copyright 2015 Jack Humbert | ||
4 | |||
5 | This program is free software: you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation, either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #ifndef CONFIG_H | ||
20 | #define CONFIG_H | ||
21 | |||
22 | #include "config_common.h" | ||
23 | |||
24 | #ifdef SUBPROJECT_rev1 | ||
25 | #include "rev1/config.h" | ||
26 | #endif | ||
27 | |||
28 | #endif | ||
diff --git a/keyboards/helix/helix.c b/keyboards/helix/helix.c new file mode 100644 index 000000000..539abd534 --- /dev/null +++ b/keyboards/helix/helix.c | |||
@@ -0,0 +1 @@ | |||
#include "helix.h" | |||
diff --git a/keyboards/helix/helix.h b/keyboards/helix/helix.h new file mode 100644 index 000000000..cddeb8830 --- /dev/null +++ b/keyboards/helix/helix.h | |||
@@ -0,0 +1,57 @@ | |||
1 | #ifndef HELIX_H | ||
2 | #define HELIX_H | ||
3 | |||
4 | #ifdef KEYBOARD_helix_rev1 | ||
5 | #include "rev1.h" | ||
6 | #endif | ||
7 | #ifdef KEYBOARD_helix_rev2 | ||
8 | #include "rev2.h" | ||
9 | #endif | ||
10 | |||
11 | #if HELIX_ROWS == 3 | ||
12 | #define KC_KEYMAP( \ | ||
13 | L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ | ||
14 | L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ | ||
15 | L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \ | ||
16 | ) \ | ||
17 | KEYMAP( \ | ||
18 | KC_##L00, KC_##L01, KC_##L02, KC_##L03, KC_##L04, KC_##L05, KC_##R00, KC_##R01, KC_##R02, KC_##R03, KC_##R04, KC_##R05, \ | ||
19 | KC_##L10, KC_##L11, KC_##L12, KC_##L13, KC_##L14, KC_##L15, KC_##R10, KC_##R11, KC_##R12, KC_##R13, KC_##R14, KC_##R15, \ | ||
20 | KC_##L20, KC_##L21, KC_##L22, KC_##L23, KC_##L24, KC_##L25, KC_##R20, KC_##R21, KC_##R22, KC_##R23, KC_##R24, KC_##R25, \ | ||
21 | ) | ||
22 | #elif HELIX_ROWS == 4 | ||
23 | // Used to create a keymap using only KC_ prefixed keys | ||
24 | #define KC_KEYMAP( \ | ||
25 | L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ | ||
26 | L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ | ||
27 | L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \ | ||
28 | L30, L31, L32, L33, L34, L35, R30, R31, R32, R33, R34, R35 \ | ||
29 | ) \ | ||
30 | KEYMAP( \ | ||
31 | KC_##L00, KC_##L01, KC_##L02, KC_##L03, KC_##L04, KC_##L05, KC_##R00, KC_##R01, KC_##R02, KC_##R03, KC_##R04, KC_##R05, \ | ||
32 | KC_##L10, KC_##L11, KC_##L12, KC_##L13, KC_##L14, KC_##L15, KC_##R10, KC_##R11, KC_##R12, KC_##R13, KC_##R14, KC_##R15, \ | ||
33 | KC_##L20, KC_##L21, KC_##L22, KC_##L23, KC_##L24, KC_##L25, KC_##R20, KC_##R21, KC_##R22, KC_##R23, KC_##R24, KC_##R25, \ | ||
34 | KC_##L30, KC_##L31, KC_##L32, KC_##L33, KC_##L34, KC_##L35, KC_##R30, KC_##R31, KC_##R32, KC_##R33, KC_##R34, KC_##R35 \ | ||
35 | ) | ||
36 | #elif HELIX_ROWS == 5 | ||
37 | #define KC_KEYMAP( \ | ||
38 | L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ | ||
39 | L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ | ||
40 | L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \ | ||
41 | L30, L31, L32, L33, L34, L35, R30, R31, R32, R33, R34, R35, \ | ||
42 | L40, L41, L42, L43, L44, L45, R40, R41, R42, R43, R44, R45 \ | ||
43 | ) \ | ||
44 | KEYMAP( \ | ||
45 | KC_##L00, KC_##L01, KC_##L02, KC_##L03, KC_##L04, KC_##L05, KC_##R00, KC_##R01, KC_##R02, KC_##R03, KC_##R04, KC_##R05, \ | ||
46 | KC_##L10, KC_##L11, KC_##L12, KC_##L13, KC_##L14, KC_##L15, KC_##R10, KC_##R11, KC_##R12, KC_##R13, KC_##R14, KC_##R15, \ | ||
47 | KC_##L20, KC_##L21, KC_##L22, KC_##L23, KC_##L24, KC_##L25, KC_##R20, KC_##R21, KC_##R22, KC_##R23, KC_##R24, KC_##R25, \ | ||
48 | KC_##L30, KC_##L31, KC_##L32, KC_##L33, KC_##L34, KC_##L35, KC_##R30, KC_##R31, KC_##R32, KC_##R33, KC_##R34, KC_##R35, \ | ||
49 | KC_##L40, KC_##L41, KC_##L42, KC_##L43, KC_##L44, KC_##L45, KC_##R40, KC_##R41, KC_##R42, KC_##R43, KC_##R44, KC_##R45 \ | ||
50 | ) | ||
51 | #else | ||
52 | #error "expected HELIX_ROWS 3 or 4 or 5" | ||
53 | #endif | ||
54 | |||
55 | #include "quantum.h" | ||
56 | |||
57 | #endif | ||
diff --git a/keyboards/helix/i2c.c b/keyboards/helix/i2c.c new file mode 100644 index 000000000..084c890c4 --- /dev/null +++ b/keyboards/helix/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 | |||
21 | volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE]; | ||
22 | |||
23 | static volatile uint8_t slave_buffer_pos; | ||
24 | static volatile bool slave_has_register_set = false; | ||
25 | |||
26 | // Wait for an i2c operation to finish | ||
27 | inline static | ||
28 | void 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 | ||
38 | void 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 | ||
50 | uint8_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. | ||
72 | void 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 | ||
83 | uint8_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 | ||
96 | uint8_t i2c_master_read(int ack) { | ||
97 | TWCR = (1<<TWINT) | (1<<TWEN) | (ack<<TWEA); | ||
98 | |||
99 | i2c_delay(); | ||
100 | return TWDR; | ||
101 | } | ||
102 | |||
103 | void i2c_reset_state(void) { | ||
104 | TWCR = 0; | ||
105 | } | ||
106 | |||
107 | void 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 | |||
116 | ISR(TWI_vect); | ||
117 | |||
118 | ISR(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/helix/i2c.h b/keyboards/helix/i2c.h new file mode 100644 index 000000000..c15b6bc50 --- /dev/null +++ b/keyboards/helix/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 400000L | ||
20 | |||
21 | extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE]; | ||
22 | |||
23 | void i2c_master_init(void); | ||
24 | uint8_t i2c_master_start(uint8_t address); | ||
25 | void i2c_master_stop(void); | ||
26 | uint8_t i2c_master_write(uint8_t data); | ||
27 | uint8_t i2c_master_read(int); | ||
28 | void i2c_reset_state(void); | ||
29 | void i2c_slave_init(uint8_t address); | ||
30 | |||
31 | |||
32 | static inline unsigned char i2c_start_read(unsigned char addr) { | ||
33 | return i2c_master_start((addr << 1) | I2C_READ); | ||
34 | } | ||
35 | |||
36 | static inline unsigned char i2c_start_write(unsigned char addr) { | ||
37 | return i2c_master_start((addr << 1) | I2C_WRITE); | ||
38 | } | ||
39 | |||
40 | // from SSD1306 scrips | ||
41 | extern unsigned char i2c_rep_start(unsigned char addr); | ||
42 | extern void i2c_start_wait(unsigned char addr); | ||
43 | extern unsigned char i2c_readAck(void); | ||
44 | extern unsigned char i2c_readNak(void); | ||
45 | extern 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/helix/pro_micro.h b/keyboards/helix/pro_micro.h new file mode 100644 index 000000000..f9e7ed75d --- /dev/null +++ b/keyboards/helix/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 | |||
102 | static const uint8_t SDA = 2; | ||
103 | static const uint8_t SCL = 3; | ||
104 | #define LED_BUILTIN 13 | ||
105 | |||
106 | // Map SPI port to 'new' pins D14..D17 | ||
107 | static const uint8_t SS = 17; | ||
108 | static const uint8_t MOSI = 16; | ||
109 | static const uint8_t MISO = 14; | ||
110 | static const uint8_t SCK = 15; | ||
111 | |||
112 | // Mapping of analog pins as digital I/O | ||
113 | // A6-A11 share with digital pins | ||
114 | static const uint8_t ADC0 = 18; | ||
115 | static const uint8_t ADC1 = 19; | ||
116 | static const uint8_t ADC2 = 20; | ||
117 | static const uint8_t ADC3 = 21; | ||
118 | static const uint8_t ADC4 = 22; | ||
119 | static const uint8_t ADC5 = 23; | ||
120 | static const uint8_t ADC6 = 24; // D4 | ||
121 | static const uint8_t ADC7 = 25; // D6 | ||
122 | static const uint8_t ADC8 = 26; // D8 | ||
123 | static const uint8_t ADC9 = 27; // D9 | ||
124 | static const uint8_t ADC10 = 28; // D10 | ||
125 | static 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 | ||
133 | extern 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) | ||
184 | const 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 | |||
194 | const 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 | |||
204 | const 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 | |||
214 | const 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 | |||
251 | const 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 | |||
288 | const 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 | |||
325 | const 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/helix/readme.md b/keyboards/helix/readme.md new file mode 100644 index 000000000..5ee233e81 --- /dev/null +++ b/keyboards/helix/readme.md | |||
@@ -0,0 +1,16 @@ | |||
1 | Helix | ||
2 | === | ||
3 | |||
4 |  | ||
5 | |||
6 | A compact split ortholinear keyboard. | ||
7 | |||
8 | Keyboard Maintainer: [Makoto Kurauchi](https://github.com/MakotoKurauchi/) [@pluis9](https://twitter.com/pluis9) | ||
9 | Hardware Supported: Helix PCB Alpha, Beta, Pro Micro | ||
10 | Hardware Availability: [PCB & Case Data](https://github.com/MakotoKurauchi/helix), [Yushakobo Shop](https://yushakobo.jp/shop/) | ||
11 | |||
12 | Make example for this keyboard (after setting up your build environment): | ||
13 | |||
14 | make helix:default | ||
15 | |||
16 | See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information. | ||
diff --git a/keyboards/helix/rev1/config.h b/keyboards/helix/rev1/config.h new file mode 100644 index 000000000..3420992d8 --- /dev/null +++ b/keyboards/helix/rev1/config.h | |||
@@ -0,0 +1,103 @@ | |||
1 | /* | ||
2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
3 | Copyright 2015 Jack Humbert | ||
4 | |||
5 | This program is free software: you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation, either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #ifndef REV1_CONFIG_H | ||
20 | #define REV1_CONFIG_H | ||
21 | |||
22 | #include "../config.h" | ||
23 | |||
24 | /* USB Device descriptor parameter */ | ||
25 | #define VENDOR_ID 0xFEED | ||
26 | #define PRODUCT_ID 0x3060 | ||
27 | #define DEVICE_VER 0x0001 | ||
28 | #define MANUFACTURER Yushakobo | ||
29 | #define PRODUCT Helix Alpha | ||
30 | #define DESCRIPTION A split keyboard for the cheap makers | ||
31 | |||
32 | #define HELIX_ROWS 5 | ||
33 | |||
34 | /* key matrix size */ | ||
35 | // Rows are doubled-up | ||
36 | #if HELIX_ROWS == 3 | ||
37 | #define MATRIX_ROWS 6 | ||
38 | #define MATRIX_COLS 6 | ||
39 | #define MATRIX_ROW_PINS { D7, E6, B4 } | ||
40 | #elif HELIX_ROWS == 4 | ||
41 | #define MATRIX_ROWS 8 | ||
42 | #define MATRIX_COLS 6 | ||
43 | #define MATRIX_ROW_PINS { D7, E6, B4, B5 } | ||
44 | #elif HELIX_ROWS == 5 | ||
45 | #define MATRIX_ROWS 10 | ||
46 | #define MATRIX_COLS 6 | ||
47 | #define MATRIX_ROW_PINS { D7, E6, B4, B5, D4 } | ||
48 | #else | ||
49 | #error "expected HELIX_ROWS 3 or 4 or 5" | ||
50 | #endif | ||
51 | |||
52 | // wiring of each half | ||
53 | #define MATRIX_COL_PINS { F6, F7, B1, B3, B2, B6 } | ||
54 | // #define MATRIX_COL_PINS { B6, B2, B3, B1, F7, F6 } //uncomment this line and comment line above if you need to reverse left-to-right key order | ||
55 | |||
56 | #define CATERINA_BOOTLOADER | ||
57 | |||
58 | /* define if matrix has ghost */ | ||
59 | //#define MATRIX_HAS_GHOST | ||
60 | |||
61 | /* number of backlight levels */ | ||
62 | // #define BACKLIGHT_LEVELS 3 | ||
63 | |||
64 | /* Set 0 if debouncing isn't needed */ | ||
65 | #define DEBOUNCING_DELAY 5 | ||
66 | |||
67 | /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ | ||
68 | #define LOCKING_SUPPORT_ENABLE | ||
69 | /* Locking resynchronize hack */ | ||
70 | #define LOCKING_RESYNC_ENABLE | ||
71 | |||
72 | /* key combination for command */ | ||
73 | #define IS_COMMAND() ( \ | ||
74 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
75 | ) | ||
76 | |||
77 | /* ws2812 RGB LED */ | ||
78 | #define RGB_DI_PIN D3 | ||
79 | #define RGBLIGHT_TIMER | ||
80 | #define RGBLED_NUM 12 // Number of LEDs | ||
81 | #define ws2812_PORTREG PORTD | ||
82 | #define ws2812_DDRREG DDRD | ||
83 | |||
84 | /* | ||
85 | * Feature disable options | ||
86 | * These options are also useful to firmware size reduction. | ||
87 | */ | ||
88 | |||
89 | /* disable debug print */ | ||
90 | // #define NO_DEBUG | ||
91 | |||
92 | /* disable print */ | ||
93 | // #define NO_PRINT | ||
94 | |||
95 | /* disable action features */ | ||
96 | //#define NO_ACTION_LAYER | ||
97 | //#define NO_ACTION_TAPPING | ||
98 | //#define NO_ACTION_ONESHOT | ||
99 | //#define NO_ACTION_MACRO | ||
100 | //#define NO_ACTION_FUNCTION | ||
101 | |||
102 | |||
103 | #endif | ||
diff --git a/keyboards/helix/rev1/keymaps/OLED_sample/config.h b/keyboards/helix/rev1/keymaps/OLED_sample/config.h new file mode 100644 index 000000000..6cd3072b1 --- /dev/null +++ b/keyboards/helix/rev1/keymaps/OLED_sample/config.h | |||
@@ -0,0 +1,54 @@ | |||
1 | /* | ||
2 | This is the c configuration file for the keymap | ||
3 | |||
4 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
5 | Copyright 2015 Jack Humbert | ||
6 | |||
7 | This program is free software: you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation, either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | ||
20 | |||
21 | #ifndef CONFIG_USER_H | ||
22 | #define CONFIG_USER_H | ||
23 | |||
24 | #include "../../config.h" | ||
25 | |||
26 | /* Use I2C or Serial */ | ||
27 | |||
28 | #define USE_I2C | ||
29 | #define USE_SERIAL | ||
30 | //#define USE_MATRIX_I2C | ||
31 | |||
32 | /* Select hand configuration */ | ||
33 | |||
34 | #define MASTER_LEFT | ||
35 | // #define _MASTER_RIGHT | ||
36 | // #define EE_HANDS | ||
37 | |||
38 | #define SSD1306OLED | ||
39 | |||
40 | #define USE_SERIAL_PD2 | ||
41 | |||
42 | #define PREVENT_STUCK_MODIFIERS | ||
43 | #define TAPPING_FORCE_HOLD | ||
44 | #define TAPPING_TERM 100 | ||
45 | |||
46 | |||
47 | #undef RGBLED_NUM | ||
48 | #define RGBLIGHT_ANIMATIONS | ||
49 | #define RGBLED_NUM 6 | ||
50 | #define RGBLIGHT_HUE_STEP 10 | ||
51 | #define RGBLIGHT_SAT_STEP 17 | ||
52 | #define RGBLIGHT_VAL_STEP 17 | ||
53 | |||
54 | #endif | ||
diff --git a/keyboards/helix/rev1/keymaps/OLED_sample/keymap.c b/keyboards/helix/rev1/keymaps/OLED_sample/keymap.c new file mode 100644 index 000000000..4f1ffb7c5 --- /dev/null +++ b/keyboards/helix/rev1/keymaps/OLED_sample/keymap.c | |||
@@ -0,0 +1,498 @@ | |||
1 | #include "helix.h" | ||
2 | #include "bootloader.h" | ||
3 | #include "action_layer.h" | ||
4 | #include "eeconfig.h" | ||
5 | #include "LUFA/Drivers/Peripheral/TWI.h" | ||
6 | #ifdef AUDIO_ENABLE | ||
7 | #include "audio.h" | ||
8 | #endif | ||
9 | #ifdef SSD1306OLED | ||
10 | #include "ssd1306.h" | ||
11 | #endif | ||
12 | |||
13 | extern keymap_config_t keymap_config; | ||
14 | |||
15 | //Following line allows macro to read current RGB settings | ||
16 | extern rgblight_config_t rgblight_config; | ||
17 | |||
18 | |||
19 | // Each layer gets a name for readability, which is then used in the keymap matrix below. | ||
20 | // The underscores don't mean anything - you can have a layer called STUFF or any other name. | ||
21 | // Layer names don't all need to be of the same length, obviously, and you can also skip them | ||
22 | // entirely and just use numbers. | ||
23 | #define _QWERTY 0 | ||
24 | #define _COLEMAK 1 | ||
25 | #define _DVORAK 2 | ||
26 | #define _LOWER 3 | ||
27 | #define _RAISE 4 | ||
28 | #define _ADJUST 16 | ||
29 | |||
30 | enum custom_keycodes { | ||
31 | QWERTY = SAFE_RANGE, | ||
32 | COLEMAK, | ||
33 | DVORAK, | ||
34 | LOWER, | ||
35 | RAISE, | ||
36 | ADJUST, | ||
37 | BACKLIT, | ||
38 | RGBLED_TOGGLE, | ||
39 | RGBLED_STEP_MODE, | ||
40 | RGBLED_INCREASE_HUE, | ||
41 | RGBLED_DECREASE_HUE, | ||
42 | RGBLED_INCREASE_SAT, | ||
43 | RGBLED_DECREASE_SAT, | ||
44 | RGBLED_INCREASE_VAL, | ||
45 | RGBLED_DECREASE_VAL, | ||
46 | }; | ||
47 | |||
48 | enum macro_keycodes { | ||
49 | KC_SAMPLEMACRO, | ||
50 | }; | ||
51 | |||
52 | |||
53 | // Fillers to make layering more clear | ||
54 | #define _______ KC_TRNS | ||
55 | #define XXXXXXX KC_NO | ||
56 | //Macros | ||
57 | #define M_SAMPLE M(KC_SAMPLEMACRO) | ||
58 | |||
59 | #if HELIX_ROWS == 5 | ||
60 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
61 | |||
62 | /* Qwerty | ||
63 | * ,-----------------------------------------------------------------------------------. | ||
64 | * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | | ||
65 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
66 | * | Tab | Q | W | E | R | T | Y | U | I | O | P | Del | | ||
67 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
68 | * | Esc | A | S | D | F | G | H | J | K | L | ; | " | | ||
69 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
70 | * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter | | ||
71 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
72 | * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right | | ||
73 | * `-----------------------------------------------------------------------------------' | ||
74 | */ | ||
75 | [_QWERTY] = KEYMAP( \ | ||
76 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \ | ||
77 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_DEL, \ | ||
78 | KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \ | ||
79 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \ | ||
80 | ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
81 | ), | ||
82 | |||
83 | /* Colemak | ||
84 | * ,-----------------------------------------------------------------------------------. | ||
85 | * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | | ||
86 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
87 | * | Tab | Q | W | F | P | G | J | L | U | Y | ; | Del | | ||
88 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
89 | * | Esc | A | R | S | T | D | H | N | E | I | O | " | | ||
90 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
91 | * | Shift| Z | X | C | V | B | K | M | , | . | / |Enter | | ||
92 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
93 | * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right | | ||
94 | * `-----------------------------------------------------------------------------------' | ||
95 | */ | ||
96 | [_COLEMAK] = KEYMAP( \ | ||
97 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \ | ||
98 | KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_DEL, \ | ||
99 | KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \ | ||
100 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \ | ||
101 | ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
102 | ), | ||
103 | |||
104 | /* Dvorak | ||
105 | * ,-----------------------------------------------------------------------------------. | ||
106 | * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | | ||
107 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
108 | * | Tab | " | , | . | P | Y | F | G | C | R | L | Del | | ||
109 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
110 | * | Esc | A | O | E | U | I | D | H | T | N | S | / | | ||
111 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
112 | * | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter | | ||
113 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
114 | * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right | | ||
115 | * `-----------------------------------------------------------------------------------' | ||
116 | */ | ||
117 | [_DVORAK] = KEYMAP( \ | ||
118 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \ | ||
119 | KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_DEL, \ | ||
120 | KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \ | ||
121 | KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \ | ||
122 | ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
123 | ), | ||
124 | |||
125 | /* Lower | ||
126 | * ,-----------------------------------------------------------------------------------. | ||
127 | * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp | | ||
128 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
129 | * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Del | | ||
130 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
131 | * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | | \ | | | | ||
132 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
133 | * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter | | ||
134 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
135 | * | | | | | | | | Next | Vol- | Vol+ | Play | | ||
136 | * `-----------------------------------------------------------------------------------' | ||
137 | */ | ||
138 | [_LOWER] = KEYMAP( \ | ||
139 | KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \ | ||
140 | KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL, \ | ||
141 | KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \ | ||
142 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______, \ | ||
143 | _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
144 | ), | ||
145 | |||
146 | /* Raise | ||
147 | * ,-----------------------------------------------------------------------------------. | ||
148 | * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | | ||
149 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
150 | * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Del | | ||
151 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
152 | * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ | | ||
153 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
154 | * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Enter | | ||
155 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
156 | * | | | | | | | | Next | Vol- | Vol+ | Play | | ||
157 | * `-----------------------------------------------------------------------------------' | ||
158 | */ | ||
159 | [_RAISE] = KEYMAP( \ | ||
160 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \ | ||
161 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \ | ||
162 | KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \ | ||
163 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______, \ | ||
164 | _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
165 | ), | ||
166 | |||
167 | /* Adjust (Lower + Raise) | ||
168 | * ,-----------------------------------------------------------------------------------. | ||
169 | * | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | | ||
170 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
171 | * | | Reset| | | | | | | | | | Del | | ||
172 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
173 | * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak| | | | ||
174 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
175 | * | | | | | | | | | | | | | | ||
176 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
177 | * | | | | | | | | | | | | | ||
178 | * `-----------------------------------------------------------------------------------' | ||
179 | */ | ||
180 | [_ADJUST] = KEYMAP( \ | ||
181 | KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \ | ||
182 | _______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \ | ||
183 | _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \ | ||
184 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
185 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \ | ||
186 | ) | ||
187 | }; | ||
188 | |||
189 | #elif HELIX_ROWS == 4 | ||
190 | |||
191 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
192 | |||
193 | /* Qwerty | ||
194 | * ,-----------------------------------------------------------------------------------. | ||
195 | * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp | | ||
196 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
197 | * | Esc | A | S | D | F | G | H | J | K | L | ; | " | | ||
198 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
199 | * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter | | ||
200 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
201 | * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right | | ||
202 | * `-----------------------------------------------------------------------------------' | ||
203 | */ | ||
204 | |||
205 | [_QWERTY] = KEYMAP( \ | ||
206 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_DEL, \ | ||
207 | KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \ | ||
208 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \ | ||
209 | ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
210 | ), | ||
211 | |||
212 | /* Colemak | ||
213 | * ,-----------------------------------------------------------------------------------. | ||
214 | * | Tab | Q | W | F | P | G | J | L | U | Y | ; | Bksp | | ||
215 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
216 | * | Esc | A | R | S | T | D | H | N | E | I | O | " | | ||
217 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
218 | * | Shift| Z | X | C | V | B | K | M | , | . | / |Enter | | ||
219 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
220 | * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right | | ||
221 | * `-----------------------------------------------------------------------------------' | ||
222 | */ | ||
223 | [_COLEMAK] = KEYMAP( \ | ||
224 | KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, \ | ||
225 | KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \ | ||
226 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \ | ||
227 | ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
228 | ), | ||
229 | |||
230 | /* Dvorak | ||
231 | * ,-----------------------------------------------------------------------------------. | ||
232 | * | Tab | " | , | . | P | Y | F | G | C | R | L | Bksp | | ||
233 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
234 | * | Esc | A | O | E | U | I | D | H | T | N | S | / | | ||
235 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
236 | * | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter | | ||
237 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
238 | * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right | | ||
239 | * `-----------------------------------------------------------------------------------' | ||
240 | */ | ||
241 | [_DVORAK] = KEYMAP( \ | ||
242 | KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC, \ | ||
243 | KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \ | ||
244 | KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \ | ||
245 | ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
246 | ), | ||
247 | |||
248 | /* Lower | ||
249 | * ,-----------------------------------------------------------------------------------. | ||
250 | * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp | | ||
251 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
252 | * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | | \ | | | | ||
253 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
254 | * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter | | ||
255 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
256 | * | | | | | | | | Next | Vol- | Vol+ | Play | | ||
257 | * `-----------------------------------------------------------------------------------' | ||
258 | */ | ||
259 | [_LOWER] = KEYMAP( \ | ||
260 | KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \ | ||
261 | KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \ | ||
262 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______, \ | ||
263 | _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
264 | ), | ||
265 | |||
266 | /* Raise | ||
267 | * ,-----------------------------------------------------------------------------------. | ||
268 | * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | | ||
269 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
270 | * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ | | ||
271 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
272 | * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Enter | | ||
273 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
274 | * | | | | | | | | Next | Vol- | Vol+ | Play | | ||
275 | * `-----------------------------------------------------------------------------------' | ||
276 | */ | ||
277 | [_RAISE] = KEYMAP( \ | ||
278 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \ | ||
279 | KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \ | ||
280 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______, \ | ||
281 | _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
282 | ), | ||
283 | |||
284 | /* Adjust (Lower + Raise) | ||
285 | * ,-----------------------------------------------------------------------------------. | ||
286 | * | | Reset| | | | | | | | | | Del | | ||
287 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
288 | * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak| | | | ||
289 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
290 | * | | | | | | | | | | | | | | ||
291 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
292 | * | | | | | | | | | | | | | ||
293 | * `-----------------------------------------------------------------------------------' | ||
294 | */ | ||
295 | [_ADJUST] = KEYMAP( \ | ||
296 | _______, RESET, _______, M_SAMPLE, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \ | ||
297 | _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \ | ||
298 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
299 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \ | ||
300 | ) | ||
301 | }; | ||
302 | |||
303 | #else | ||
304 | #error "undefined keymaps" | ||
305 | #endif | ||
306 | |||
307 | |||
308 | #ifdef AUDIO_ENABLE | ||
309 | |||
310 | float tone_qwerty[][2] = SONG(QWERTY_SOUND); | ||
311 | float tone_dvorak[][2] = SONG(DVORAK_SOUND); | ||
312 | float tone_colemak[][2] = SONG(COLEMAK_SOUND); | ||
313 | float tone_plover[][2] = SONG(PLOVER_SOUND); | ||
314 | float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND); | ||
315 | float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); | ||
316 | #endif | ||
317 | |||
318 | // define variables for reactive RGB | ||
319 | bool TOG_STATUS = false; | ||
320 | int RGB_current_mode; | ||
321 | |||
322 | void persistent_default_layer_set(uint16_t default_layer) { | ||
323 | eeconfig_update_default_layer(default_layer); | ||
324 | default_layer_set(default_layer); | ||
325 | } | ||
326 | |||
327 | // Setting ADJUST layer RGB back to default | ||
328 | void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) { | ||
329 | if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) { | ||
330 | rgblight_mode(RGB_current_mode); | ||
331 | layer_on(layer3); | ||
332 | } else { | ||
333 | layer_off(layer3); | ||
334 | } | ||
335 | } | ||
336 | |||
337 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
338 | switch (keycode) { | ||
339 | case QWERTY: | ||
340 | if (record->event.pressed) { | ||
341 | #ifdef AUDIO_ENABLE | ||
342 | PLAY_SONG(tone_qwerty); | ||
343 | #endif | ||
344 | persistent_default_layer_set(1UL<<_QWERTY); | ||
345 | } | ||
346 | return false; | ||
347 | break; | ||
348 | case COLEMAK: | ||
349 | if (record->event.pressed) { | ||
350 | #ifdef AUDIO_ENABLE | ||
351 | PLAY_SONG(tone_colemak); | ||
352 | #endif | ||
353 | persistent_default_layer_set(1UL<<_COLEMAK); | ||
354 | } | ||
355 | return false; | ||
356 | break; | ||
357 | case DVORAK: | ||
358 | if (record->event.pressed) { | ||
359 | #ifdef AUDIO_ENABLE | ||
360 | PLAY_SONG(tone_dvorak); | ||
361 | #endif | ||
362 | persistent_default_layer_set(1UL<<_DVORAK); | ||
363 | } | ||
364 | return false; | ||
365 | break; | ||
366 | case LOWER: | ||
367 | if (record->event.pressed) { | ||
368 | //not sure how to have keyboard check mode and set it to a variable, so my work around | ||
369 | //uses another variable that would be set to true after the first time a reactive key is pressed. | ||
370 | if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false | ||
371 | } else { | ||
372 | TOG_STATUS = !TOG_STATUS; | ||
373 | rgblight_mode(16); | ||
374 | } | ||
375 | layer_on(_LOWER); | ||
376 | update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); | ||
377 | } else { | ||
378 | rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change | ||
379 | TOG_STATUS = false; | ||
380 | layer_off(_LOWER); | ||
381 | update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); | ||
382 | } | ||
383 | return false; | ||
384 | break; | ||
385 | case RAISE: | ||
386 | if (record->event.pressed) { | ||
387 | //not sure how to have keyboard check mode and set it to a variable, so my work around | ||
388 | //uses another variable that would be set to true after the first time a reactive key is pressed. | ||
389 | if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false | ||
390 | } else { | ||
391 | TOG_STATUS = !TOG_STATUS; | ||
392 | rgblight_mode(15); | ||
393 | } | ||
394 | layer_on(_RAISE); | ||
395 | update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); | ||
396 | } else { | ||
397 | rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change | ||
398 | layer_off(_RAISE); | ||
399 | TOG_STATUS = false; | ||
400 | update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); | ||
401 | } | ||
402 | return false; | ||
403 | break; | ||
404 | case ADJUST: | ||
405 | if (record->event.pressed) { | ||
406 | layer_on(_ADJUST); | ||
407 | } else { | ||
408 | layer_off(_ADJUST); | ||
409 | } | ||
410 | return false; | ||
411 | break; | ||
412 | case BACKLIT: | ||
413 | if (record->event.pressed) { | ||
414 | register_code(KC_RSFT); | ||
415 | #ifdef BACKLIGHT_ENABLE | ||
416 | backlight_step(); | ||
417 | #endif | ||
418 | } else { | ||
419 | unregister_code(KC_RSFT); | ||
420 | } | ||
421 | return false; | ||
422 | break; | ||
423 | //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released | ||
424 | case RGB_MOD: | ||
425 | if (record->event.pressed) { | ||
426 | rgblight_mode(RGB_current_mode); | ||
427 | rgblight_step(); | ||
428 | RGB_current_mode = rgblight_config.mode; | ||
429 | } | ||
430 | return false; | ||
431 | break; | ||
432 | } | ||
433 | return true; | ||
434 | } | ||
435 | |||
436 | void matrix_init_user(void) { | ||
437 | #ifdef AUDIO_ENABLE | ||
438 | startup_user(); | ||
439 | #endif | ||
440 | RGB_current_mode = rgblight_config.mode; | ||
441 | } | ||
442 | |||
443 | //SSD1306 OLED init and update loop, make sure to add #define SSD1306OLED in config.h | ||
444 | #ifdef SSD1306OLED | ||
445 | void matrix_master_OLED_init (void) { | ||
446 | TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000)); | ||
447 | iota_gfx_init(0); // turns on the display | ||
448 | } | ||
449 | |||
450 | void matrix_scan_user(void) { | ||
451 | iota_gfx_task(); // this is what updates the display continuously | ||
452 | } | ||
453 | #endif | ||
454 | |||
455 | #ifdef AUDIO_ENABLE | ||
456 | |||
457 | void startup_user() | ||
458 | { | ||
459 | _delay_ms(20); // gets rid of tick | ||
460 | } | ||
461 | |||
462 | void shutdown_user() | ||
463 | { | ||
464 | _delay_ms(150); | ||
465 | stop_all_notes(); | ||
466 | } | ||
467 | |||
468 | void music_on_user(void) | ||
469 | { | ||
470 | music_scale_user(); | ||
471 | } | ||
472 | |||
473 | void music_scale_user(void) | ||
474 | { | ||
475 | PLAY_SONG(music_scale); | ||
476 | } | ||
477 | |||
478 | #endif | ||
479 | |||
480 | /* | ||
481 | * Macro definition | ||
482 | */ | ||
483 | const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | ||
484 | { | ||
485 | if (!eeconfig_is_enabled()) { | ||
486 | eeconfig_init(); | ||
487 | } | ||
488 | |||
489 | switch (id) { | ||
490 | case KC_SAMPLEMACRO: | ||
491 | if (record->event.pressed){ | ||
492 | return MACRO (I(10), T(H), T(E), T(L), T(L), T(O), T(SPACE), T(W), T(O), T(R), T(L), T(D), END); | ||
493 | } | ||
494 | |||
495 | } | ||
496 | |||
497 | return MACRO_NONE; | ||
498 | } | ||
diff --git a/keyboards/helix/rev1/keymaps/OLED_sample/readme.md b/keyboards/helix/rev1/keymaps/OLED_sample/readme.md new file mode 100644 index 000000000..02888855b --- /dev/null +++ b/keyboards/helix/rev1/keymaps/OLED_sample/readme.md | |||
@@ -0,0 +1,25 @@ | |||
1 | SSD1306 OLED Display via I2C | ||
2 | ====== | ||
3 | |||
4 | Features | ||
5 | -------- | ||
6 | |||
7 | Some features supported by the firmware: | ||
8 | |||
9 | |||
10 | * I2C connection between the two halves is required as the OLED display will use this connection as well. Note this | ||
11 | requires pull-up resistors on the data and clock lines. | ||
12 | * OLED display will connect from either side | ||
13 | |||
14 | |||
15 | Wiring | ||
16 | ------ | ||
17 | |||
18 | |||
19 | Work in progress... | ||
20 | |||
21 | |||
22 | OLED Configuration | ||
23 | ------------------------------- | ||
24 | |||
25 | Work in progress... | ||
diff --git a/keyboards/helix/rev1/keymaps/OLED_sample/rules.mk b/keyboards/helix/rev1/keymaps/OLED_sample/rules.mk new file mode 100644 index 000000000..67a0ff2d8 --- /dev/null +++ b/keyboards/helix/rev1/keymaps/OLED_sample/rules.mk | |||
@@ -0,0 +1,25 @@ | |||
1 | |||
2 | # Build Options | ||
3 | # change to "no" to disable the options, or define them in the Makefile in | ||
4 | # the appropriate keymap folder that will get included automatically | ||
5 | # | ||
6 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) | ||
7 | MOUSEKEY_ENABLE = no # Mouse keys(+4700) | ||
8 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | ||
9 | CONSOLE_ENABLE = no # Console for debug(+400) | ||
10 | COMMAND_ENABLE = no # Commands for debug and configuration | ||
11 | NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
12 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality | ||
13 | MIDI_ENABLE = no # MIDI controls | ||
14 | AUDIO_ENABLE = no # Audio output on port C6 | ||
15 | UNICODE_ENABLE = no # Unicode | ||
16 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
17 | RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. | ||
18 | ONEHAND_ENABLE = no # Enable one-hand typing | ||
19 | |||
20 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | ||
21 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | ||
22 | |||
23 | ifndef QUANTUM_DIR | ||
24 | include ../../../../Makefile | ||
25 | endif | ||
diff --git a/keyboards/helix/rev1/keymaps/default/config.h b/keyboards/helix/rev1/keymaps/default/config.h new file mode 100644 index 000000000..7f33a4363 --- /dev/null +++ b/keyboards/helix/rev1/keymaps/default/config.h | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | This is the c configuration file for the keymap | ||
3 | |||
4 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
5 | Copyright 2015 Jack Humbert | ||
6 | |||
7 | This program is free software: you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation, either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | ||
20 | |||
21 | #ifndef CONFIG_USER_H | ||
22 | #define CONFIG_USER_H | ||
23 | |||
24 | #include "../../config.h" | ||
25 | |||
26 | /* Use I2C or Serial, not both */ | ||
27 | |||
28 | #define USE_SERIAL | ||
29 | // #define USE_I2C | ||
30 | |||
31 | /* Select hand configuration */ | ||
32 | |||
33 | #define MASTER_LEFT | ||
34 | // #define _MASTER_RIGHT | ||
35 | // #define EE_HANDS | ||
36 | |||
37 | #endif \ No newline at end of file | ||
diff --git a/keyboards/helix/rev1/keymaps/default/keymap.c b/keyboards/helix/rev1/keymaps/default/keymap.c new file mode 100644 index 000000000..d7cf34053 --- /dev/null +++ b/keyboards/helix/rev1/keymaps/default/keymap.c | |||
@@ -0,0 +1,349 @@ | |||
1 | #include "helix.h" | ||
2 | #include "action_layer.h" | ||
3 | #include "eeconfig.h" | ||
4 | |||
5 | extern keymap_config_t keymap_config; | ||
6 | |||
7 | // Each layer gets a name for readability, which is then used in the keymap matrix below. | ||
8 | // The underscores don't mean anything - you can have a layer called STUFF or any other name. | ||
9 | // Layer names don't all need to be of the same length, obviously, and you can also skip them | ||
10 | // entirely and just use numbers. | ||
11 | #define _QWERTY 0 | ||
12 | #define _COLEMAK 1 | ||
13 | #define _DVORAK 2 | ||
14 | #define _LOWER 3 | ||
15 | #define _RAISE 4 | ||
16 | #define _ADJUST 16 | ||
17 | |||
18 | enum 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 | |||
31 | #if HELIX_ROWS == 5 | ||
32 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
33 | |||
34 | /* Qwerty | ||
35 | * ,-----------------------------------------------------------------------------------. | ||
36 | * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | | ||
37 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
38 | * | Tab | Q | W | E | R | T | Y | U | I | O | P | Del | | ||
39 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
40 | * | Esc | A | S | D | F | G | H | J | K | L | ; | " | | ||
41 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
42 | * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter | | ||
43 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
44 | * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right | | ||
45 | * `-----------------------------------------------------------------------------------' | ||
46 | */ | ||
47 | [_QWERTY] = KEYMAP( \ | ||
48 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \ | ||
49 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_DEL, \ | ||
50 | KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \ | ||
51 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \ | ||
52 | ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
53 | ), | ||
54 | |||
55 | /* Colemak | ||
56 | * ,-----------------------------------------------------------------------------------. | ||
57 | * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | | ||
58 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
59 | * | Tab | Q | W | F | P | G | J | L | U | Y | ; | Del | | ||
60 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
61 | * | Esc | A | R | S | T | D | H | N | E | I | O | " | | ||
62 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
63 | * | Shift| Z | X | C | V | B | K | M | , | . | / |Enter | | ||
64 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
65 | * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right | | ||
66 | * `-----------------------------------------------------------------------------------' | ||
67 | */ | ||
68 | [_COLEMAK] = KEYMAP( \ | ||
69 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \ | ||
70 | KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_DEL, \ | ||
71 | KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \ | ||
72 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \ | ||
73 | ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
74 | ), | ||
75 | |||
76 | /* Dvorak | ||
77 | * ,-----------------------------------------------------------------------------------. | ||
78 | * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | | ||
79 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
80 | * | Tab | " | , | . | P | Y | F | G | C | R | L | Del | | ||
81 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
82 | * | Esc | A | O | E | U | I | D | H | T | N | S | / | | ||
83 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
84 | * | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter | | ||
85 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
86 | * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right | | ||
87 | * `-----------------------------------------------------------------------------------' | ||
88 | */ | ||
89 | [_DVORAK] = KEYMAP( \ | ||
90 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \ | ||
91 | KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_DEL, \ | ||
92 | KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \ | ||
93 | KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \ | ||
94 | ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
95 | ), | ||
96 | |||
97 | /* Lower | ||
98 | * ,-----------------------------------------------------------------------------------. | ||
99 | * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp | | ||
100 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
101 | * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Del | | ||
102 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
103 | * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | | \ | | | | ||
104 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
105 | * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter | | ||
106 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
107 | * | | | | | | | | Next | Vol- | Vol+ | Play | | ||
108 | * `-----------------------------------------------------------------------------------' | ||
109 | */ | ||
110 | [_LOWER] = KEYMAP( \ | ||
111 | KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \ | ||
112 | KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL, \ | ||
113 | KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \ | ||
114 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______, \ | ||
115 | _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
116 | ), | ||
117 | |||
118 | /* Raise | ||
119 | * ,-----------------------------------------------------------------------------------. | ||
120 | * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | | ||
121 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
122 | * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Del | | ||
123 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
124 | * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ | | ||
125 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
126 | * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Enter | | ||
127 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
128 | * | | | | | | | | Next | Vol- | Vol+ | Play | | ||
129 | * `-----------------------------------------------------------------------------------' | ||
130 | */ | ||
131 | [_RAISE] = KEYMAP( \ | ||
132 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \ | ||
133 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \ | ||
134 | KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \ | ||
135 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______, \ | ||
136 | _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
137 | ), | ||
138 | |||
139 | /* Adjust (Lower + Raise) | ||
140 | * ,-----------------------------------------------------------------------------------. | ||
141 | * | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | | ||
142 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
143 | * | | Reset| | | | | | | | | | Del | | ||
144 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
145 | * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak| | | | ||
146 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
147 | * | | | | | | | | | | | | | | ||
148 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
149 | * | | | | | | | | | | | | | ||
150 | * `-----------------------------------------------------------------------------------' | ||
151 | */ | ||
152 | [_ADJUST] = KEYMAP( \ | ||
153 | KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \ | ||
154 | _______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \ | ||
155 | _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \ | ||
156 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
157 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \ | ||
158 | ) | ||
159 | }; | ||
160 | |||
161 | #elif HELIX_ROWS == 4 | ||
162 | |||
163 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
164 | |||
165 | /* Qwerty | ||
166 | * ,-----------------------------------------------------------------------------------. | ||
167 | * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp | | ||
168 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
169 | * | Esc | A | S | D | F | G | H | J | K | L | ; | " | | ||
170 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
171 | * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter | | ||
172 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
173 | * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right | | ||
174 | * `-----------------------------------------------------------------------------------' | ||
175 | */ | ||
176 | |||
177 | [_QWERTY] = KEYMAP( \ | ||
178 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_DEL, \ | ||
179 | KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \ | ||
180 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \ | ||
181 | ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
182 | ), | ||
183 | |||
184 | /* Colemak | ||
185 | * ,-----------------------------------------------------------------------------------. | ||
186 | * | Tab | Q | W | F | P | G | J | L | U | Y | ; | Bksp | | ||
187 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
188 | * | Esc | A | R | S | T | D | H | N | E | I | O | " | | ||
189 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
190 | * | Shift| Z | X | C | V | B | K | M | , | . | / |Enter | | ||
191 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
192 | * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right | | ||
193 | * `-----------------------------------------------------------------------------------' | ||
194 | */ | ||
195 | [_COLEMAK] = KEYMAP( \ | ||
196 | KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, \ | ||
197 | KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \ | ||
198 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \ | ||
199 | ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
200 | ), | ||
201 | |||
202 | /* Dvorak | ||
203 | * ,-----------------------------------------------------------------------------------. | ||
204 | * | Tab | " | , | . | P | Y | F | G | C | R | L | Bksp | | ||
205 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
206 | * | Esc | A | O | E | U | I | D | H | T | N | S | / | | ||
207 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
208 | * | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter | | ||
209 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
210 | * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right | | ||
211 | * `-----------------------------------------------------------------------------------' | ||
212 | */ | ||
213 | [_DVORAK] = KEYMAP( \ | ||
214 | KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC, \ | ||
215 | KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \ | ||
216 | KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \ | ||
217 | ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
218 | ), | ||
219 | |||
220 | /* Lower | ||
221 | * ,-----------------------------------------------------------------------------------. | ||
222 | * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp | | ||
223 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
224 | * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | | \ | | | | ||
225 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
226 | * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter | | ||
227 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
228 | * | | | | | | | | Next | Vol- | Vol+ | Play | | ||
229 | * `-----------------------------------------------------------------------------------' | ||
230 | */ | ||
231 | [_LOWER] = KEYMAP( \ | ||
232 | KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \ | ||
233 | KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \ | ||
234 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______, \ | ||
235 | _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
236 | ), | ||
237 | |||
238 | /* Raise | ||
239 | * ,-----------------------------------------------------------------------------------. | ||
240 | * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | | ||
241 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
242 | * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ | | ||
243 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
244 | * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Enter | | ||
245 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
246 | * | | | | | | | | Next | Vol- | Vol+ | Play | | ||
247 | * `-----------------------------------------------------------------------------------' | ||
248 | */ | ||
249 | [_RAISE] = KEYMAP( \ | ||
250 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \ | ||
251 | KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \ | ||
252 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______, \ | ||
253 | _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
254 | ), | ||
255 | |||
256 | /* Adjust (Lower + Raise) | ||
257 | * ,-----------------------------------------------------------------------------------. | ||
258 | * | | Reset| | | | | | | | | | Del | | ||
259 | * |------+------+------+------+------+-------------+------+------+------+------+------| | ||
260 | * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak| | | | ||
261 | * |------+------+------+------+------+------|------+------+------+------+------+------| | ||
262 | * | | | | | | | | | | | | | | ||
263 | * |------+------+------+------+------+------+------+------+------+------+------+------| | ||
264 | * | | | | | | | | | | | | | ||
265 | * `-----------------------------------------------------------------------------------' | ||
266 | */ | ||
267 | [_ADJUST] = KEYMAP( \ | ||
268 | _______, RESET, _______, M_SAMPLE, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \ | ||
269 | _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \ | ||
270 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | ||
271 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \ | ||
272 | ) | ||
273 | }; | ||
274 | |||
275 | #else | ||
276 | #error "undefined keymaps" | ||
277 | #endif | ||
278 | |||
279 | #ifdef AUDIO_ENABLE | ||
280 | float tone_qwerty[][2] = SONG(QWERTY_SOUND); | ||
281 | float tone_dvorak[][2] = SONG(DVORAK_SOUND); | ||
282 | float tone_colemak[][2] = SONG(COLEMAK_SOUND); | ||
283 | #endif | ||
284 | |||
285 | void persistent_default_layer_set(uint16_t default_layer) { | ||
286 | eeconfig_update_default_layer(default_layer); | ||
287 | default_layer_set(default_layer); | ||
288 | } | ||
289 | |||
290 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
291 | switch (keycode) { | ||
292 | case QWERTY: | ||
293 | if (record->event.pressed) { | ||
294 | #ifdef AUDIO_ENABLE | ||
295 | PLAY_SONG(tone_qwerty); | ||
296 | #endif | ||
297 | persistent_default_layer_set(1UL<<_QWERTY); | ||
298 | } | ||
299 | return false; | ||
300 | break; | ||
301 | case COLEMAK: | ||
302 | if (record->event.pressed) { | ||
303 | #ifdef AUDIO_ENABLE | ||
304 | PLAY_SONG(tone_colemak); | ||
305 | #endif | ||
306 | persistent_default_layer_set(1UL<<_COLEMAK); | ||
307 | } | ||
308 | return false; | ||
309 | break; | ||
310 | case DVORAK: | ||
311 | if (record->event.pressed) { | ||
312 | #ifdef AUDIO_ENABLE | ||
313 | PLAY_SONG(tone_dvorak); | ||
314 | #endif | ||
315 | persistent_default_layer_set(1UL<<_DVORAK); | ||
316 | } | ||
317 | return false; | ||
318 | break; | ||
319 | case LOWER: | ||
320 | if (record->event.pressed) { | ||
321 | layer_on(_LOWER); | ||
322 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
323 | } else { | ||
324 | layer_off(_LOWER); | ||
325 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
326 | } | ||
327 | return false; | ||
328 | break; | ||
329 | case RAISE: | ||
330 | if (record->event.pressed) { | ||
331 | layer_on(_RAISE); | ||
332 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
333 | } else { | ||
334 | layer_off(_RAISE); | ||
335 | update_tri_layer(_LOWER, _RAISE, _ADJUST); | ||
336 | } | ||
337 | return false; | ||
338 | break; | ||
339 | case ADJUST: | ||
340 | if (record->event.pressed) { | ||
341 | layer_on(_ADJUST); | ||
342 | } else { | ||
343 | layer_off(_ADJUST); | ||
344 | } | ||
345 | return false; | ||
346 | break; | ||
347 | } | ||
348 | return true; | ||
349 | } | ||
diff --git a/keyboards/helix/rev1/keymaps/default/rules.mk b/keyboards/helix/rev1/keymaps/default/rules.mk new file mode 100644 index 000000000..457a3d01d --- /dev/null +++ b/keyboards/helix/rev1/keymaps/default/rules.mk | |||
@@ -0,0 +1,3 @@ | |||
1 | ifndef QUANTUM_DIR | ||
2 | include ../../../../Makefile | ||
3 | endif | ||
diff --git a/keyboards/helix/rev1/matrix.c b/keyboards/helix/rev1/matrix.c new file mode 100644 index 000000000..375057a6f --- /dev/null +++ b/keyboards/helix/rev1/matrix.c | |||
@@ -0,0 +1,316 @@ | |||
1 | /* | ||
2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation, either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | /* | ||
19 | * scan matrix | ||
20 | */ | ||
21 | #include <stdint.h> | ||
22 | #include <stdbool.h> | ||
23 | #include <avr/io.h> | ||
24 | #include <avr/wdt.h> | ||
25 | #include <avr/interrupt.h> | ||
26 | #include <util/delay.h> | ||
27 | #include "print.h" | ||
28 | #include "debug.h" | ||
29 | #include "util.h" | ||
30 | #include "matrix.h" | ||
31 | #include "split_util.h" | ||
32 | #include "pro_micro.h" | ||
33 | #include "config.h" | ||
34 | |||
35 | #ifdef USE_MATRIX_I2C | ||
36 | # include "i2c.h" | ||
37 | #else // USE_SERIAL | ||
38 | # include "serial.h" | ||
39 | #endif | ||
40 | |||
41 | #ifndef DEBOUNCE | ||
42 | # define DEBOUNCE 5 | ||
43 | #endif | ||
44 | |||
45 | #define ERROR_DISCONNECT_COUNT 5 | ||
46 | |||
47 | static uint8_t debouncing = DEBOUNCE; | ||
48 | static const int ROWS_PER_HAND = MATRIX_ROWS/2; | ||
49 | static uint8_t error_count = 0; | ||
50 | |||
51 | static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; | ||
52 | static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; | ||
53 | |||
54 | /* matrix state(1:on, 0:off) */ | ||
55 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
56 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
57 | |||
58 | static matrix_row_t read_cols(void); | ||
59 | static void init_cols(void); | ||
60 | static void unselect_rows(void); | ||
61 | static void select_row(uint8_t row); | ||
62 | |||
63 | __attribute__ ((weak)) | ||
64 | void matrix_init_quantum(void) { | ||
65 | matrix_init_kb(); | ||
66 | } | ||
67 | |||
68 | __attribute__ ((weak)) | ||
69 | void matrix_scan_quantum(void) { | ||
70 | matrix_scan_kb(); | ||
71 | } | ||
72 | |||
73 | __attribute__ ((weak)) | ||
74 | void matrix_init_kb(void) { | ||
75 | matrix_init_user(); | ||
76 | } | ||
77 | |||
78 | __attribute__ ((weak)) | ||
79 | void matrix_scan_kb(void) { | ||
80 | matrix_scan_user(); | ||
81 | } | ||
82 | |||
83 | __attribute__ ((weak)) | ||
84 | void matrix_init_user(void) { | ||
85 | } | ||
86 | |||
87 | __attribute__ ((weak)) | ||
88 | void matrix_scan_user(void) { | ||
89 | } | ||
90 | |||
91 | inline | ||
92 | uint8_t matrix_rows(void) | ||
93 | { | ||
94 | return MATRIX_ROWS; | ||
95 | } | ||
96 | |||
97 | inline | ||
98 | uint8_t matrix_cols(void) | ||
99 | { | ||
100 | return MATRIX_COLS; | ||
101 | } | ||
102 | |||
103 | void 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 | |||
123 | uint8_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_MATRIX_I2C | ||
153 | |||
154 | // Get rows from other half over i2c | ||
155 | int 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 { | ||
177 | i2c_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 | |||
187 | int 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 | |||
201 | uint8_t matrix_scan(void) | ||
202 | { | ||
203 | int ret = _matrix_scan(); | ||
204 | |||
205 | |||
206 | |||
207 | #ifdef USE_MATRIX_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 | |||
233 | void matrix_slave_scan(void) { | ||
234 | _matrix_scan(); | ||
235 | |||
236 | int offset = (isLeftHand) ? 0 : (MATRIX_ROWS / 2); | ||
237 | |||
238 | #ifdef USE_MATRIX_I2C | ||
239 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | ||
240 | /* i2c_slave_buffer[i] = matrix[offset+i]; */ | ||
241 | i2c_slave_buffer[i] = matrix[offset+i]; | ||
242 | } | ||
243 | #else // USE_SERIAL | ||
244 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | ||
245 | serial_slave_buffer[i] = matrix[offset+i]; | ||
246 | } | ||
247 | #endif | ||
248 | } | ||
249 | |||
250 | bool matrix_is_modified(void) | ||
251 | { | ||
252 | if (debouncing) return false; | ||
253 | return true; | ||
254 | } | ||
255 | |||
256 | inline | ||
257 | bool matrix_is_on(uint8_t row, uint8_t col) | ||
258 | { | ||
259 | return (matrix[row] & ((matrix_row_t)1<<col)); | ||
260 | } | ||
261 | |||
262 | inline | ||
263 | matrix_row_t matrix_get_row(uint8_t row) | ||
264 | { | ||
265 | return matrix[row]; | ||
266 | } | ||
267 | |||
268 | void 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 | |||
278 | uint8_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 | |||
287 | static 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 | |||
295 | static 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 | |||
304 | static 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 | |||
312 | static 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/helix/rev1/rev1.c b/keyboards/helix/rev1/rev1.c new file mode 100644 index 000000000..950e4eec3 --- /dev/null +++ b/keyboards/helix/rev1/rev1.c | |||
@@ -0,0 +1,39 @@ | |||
1 | #include "helix.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 | ||
9 | void 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 | |||
15 | void matrix_init_kb(void) { | ||
16 | |||
17 | #ifdef AUDIO_ENABLE | ||
18 | _delay_ms(20); // gets rid of tick | ||
19 | PLAY_SONG(tone_startup); | ||
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 | |||
33 | void shutdown_kb(void) { | ||
34 | #ifdef AUDIO_ENABLE | ||
35 | PLAY_SONG(tone_goodbye); | ||
36 | _delay_ms(150); | ||
37 | stop_all_notes(); | ||
38 | #endif | ||
39 | } | ||
diff --git a/keyboards/helix/rev1/rev1.h b/keyboards/helix/rev1/rev1.h new file mode 100644 index 000000000..fb56de022 --- /dev/null +++ b/keyboards/helix/rev1/rev1.h | |||
@@ -0,0 +1,145 @@ | |||
1 | #ifndef REV1_H | ||
2 | #define REV1_CONFIG_H | ||
3 | |||
4 | #include "../helix.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 | |||
21 | #if HELIX_ROWS == 3 | ||
22 | #ifndef FLIP_HALF | ||
23 | // Standard Keymap | ||
24 | // (TRRS jack on the left half is to the right, TRRS jack on the right half is to the left) | ||
25 | #define KEYMAP( \ | ||
26 | L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ | ||
27 | L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ | ||
28 | L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \ | ||
29 | ) \ | ||
30 | { \ | ||
31 | { L00, L01, L02, L03, L04, L05 }, \ | ||
32 | { L10, L11, L12, L13, L14, L15 }, \ | ||
33 | { L20, L21, L22, L23, L24, L25 }, \ | ||
34 | { R05, R04, R03, R02, R01, R00 }, \ | ||
35 | { R15, R14, R13, R12, R11, R10 }, \ | ||
36 | { R25, R24, R23, R22, R21, R20 }, \ | ||
37 | } | ||
38 | #else | ||
39 | // Keymap with right side flipped | ||
40 | // (TRRS jack on both halves are to the right) | ||
41 | #define KEYMAP( \ | ||
42 | L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ | ||
43 | L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ | ||
44 | L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \ | ||
45 | ) \ | ||
46 | { \ | ||
47 | { L00, L01, L02, L03, L04, L05 }, \ | ||
48 | { L10, L11, L12, L13, L14, L15 }, \ | ||
49 | { L20, L21, L22, L23, L24, L25 }, \ | ||
50 | { R00, R01, R02, R03, R04, R05 }, \ | ||
51 | { R10, R11, R12, R13, R14, R15 }, \ | ||
52 | { R20, R21, R22, R23, R24, R25 }, \ | ||
53 | } | ||
54 | #endif | ||
55 | #elif HELIX_ROWS == 4 | ||
56 | #ifndef FLIP_HALF | ||
57 | // Standard Keymap | ||
58 | // (TRRS jack on the left half is to the right, TRRS jack on the right half is to the left) | ||
59 | #define KEYMAP( \ | ||
60 | L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ | ||
61 | L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ | ||
62 | L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \ | ||
63 | L30, L31, L32, L33, L34, L35, R30, R31, R32, R33, R34, R35 \ | ||
64 | ) \ | ||
65 | { \ | ||
66 | { L00, L01, L02, L03, L04, L05 }, \ | ||
67 | { L10, L11, L12, L13, L14, L15 }, \ | ||
68 | { L20, L21, L22, L23, L24, L25 }, \ | ||
69 | { L30, L31, L32, L33, L34, L35 }, \ | ||
70 | { R05, R04, R03, R02, R01, R00 }, \ | ||
71 | { R15, R14, R13, R12, R11, R10 }, \ | ||
72 | { R25, R24, R23, R22, R21, R20 }, \ | ||
73 | { R35, R34, R33, R32, R31, R30 } \ | ||
74 | } | ||
75 | #else | ||
76 | // Keymap with right side flipped | ||
77 | // (TRRS jack on both halves are to the right) | ||
78 | #define KEYMAP( \ | ||
79 | L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ | ||
80 | L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ | ||
81 | L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \ | ||
82 | L30, L31, L32, L33, L34, L35, R30, R31, R32, R33, R34, R35 \ | ||
83 | ) \ | ||
84 | { \ | ||
85 | { L00, L01, L02, L03, L04, L05 }, \ | ||
86 | { L10, L11, L12, L13, L14, L15 }, \ | ||
87 | { L20, L21, L22, L23, L24, L25 }, \ | ||
88 | { L30, L31, L32, L33, L34, L35 }, \ | ||
89 | { R00, R01, R02, R03, R04, R05 }, \ | ||
90 | { R10, R11, R12, R13, R14, R15 }, \ | ||
91 | { R20, R21, R22, R23, R24, R25 }, \ | ||
92 | { R30, R31, R32, R33, R34, R35 } \ | ||
93 | } | ||
94 | #endif | ||
95 | #elif HELIX_ROWS == 5 | ||
96 | #ifndef FLIP_HALF | ||
97 | // Standard Keymap | ||
98 | // (TRRS jack on the left half is to the right, TRRS jack on the right half is to the left) | ||
99 | #define KEYMAP( \ | ||
100 | L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ | ||
101 | L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ | ||
102 | L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \ | ||
103 | L30, L31, L32, L33, L34, L35, R30, R31, R32, R33, R34, R35, \ | ||
104 | L40, L41, L42, L43, L44, L45, R40, R41, R42, R43, R44, R45 \ | ||
105 | ) \ | ||
106 | { \ | ||
107 | { L00, L01, L02, L03, L04, L05 }, \ | ||
108 | { L10, L11, L12, L13, L14, L15 }, \ | ||
109 | { L20, L21, L22, L23, L24, L25 }, \ | ||
110 | { L30, L31, L32, L33, L34, L35 }, \ | ||
111 | { L40, L41, L42, L43, L44, L45 }, \ | ||
112 | { R05, R04, R03, R02, R01, R00 }, \ | ||
113 | { R15, R14, R13, R12, R11, R10 }, \ | ||
114 | { R25, R24, R23, R22, R21, R20 }, \ | ||
115 | { R35, R34, R33, R32, R31, R30 }, \ | ||
116 | { R45, R44, R43, R42, R41, R40 } \ | ||
117 | } | ||
118 | #else | ||
119 | // Keymap with right side flipped | ||
120 | // (TRRS jack on both halves are to the right) | ||
121 | #define KEYMAP( \ | ||
122 | L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ | ||
123 | L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ | ||
124 | L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \ | ||
125 | L30, L31, L32, L33, L34, L35, R30, R31, R32, R33, R34, R35, \ | ||
126 | L40, L41, L42, L43, L44, L45, R40, R41, R42, R43, R44, R45 \ | ||
127 | ) \ | ||
128 | { \ | ||
129 | { L00, L01, L02, L03, L04, L05 }, \ | ||
130 | { L10, L11, L12, L13, L14, L15 }, \ | ||
131 | { L20, L21, L22, L23, L24, L25 }, \ | ||
132 | { L30, L31, L32, L33, L34, L35 }, \ | ||
133 | { L40, L41, L42, L43, L44, L45 }, \ | ||
134 | { R00, R01, R02, R03, R04, R05 }, \ | ||
135 | { R10, R11, R12, R13, R14, R15 }, \ | ||
136 | { R20, R21, R22, R23, R24, R25 }, \ | ||
137 | { R30, R31, R32, R33, R34, R35 }, \ | ||
138 | { R40, R41, R42, R43, R44, R45 } \ | ||
139 | } | ||
140 | #endif | ||
141 | #else | ||
142 | #error "expected HELIX_ROWS 3 or 4 or 5" | ||
143 | #endif | ||
144 | |||
145 | #endif | ||
diff --git a/keyboards/helix/rev1/rules.mk b/keyboards/helix/rev1/rules.mk new file mode 100644 index 000000000..daba80eae --- /dev/null +++ b/keyboards/helix/rev1/rules.mk | |||
@@ -0,0 +1,4 @@ | |||
1 | SRC += rev1/matrix.c \ | ||
2 | rev1/split_util.c | ||
3 | |||
4 | BACKLIGHT_ENABLE = no | ||
diff --git a/keyboards/helix/rev1/split_util.c b/keyboards/helix/rev1/split_util.c new file mode 100644 index 000000000..5debd6e00 --- /dev/null +++ b/keyboards/helix/rev1/split_util.c | |||
@@ -0,0 +1,86 @@ | |||
1 | #include <avr/io.h> | ||
2 | #include <avr/wdt.h> | ||
3 | #include <avr/power.h> | ||
4 | #include <avr/interrupt.h> | ||
5 | #include <util/delay.h> | ||
6 | #include <avr/eeprom.h> | ||
7 | #include "split_util.h" | ||
8 | #include "matrix.h" | ||
9 | #include "keyboard.h" | ||
10 | #include "config.h" | ||
11 | |||
12 | #ifdef USE_MATRIX_I2C | ||
13 | # include "i2c.h" | ||
14 | #else | ||
15 | # include "serial.h" | ||
16 | #endif | ||
17 | |||
18 | volatile bool isLeftHand = true; | ||
19 | |||
20 | static 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 | |||
33 | static void keyboard_master_setup(void) { | ||
34 | #ifdef USE_I2C | ||
35 | #ifdef SSD1306OLED | ||
36 | matrix_master_OLED_init (); | ||
37 | #endif | ||
38 | #endif | ||
39 | #ifdef USE_MATRIX_I2C | ||
40 | i2c_master_init(); | ||
41 | #else | ||
42 | serial_master_init(); | ||
43 | #endif | ||
44 | } | ||
45 | |||
46 | static void keyboard_slave_setup(void) { | ||
47 | #ifdef USE_MATRIX_I2C | ||
48 | i2c_slave_init(SLAVE_I2C_ADDRESS); | ||
49 | #else | ||
50 | serial_slave_init(); | ||
51 | #endif | ||
52 | } | ||
53 | |||
54 | bool has_usb(void) { | ||
55 | USBCON |= (1 << OTGPADE); //enables VBUS pad | ||
56 | _delay_us(5); | ||
57 | return (USBSTA & (1<<VBUS)); //checks state of VBUS | ||
58 | } | ||
59 | |||
60 | void split_keyboard_setup(void) { | ||
61 | setup_handedness(); | ||
62 | |||
63 | if (has_usb()) { | ||
64 | keyboard_master_setup(); | ||
65 | } else { | ||
66 | keyboard_slave_setup(); | ||
67 | } | ||
68 | sei(); | ||
69 | } | ||
70 | |||
71 | void keyboard_slave_loop(void) { | ||
72 | matrix_init(); | ||
73 | |||
74 | while (1) { | ||
75 | matrix_slave_scan(); | ||
76 | } | ||
77 | } | ||
78 | |||
79 | // this code runs before the usb and keyboard is initialized | ||
80 | void matrix_setup(void) { | ||
81 | split_keyboard_setup(); | ||
82 | |||
83 | if (!has_usb()) { | ||
84 | keyboard_slave_loop(); | ||
85 | } | ||
86 | } | ||
diff --git a/keyboards/helix/rev1/split_util.h b/keyboards/helix/rev1/split_util.h new file mode 100644 index 000000000..3ae76c209 --- /dev/null +++ b/keyboards/helix/rev1/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 | |||
13 | extern volatile bool isLeftHand; | ||
14 | |||
15 | // slave version of matix scan, defined in matrix.c | ||
16 | void matrix_slave_scan(void); | ||
17 | |||
18 | void split_keyboard_setup(void); | ||
19 | bool has_usb(void); | ||
20 | void keyboard_slave_loop(void); | ||
21 | |||
22 | void matrix_master_OLED_init (void); | ||
23 | |||
24 | #endif | ||
diff --git a/keyboards/helix/rev2/config.h b/keyboards/helix/rev2/config.h new file mode 100644 index 000000000..42878d5c0 --- /dev/null +++ b/keyboards/helix/rev2/config.h | |||
@@ -0,0 +1,97 @@ | |||
1 | /* | ||
2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
3 | Copyright 2015 Jack Humbert | ||
4 | |||
5 | This program is free software: you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation, either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #ifndef REV2_CONFIG_H | ||
20 | #define REV2_CONFIG_H | ||
21 | |||
22 | #include "../config.h" | ||
23 | |||
24 | /* USB Device descriptor parameter */ | ||
25 | #define VENDOR_ID 0xFEED | ||
26 | #define PRODUCT_ID 0x3060 | ||
27 | #define DEVICE_VER 0x0001 | ||
28 | #define MANUFACTURER Yushakobo | ||
29 | #define PRODUCT Helix Beta | ||
30 | #define DESCRIPTION A split keyboard for the cheap makers | ||
31 | |||
32 | #define HELIX_ROWS 5 | ||
33 | |||
34 | /* key matrix size */ | ||
35 | // Rows are doubled-up | ||
36 | #if HELIX_ROWS == 4 | ||
37 | #define MATRIX_ROWS 8 | ||
38 | #define MATRIX_COLS 7 | ||
39 | #define MATRIX_ROW_PINS { D4, C6, D7, E6 } | ||
40 | #elif HELIX_ROWS == 5 | ||
41 | #define MATRIX_ROWS 10 | ||
42 | #define MATRIX_COLS 7 | ||
43 | #define MATRIX_ROW_PINS { D4, C6, D7, E6, B4 } | ||
44 | #else | ||
45 | #error "expected HELIX_ROWS 4 or 5" | ||
46 | #endif | ||
47 | |||
48 | // wiring of each half | ||
49 | #define MATRIX_COL_PINS { F4, F5, F6, F7, B1, B3, B2 } | ||
50 | // #define MATRIX_COL_PINS { B2, B3, B1, F7, F6, F5, F4 } //uncomment this line and comment line above if you need to reverse left-to-right key order | ||
51 | |||
52 | /* define if matrix has ghost */ | ||
53 | //#define MATRIX_HAS_GHOST | ||
54 | |||
55 | /* number of backlight levels */ | ||
56 | // #define BACKLIGHT_LEVELS 3 | ||
57 | |||
58 | /* Set 0 if debouncing isn't needed */ | ||
59 | #define DEBOUNCING_DELAY 5 | ||
60 | |||
61 | /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ | ||
62 | //#define LOCKING_SUPPORT_ENABLE | ||
63 | /* Locking resynchronize hack */ | ||
64 | //#define LOCKING_RESYNC_ENABLE | ||
65 | |||
66 | /* key combination for command */ | ||
67 | #define IS_COMMAND() ( \ | ||
68 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
69 | ) | ||
70 | |||
71 | /* ws2812 RGB LED */ | ||
72 | #define RGB_DI_PIN D3 | ||
73 | #define RGBLIGHT_TIMER | ||
74 | #define RGBLED_NUM 12 // Number of LEDs | ||
75 | #define ws2812_PORTREG PORTD | ||
76 | #define ws2812_DDRREG DDRD | ||
77 | |||
78 | /* | ||
79 | * Feature disable options | ||
80 | * These options are also useful to firmware size reduction. | ||
81 | */ | ||
82 | |||
83 | /* disable debug print */ | ||
84 | // #define NO_DEBUG | ||
85 | |||
86 | /* disable print */ | ||
87 | // #define NO_PRINT | ||
88 | |||
89 | /* disable action features */ | ||
90 | //#define NO_ACTION_LAYER | ||
91 | //#define NO_ACTION_TAPPING | ||
92 | //#define NO_ACTION_ONESHOT | ||
93 | //#define NO_ACTION_MACRO | ||
94 | //#define NO_ACTION_FUNCTION | ||
95 | |||
96 | |||
97 | #endif | ||
diff --git a/keyboards/helix/rev2/keymaps/default/config.h b/keyboards/helix/rev2/keymaps/default/config.h new file mode 100644 index 000000000..1b3875fcd --- /dev/null +++ b/keyboards/helix/rev2/keymaps/default/config.h | |||
@@ -0,0 +1,54 @@ | |||
1 | /* | ||
2 | This is the c configuration file for the keymap | ||
3 | |||
4 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
5 | Copyright 2015 Jack Humbert | ||
6 | |||
7 | This program is free software: you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation, either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | ||
20 | |||
21 | #ifndef CONFIG_USER_H | ||
22 | #define CONFIG_USER_H | ||
23 | |||
24 | #include "../../config.h" | ||
25 | |||
26 | /* Use I2C or Serial */ | ||
27 | |||
28 | #define USE_I2C | ||
29 | #define USE_SERIAL | ||
30 | //#define USE_MATRIX_I2C | ||
31 | |||
32 | /* Select hand configuration */ | ||
33 | |||
34 | #define MASTER_LEFT | ||
35 | // #define MASTER_RIGHT | ||
36 | // #define EE_HANDS | ||
37 | |||
38 | //#define SSD1306OLED | ||
39 | |||
40 | #define USE_SERIAL_PD2 | ||
41 | |||
42 | #define PREVENT_STUCK_MODIFIERS | ||
43 | #define TAPPING_FORCE_HOLD | ||
44 | #define TAPPING_TERM 100 | ||
45 | |||
46 | |||
47 | #undef RGBLED_NUM | ||
48 | #define RGBLIGHT_ANIMATIONS | ||
49 | #define RGBLED_NUM 6 | ||
50 | #define RGBLIGHT_LIMIT_VAL 255 | ||
51 | #define RGBLIGHT_HUE_STEP 10 | ||
52 | #define RGBLIGHT_SAT_STEP 17 | ||
53 | #define RGBLIGHT_VAL_STEP 17 | ||
54 | #endif | ||
diff --git a/keyboards/helix/rev2/keymaps/default/keymap.c b/keyboards/helix/rev2/keymaps/default/keymap.c new file mode 100644 index 000000000..b8a9baee3 --- /dev/null +++ b/keyboards/helix/rev2/keymaps/default/keymap.c | |||
@@ -0,0 +1,616 @@ | |||
1 | #include "helix.h" | ||
2 | #include "bootloader.h" | ||
3 | #include "action_layer.h" | ||
4 | #include "eeconfig.h" | ||
5 | #ifdef PROTOCOL_LUFA | ||
6 | #include "lufa.h" | ||
7 | #include "split_util.h" | ||
8 | #endif | ||
9 | #include "LUFA/Drivers/Peripheral/TWI.h" | ||
10 | #ifdef AUDIO_ENABLE | ||
11 | #include "audio.h" | ||
12 | #endif | ||
13 | #ifdef SSD1306OLED | ||
14 | #include "ssd1306.h" | ||
15 | #endif | ||
16 | |||
17 | extern keymap_config_t keymap_config; | ||
18 | |||
19 | #ifdef RGBLIGHT_ENABLE | ||
20 | //Following line allows macro to read current RGB settings | ||
21 | extern rgblight_config_t rgblight_config; | ||
22 | #endif | ||
23 | |||
24 | extern uint8_t is_master; | ||
25 | |||
26 | // Each layer gets a name for readability, which is then used in the keymap matrix below. | ||
27 | // The underscores don't mean anything - you can have a layer called STUFF or any other name. | ||
28 | // Layer names don't all need to be of the same length, obviously, and you can also skip them | ||
29 | // entirely and just use numbers. | ||
30 | #define _QWERTY 0 | ||
31 | #define _COLEMAK 1 | ||
32 | #define _DVORAK 2 | ||
33 | #define _LOWER 3 | ||
34 | #define _RAISE 4 | ||
35 | #define _ADJUST 16 | ||
36 | |||
37 | enum custom_keycodes { | ||
38 | QWERTY = SAFE_RANGE, | ||
39 | COLEMAK, | ||
40 | DVORAK, | ||
41 | LOWER, | ||
42 | RAISE, | ||
43 | ADJUST, | ||
44 | BACKLIT, | ||
45 | EISU, | ||
46 | KANA, | ||
47 | RGBRST | ||
48 | }; | ||
49 | |||
50 | enum macro_keycodes { | ||
51 | KC_SAMPLEMACRO, | ||
52 | }; | ||
53 | |||
54 | |||
55 | // Fillers to make layering more clear | ||
56 | #define _______ KC_TRNS | ||
57 | #define XXXXXXX KC_NO | ||
58 | //Macros | ||
59 | #define M_SAMPLE M(KC_SAMPLEMACRO) | ||
60 | |||
61 | #if HELIX_ROWS == 5 | ||
62 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
63 | |||
64 | /* Qwerty | ||
65 | * ,-----------------------------------------. ,-----------------------------------------. | ||
66 | * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del | | ||
67 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
68 | * | Tab | Q | W | E | R | T | | Y | U | I | O | P | Bksp | | ||
69 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
70 | * | Ctrl | A | S | D | F | G | | H | J | K | L | ; | ' | | ||
71 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
72 | * | Shift| Z | X | C | V | B | [ | ] | N | M | , | . | / |Enter | | ||
73 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
74 | * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right | | ||
75 | * `-------------------------------------------------------------------------------------------------' | ||
76 | */ | ||
77 | [_QWERTY] = KEYMAP( \ | ||
78 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \ | ||
79 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \ | ||
80 | KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \ | ||
81 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LBRC, KC_RBRC, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \ | ||
82 | ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
83 | ), | ||
84 | |||
85 | /* Colemak | ||
86 | * ,-----------------------------------------. ,-----------------------------------------. | ||
87 | * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del | | ||
88 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
89 | * | Tab | Q | W | F | P | G | | J | L | U | Y | ; | Bksp | | ||
90 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
91 | * | Ctrl | A | R | S | T | D | | H | N | E | I | O | ' | | ||
92 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
93 | * | Shift| Z | X | C | V | B | [ | ] | K | M | , | . | / |Enter | | ||
94 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
95 | * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right | | ||
96 | * `-------------------------------------------------------------------------------------------------' | ||
97 | */ | ||
98 | [_COLEMAK] = KEYMAP( \ | ||
99 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \ | ||
100 | KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, \ | ||
101 | KC_LCTL, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \ | ||
102 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LBRC, KC_RBRC, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \ | ||
103 | ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
104 | ), | ||
105 | |||
106 | /* Dvorak | ||
107 | * ,-----------------------------------------. ,-----------------------------------------. | ||
108 | * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Bksp | | ||
109 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
110 | * | Tab | ' | , | . | P | Y | | F | G | C | R | L | Del | | ||
111 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
112 | * | Ctrl | A | O | E | U | I | | D | H | T | N | S | / | | ||
113 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
114 | * | Shift| ; | Q | J | K | X | [ | ] | B | M | W | V | Z |Enter | | ||
115 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
116 | * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right | | ||
117 | * `-------------------------------------------------------------------------------------------------' | ||
118 | */ | ||
119 | [_DVORAK] = KEYMAP( \ | ||
120 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \ | ||
121 | KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_DEL, \ | ||
122 | KC_LCTL, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \ | ||
123 | KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_LBRC, KC_RBRC, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \ | ||
124 | ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
125 | ), | ||
126 | |||
127 | /* Lower | ||
128 | * ,-----------------------------------------. ,-----------------------------------------. | ||
129 | * | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | | | ||
130 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
131 | * | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | | | ||
132 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
133 | * | | F1 | F2 | F3 | F4 | F5 | | F6 | _ | + | { | } | | | | ||
134 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
135 | * | | F7 | F8 | F9 | F10 | F11 | ( | ) | F12 | | | Home | End | | | ||
136 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
137 | * | | | | | | | | | | | Next | Vol- | Vol+ | Play | | ||
138 | * `-------------------------------------------------------------------------------------------------' | ||
139 | */ | ||
140 | [_LOWER] = KEYMAP( \ | ||
141 | KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, \ | ||
142 | KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, \ | ||
143 | _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \ | ||
144 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_LPRN, KC_RPRN, KC_F12, _______, _______, KC_HOME, KC_END, _______, \ | ||
145 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
146 | ), | ||
147 | |||
148 | /* Raise | ||
149 | * ,-----------------------------------------. ,-----------------------------------------. | ||
150 | * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Bksp | | ||
151 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
152 | * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del | | ||
153 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
154 | * | | F1 | F2 | F3 | F4 | F5 | | F6 | - | = | [ | ] | \ | | ||
155 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
156 | * | | F7 | F8 | F9 | F10 | F11 | | | F12 | | |PageDn|PageUp| | | ||
157 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
158 | * | | | | | | | | | | | Next | Vol- | Vol+ | Play | | ||
159 | * `-------------------------------------------------------------------------------------------------' | ||
160 | */ | ||
161 | [_RAISE] = KEYMAP( \ | ||
162 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \ | ||
163 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \ | ||
164 | _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \ | ||
165 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, KC_F12, _______, _______, KC_PGDN, KC_PGUP, _______, \ | ||
166 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
167 | ), | ||
168 | |||
169 | /* Adjust (Lower + Raise) | ||
170 | * ,-----------------------------------------. ,-----------------------------------------. | ||
171 | * | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 | | ||
172 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
173 | * | | Reset|RGBRST| | | | | | | | | | Del | | ||
174 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
175 | * | | | |Aud on|Audoff| Mac | | Win |Qwerty|Colemk|Dvorak| | | | ||
176 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
177 | * | | | | | | | | | | |RGB ON| HUE+ | SAT+ | VAL+ | | ||
178 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
179 | * | | | | | | | | | | | MODE | HUE- | SAT- | VAL- | | ||
180 | * `-------------------------------------------------------------------------------------------------' | ||
181 | */ | ||
182 | [_ADJUST] = KEYMAP( \ | ||
183 | KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \ | ||
184 | _______, RESET, RGBRST, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \ | ||
185 | _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \ | ||
186 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, \ | ||
187 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SMOD,RGB_HUD, RGB_SAD, RGB_VAD \ | ||
188 | ) | ||
189 | }; | ||
190 | |||
191 | #elif HELIX_ROWS == 4 | ||
192 | |||
193 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
194 | |||
195 | /* Qwerty | ||
196 | * ,-----------------------------------------. ,-----------------------------------------. | ||
197 | * | Tab | Q | W | E | R | T | | Y | U | I | O | P | Bksp | | ||
198 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
199 | * | Ctrl | A | S | D | F | G | | H | J | K | L | ; | ' | | ||
200 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
201 | * | Shift| Z | X | C | V | B | | N | M | , | . | / |Enter | | ||
202 | * |------+------+------+------+------+------+-------------+------+------+------+------+------+------| | ||
203 | * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right | | ||
204 | * `-------------------------------------------------------------------------------------------------' | ||
205 | */ | ||
206 | [_QWERTY] = KEYMAP( \ | ||
207 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \ | ||
208 | KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \ | ||
209 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \ | ||
210 | ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
211 | ), | ||
212 | |||
213 | /* Colemak | ||
214 | * ,-----------------------------------------. ,-----------------------------------------. | ||
215 | * | Tab | Q | W | F | P | G | | J | L | U | Y | ; | Bksp | | ||
216 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
217 | * | Ctrl | A | R | S | T | D | | H | N | E | I | O | ' | | ||
218 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
219 | * | Shift| Z | X | C | V | B | | K | M | , | . | / |Enter | | ||
220 | * |------+------+------+------+------+------+-------------+------+------+------+------+------+------| | ||
221 | * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right | | ||
222 | * `-------------------------------------------------------------------------------------------------' | ||
223 | */ | ||
224 | [_COLEMAK] = KEYMAP( \ | ||
225 | KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, \ | ||
226 | KC_LCTL, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \ | ||
227 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \ | ||
228 | ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
229 | ), | ||
230 | |||
231 | /* Dvorak | ||
232 | * ,-----------------------------------------. ,-----------------------------------------. | ||
233 | * | Tab | ' | , | . | P | Y | | F | G | C | R | L | Del | | ||
234 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
235 | * | Ctrl | A | O | E | U | I | | D | H | T | N | S | / | | ||
236 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
237 | * | Shift| ; | Q | J | K | X | | B | M | W | V | Z |Enter | | ||
238 | * |------+------+------+------+------+------+-------------+------+------+------+------+------+------| | ||
239 | * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right | | ||
240 | * `-------------------------------------------------------------------------------------------------' | ||
241 | */ | ||
242 | [_DVORAK] = KEYMAP( \ | ||
243 | KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_DEL, \ | ||
244 | KC_LCTL, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \ | ||
245 | KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \ | ||
246 | ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
247 | ), | ||
248 | |||
249 | /* Lower | ||
250 | * ,-----------------------------------------. ,-----------------------------------------. | ||
251 | * | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | | | ||
252 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
253 | * | | F1 | F2 | F3 | F4 | F5 | | F6 | _ | + | { | } | | | | ||
254 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
255 | * | | F7 | F8 | F9 | F10 | F11 | | F12 | | | Home | End | | | ||
256 | * |------+------+------+------+------+------+-------------+------+------+------+------+------+------| | ||
257 | * | | | | | | | | | | | Next | Vol- | Vol+ | Play | | ||
258 | * `-------------------------------------------------------------------------------------------------' | ||
259 | */ | ||
260 | [_LOWER] = KEYMAP( \ | ||
261 | KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, \ | ||
262 | _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \ | ||
263 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, KC_HOME, KC_END, _______, \ | ||
264 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
265 | ), | ||
266 | |||
267 | /* Raise | ||
268 | * ,-----------------------------------------. ,-----------------------------------------. | ||
269 | * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del | | ||
270 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
271 | * | | F1 | F2 | F3 | F4 | F5 | | F6 | - | = | [ | ] | \ | | ||
272 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
273 | * | | F7 | F8 | F9 | F10 | F11 | | F12 | | |PageDn|PageUp| | | ||
274 | * |------+------+------+------+------+------+-------------+------+------+------+------+------+------| | ||
275 | * | | | | | | | | | | | Next | Vol- | Vol+ | Play | | ||
276 | * `-------------------------------------------------------------------------------------------------' | ||
277 | */ | ||
278 | [_RAISE] = KEYMAP( \ | ||
279 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \ | ||
280 | _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \ | ||
281 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, KC_PGDN, KC_PGUP, _______, \ | ||
282 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
283 | ), | ||
284 | |||
285 | /* Adjust (Lower + Raise) | ||
286 | * ,-----------------------------------------. ,-----------------------------------------. | ||
287 | * | | Reset| | | | | | | | | | | Del | | ||
288 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
289 | * | | | |Aud on|Audoff| Mac | | Win |Qwerty|Colemk|Dvorak| | | | ||
290 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
291 | * | | | | | | | | | |RGB ON| HUE+ | SAT+ | VAL+ | | ||
292 | * |------+------+------+------+------+------+-------------+------+------+------+------+------+------| | ||
293 | * | | | | | | | | | | | MODE | HUE- | SAT- | VAL- | | ||
294 | * `-------------------------------------------------------------------------------------------------' | ||
295 | */ | ||
296 | [_ADJUST] = KEYMAP( \ | ||
297 | _______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \ | ||
298 | _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \ | ||
299 | _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, \ | ||
300 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SMOD,RGB_HUD, RGB_SAD, RGB_VAD \ | ||
301 | ) | ||
302 | }; | ||
303 | |||
304 | #else | ||
305 | #error "undefined keymaps" | ||
306 | #endif | ||
307 | |||
308 | |||
309 | #ifdef AUDIO_ENABLE | ||
310 | |||
311 | float tone_qwerty[][2] = SONG(QWERTY_SOUND); | ||
312 | float tone_dvorak[][2] = SONG(DVORAK_SOUND); | ||
313 | float tone_colemak[][2] = SONG(COLEMAK_SOUND); | ||
314 | float tone_plover[][2] = SONG(PLOVER_SOUND); | ||
315 | float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND); | ||
316 | float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); | ||
317 | #endif | ||
318 | |||
319 | // define variables for reactive RGB | ||
320 | bool TOG_STATUS = false; | ||
321 | int RGB_current_mode; | ||
322 | |||
323 | void persistent_default_layer_set(uint16_t default_layer) { | ||
324 | eeconfig_update_default_layer(default_layer); | ||
325 | default_layer_set(default_layer); | ||
326 | } | ||
327 | |||
328 | // Setting ADJUST layer RGB back to default | ||
329 | void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) { | ||
330 | if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) { | ||
331 | #ifdef RGBLIGHT_ENABLE | ||
332 | //rgblight_mode(RGB_current_mode); | ||
333 | #endif | ||
334 | layer_on(layer3); | ||
335 | } else { | ||
336 | layer_off(layer3); | ||
337 | } | ||
338 | } | ||
339 | |||
340 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
341 | switch (keycode) { | ||
342 | case QWERTY: | ||
343 | if (record->event.pressed) { | ||
344 | #ifdef AUDIO_ENABLE | ||
345 | PLAY_SONG(tone_qwerty); | ||
346 | #endif | ||
347 | persistent_default_layer_set(1UL<<_QWERTY); | ||
348 | } | ||
349 | return false; | ||
350 | break; | ||
351 | case COLEMAK: | ||
352 | if (record->event.pressed) { | ||
353 | #ifdef AUDIO_ENABLE | ||
354 | PLAY_SONG(tone_colemak); | ||
355 | #endif | ||
356 | persistent_default_layer_set(1UL<<_COLEMAK); | ||
357 | } | ||
358 | return false; | ||
359 | break; | ||
360 | case DVORAK: | ||
361 | if (record->event.pressed) { | ||
362 | #ifdef AUDIO_ENABLE | ||
363 | PLAY_SONG(tone_dvorak); | ||
364 | #endif | ||
365 | persistent_default_layer_set(1UL<<_DVORAK); | ||
366 | } | ||
367 | return false; | ||
368 | break; | ||
369 | case LOWER: | ||
370 | if (record->event.pressed) { | ||
371 | //not sure how to have keyboard check mode and set it to a variable, so my work around | ||
372 | //uses another variable that would be set to true after the first time a reactive key is pressed. | ||
373 | if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false | ||
374 | } else { | ||
375 | TOG_STATUS = !TOG_STATUS; | ||
376 | #ifdef RGBLIGHT_ENABLE | ||
377 | //rgblight_mode(16); | ||
378 | #endif | ||
379 | } | ||
380 | layer_on(_LOWER); | ||
381 | update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); | ||
382 | } else { | ||
383 | #ifdef RGBLIGHT_ENABLE | ||
384 | //rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change | ||
385 | #endif | ||
386 | TOG_STATUS = false; | ||
387 | layer_off(_LOWER); | ||
388 | update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); | ||
389 | } | ||
390 | return false; | ||
391 | break; | ||
392 | case RAISE: | ||
393 | if (record->event.pressed) { | ||
394 | //not sure how to have keyboard check mode and set it to a variable, so my work around | ||
395 | //uses another variable that would be set to true after the first time a reactive key is pressed. | ||
396 | if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false | ||
397 | } else { | ||
398 | TOG_STATUS = !TOG_STATUS; | ||
399 | #ifdef RGBLIGHT_ENABLE | ||
400 | //rgblight_mode(15); | ||
401 | #endif | ||
402 | } | ||
403 | layer_on(_RAISE); | ||
404 | update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); | ||
405 | } else { | ||
406 | #ifdef RGBLIGHT_ENABLE | ||
407 | //rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change | ||
408 | #endif | ||
409 | layer_off(_RAISE); | ||
410 | TOG_STATUS = false; | ||
411 | update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); | ||
412 | } | ||
413 | return false; | ||
414 | break; | ||
415 | case ADJUST: | ||
416 | if (record->event.pressed) { | ||
417 | layer_on(_ADJUST); | ||
418 | } else { | ||
419 | layer_off(_ADJUST); | ||
420 | } | ||
421 | return false; | ||
422 | break; | ||
423 | //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released | ||
424 | case RGB_MOD: | ||
425 | #ifdef RGBLIGHT_ENABLE | ||
426 | if (record->event.pressed) { | ||
427 | rgblight_mode(RGB_current_mode); | ||
428 | rgblight_step(); | ||
429 | RGB_current_mode = rgblight_config.mode; | ||
430 | } | ||
431 | #endif | ||
432 | return false; | ||
433 | break; | ||
434 | case EISU: | ||
435 | if (record->event.pressed) { | ||
436 | if(keymap_config.swap_lalt_lgui==false){ | ||
437 | register_code(KC_LANG2); | ||
438 | }else{ | ||
439 | SEND_STRING(SS_LALT("`")); | ||
440 | } | ||
441 | } else { | ||
442 | unregister_code(KC_LANG2); | ||
443 | } | ||
444 | return false; | ||
445 | break; | ||
446 | case KANA: | ||
447 | if (record->event.pressed) { | ||
448 | if(keymap_config.swap_lalt_lgui==false){ | ||
449 | register_code(KC_LANG1); | ||
450 | }else{ | ||
451 | SEND_STRING(SS_LALT("`")); | ||
452 | } | ||
453 | } else { | ||
454 | unregister_code(KC_LANG1); | ||
455 | } | ||
456 | return false; | ||
457 | break; | ||
458 | case RGBRST: | ||
459 | #ifdef RGBLIGHT_ENABLE | ||
460 | if (record->event.pressed) { | ||
461 | eeconfig_update_rgblight_default(); | ||
462 | rgblight_enable(); | ||
463 | RGB_current_mode = rgblight_config.mode; | ||
464 | } | ||
465 | #endif | ||
466 | break; | ||
467 | } | ||
468 | return true; | ||
469 | } | ||
470 | |||
471 | void matrix_init_user(void) { | ||
472 | #ifdef AUDIO_ENABLE | ||
473 | startup_user(); | ||
474 | #endif | ||
475 | #ifdef RGBLIGHT_ENABLE | ||
476 | RGB_current_mode = rgblight_config.mode; | ||
477 | #endif | ||
478 | //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h | ||
479 | #ifdef SSD1306OLED | ||
480 | TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000)); | ||
481 | iota_gfx_init(!has_usb()); // turns on the display | ||
482 | #endif | ||
483 | } | ||
484 | |||
485 | |||
486 | #ifdef AUDIO_ENABLE | ||
487 | |||
488 | void startup_user() | ||
489 | { | ||
490 | _delay_ms(20); // gets rid of tick | ||
491 | } | ||
492 | |||
493 | void shutdown_user() | ||
494 | { | ||
495 | _delay_ms(150); | ||
496 | stop_all_notes(); | ||
497 | } | ||
498 | |||
499 | void music_on_user(void) | ||
500 | { | ||
501 | music_scale_user(); | ||
502 | } | ||
503 | |||
504 | void music_scale_user(void) | ||
505 | { | ||
506 | PLAY_SONG(music_scale); | ||
507 | } | ||
508 | |||
509 | #endif | ||
510 | |||
511 | |||
512 | //SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h | ||
513 | #ifdef SSD1306OLED | ||
514 | |||
515 | void matrix_scan_user(void) { | ||
516 | iota_gfx_task(); // this is what updates the display continuously | ||
517 | } | ||
518 | |||
519 | void matrix_update(struct CharacterMatrix *dest, | ||
520 | const struct CharacterMatrix *source) { | ||
521 | if (memcmp(dest->display, source->display, sizeof(dest->display))) { | ||
522 | memcpy(dest->display, source->display, sizeof(dest->display)); | ||
523 | dest->dirty = true; | ||
524 | } | ||
525 | } | ||
526 | |||
527 | //assign the right code to your layers for OLED display | ||
528 | #define L_BASE 0 | ||
529 | #define L_LOWER 8 | ||
530 | #define L_RAISE 16 | ||
531 | #define L_FNLAYER 64 | ||
532 | #define L_NUMLAY 128 | ||
533 | #define L_NLOWER 136 | ||
534 | #define L_NFNLAYER 192 | ||
535 | #define L_MOUSECURSOR 256 | ||
536 | #define L_ADJUST 65536 | ||
537 | #define L_ADJUST_TRI 65560 | ||
538 | |||
539 | static void render_logo(struct CharacterMatrix *matrix) { | ||
540 | |||
541 | static char logo[]={ | ||
542 | 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94, | ||
543 | 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4, | ||
544 | 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4, | ||
545 | 0}; | ||
546 | matrix_write(matrix, logo); | ||
547 | //matrix_write_P(&matrix, PSTR(" Split keyboard kit")); | ||
548 | } | ||
549 | |||
550 | |||
551 | |||
552 | void render_status(struct CharacterMatrix *matrix) { | ||
553 | |||
554 | // Render to mode icon | ||
555 | static char logo[][2][3]={{{0x95,0x96,0},{0xb5,0xb6,0}},{{0x97,0x98,0},{0xb7,0xb8,0}}}; | ||
556 | if(keymap_config.swap_lalt_lgui==false){ | ||
557 | matrix_write(matrix, logo[0][0]); | ||
558 | matrix_write_P(matrix, PSTR("\n")); | ||
559 | matrix_write(matrix, logo[0][1]); | ||
560 | }else{ | ||
561 | matrix_write(matrix, logo[1][0]); | ||
562 | matrix_write_P(matrix, PSTR("\n")); | ||
563 | matrix_write(matrix, logo[1][1]); | ||
564 | } | ||
565 | |||
566 | // Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below | ||
567 | char buf[40]; | ||
568 | snprintf(buf,sizeof(buf), "Undef-%ld", layer_state); | ||
569 | matrix_write_P(matrix, PSTR("\nLayer: ")); | ||
570 | switch (layer_state) { | ||
571 | case L_BASE: | ||
572 | matrix_write_P(matrix, PSTR("Default")); | ||
573 | break; | ||
574 | case L_RAISE: | ||
575 | matrix_write_P(matrix, PSTR("Raise")); | ||
576 | break; | ||
577 | case L_LOWER: | ||
578 | matrix_write_P(matrix, PSTR("Lower")); | ||
579 | break; | ||
580 | case L_ADJUST: | ||
581 | case L_ADJUST_TRI: | ||
582 | matrix_write_P(matrix, PSTR("Adjust")); | ||
583 | break; | ||
584 | default: | ||
585 | matrix_write(matrix, buf); | ||
586 | } | ||
587 | |||
588 | // Host Keyboard LED Status | ||
589 | char led[40]; | ||
590 | snprintf(led, sizeof(led), "\n%s %s %s", | ||
591 | (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ", | ||
592 | (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ", | ||
593 | (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " "); | ||
594 | matrix_write(matrix, led); | ||
595 | } | ||
596 | |||
597 | |||
598 | void iota_gfx_task_user(void) { | ||
599 | struct CharacterMatrix matrix; | ||
600 | |||
601 | #if DEBUG_TO_SCREEN | ||
602 | if (debug_enable) { | ||
603 | return; | ||
604 | } | ||
605 | #endif | ||
606 | |||
607 | matrix_clear(&matrix); | ||
608 | if(is_master){ | ||
609 | render_status(&matrix); | ||
610 | }else{ | ||
611 | render_logo(&matrix); | ||
612 | } | ||
613 | matrix_update(&display, &matrix); | ||
614 | } | ||
615 | |||
616 | #endif | ||
diff --git a/keyboards/helix/rev2/keymaps/default/readme.md b/keyboards/helix/rev2/keymaps/default/readme.md new file mode 100644 index 000000000..02888855b --- /dev/null +++ b/keyboards/helix/rev2/keymaps/default/readme.md | |||
@@ -0,0 +1,25 @@ | |||
1 | SSD1306 OLED Display via I2C | ||
2 | ====== | ||
3 | |||
4 | Features | ||
5 | -------- | ||
6 | |||
7 | Some features supported by the firmware: | ||
8 | |||
9 | |||
10 | * I2C connection between the two halves is required as the OLED display will use this connection as well. Note this | ||
11 | requires pull-up resistors on the data and clock lines. | ||
12 | * OLED display will connect from either side | ||
13 | |||
14 | |||
15 | Wiring | ||
16 | ------ | ||
17 | |||
18 | |||
19 | Work in progress... | ||
20 | |||
21 | |||
22 | OLED Configuration | ||
23 | ------------------------------- | ||
24 | |||
25 | Work in progress... | ||
diff --git a/keyboards/helix/rev2/keymaps/default/rules.mk b/keyboards/helix/rev2/keymaps/default/rules.mk new file mode 100644 index 000000000..ce3ef6cd9 --- /dev/null +++ b/keyboards/helix/rev2/keymaps/default/rules.mk | |||
@@ -0,0 +1,25 @@ | |||
1 | |||
2 | # Build Options | ||
3 | # change to "no" to disable the options, or define them in the Makefile in | ||
4 | # the appropriate keymap folder that will get included automatically | ||
5 | # | ||
6 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) | ||
7 | MOUSEKEY_ENABLE = no # Mouse keys(+4700) | ||
8 | EXTRAKEY_ENABLE = no # Audio control and System control(+450) | ||
9 | CONSOLE_ENABLE = no # Console for debug(+400) | ||
10 | COMMAND_ENABLE = no # Commands for debug and configuration | ||
11 | NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
12 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality | ||
13 | MIDI_ENABLE = no # MIDI controls | ||
14 | AUDIO_ENABLE = no # Audio output on port C6 | ||
15 | UNICODE_ENABLE = no # Unicode | ||
16 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
17 | RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. | ||
18 | ONEHAND_ENABLE = no # Enable one-hand typing | ||
19 | |||
20 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | ||
21 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | ||
22 | |||
23 | ifndef QUANTUM_DIR | ||
24 | include ../../../../Makefile | ||
25 | endif | ||
diff --git a/keyboards/helix/rev2/matrix.c b/keyboards/helix/rev2/matrix.c new file mode 100644 index 000000000..7ddbc2107 --- /dev/null +++ b/keyboards/helix/rev2/matrix.c | |||
@@ -0,0 +1,359 @@ | |||
1 | /* | ||
2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation, either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | /* | ||
19 | * scan matrix | ||
20 | */ | ||
21 | #include <stdint.h> | ||
22 | #include <stdbool.h> | ||
23 | #include <avr/io.h> | ||
24 | #include <avr/wdt.h> | ||
25 | #include <avr/interrupt.h> | ||
26 | #include <util/delay.h> | ||
27 | #include "print.h" | ||
28 | #include "debug.h" | ||
29 | #include "util.h" | ||
30 | #include "matrix.h" | ||
31 | #include "split_util.h" | ||
32 | #include "pro_micro.h" | ||
33 | #include "config.h" | ||
34 | |||
35 | #ifdef USE_MATRIX_I2C | ||
36 | # include "i2c.h" | ||
37 | #else // USE_SERIAL | ||
38 | # include "serial.h" | ||
39 | #endif | ||
40 | |||
41 | #ifndef DEBOUNCE | ||
42 | # define DEBOUNCE 5 | ||
43 | #endif | ||
44 | |||
45 | #define ERROR_DISCONNECT_COUNT 5 | ||
46 | |||
47 | static uint8_t debouncing = DEBOUNCE; | ||
48 | static const int ROWS_PER_HAND = MATRIX_ROWS/2; | ||
49 | static uint8_t error_count = 0; | ||
50 | uint8_t is_master = 0 ; | ||
51 | |||
52 | static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; | ||
53 | static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; | ||
54 | |||
55 | /* matrix state(1:on, 0:off) */ | ||
56 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
57 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
58 | |||
59 | static matrix_row_t read_cols(void); | ||
60 | static void init_cols(void); | ||
61 | static void unselect_rows(void); | ||
62 | static void select_row(uint8_t row); | ||
63 | static uint8_t matrix_master_scan(void); | ||
64 | |||
65 | __attribute__ ((weak)) | ||
66 | void matrix_init_quantum(void) { | ||
67 | matrix_init_kb(); | ||
68 | } | ||
69 | |||
70 | __attribute__ ((weak)) | ||
71 | void matrix_scan_quantum(void) { | ||
72 | matrix_scan_kb(); | ||
73 | } | ||
74 | |||
75 | __attribute__ ((weak)) | ||
76 | void matrix_init_kb(void) { | ||
77 | matrix_init_user(); | ||
78 | } | ||
79 | |||
80 | __attribute__ ((weak)) | ||
81 | void matrix_scan_kb(void) { | ||
82 | matrix_scan_user(); | ||
83 | } | ||
84 | |||
85 | __attribute__ ((weak)) | ||
86 | void matrix_init_user(void) { | ||
87 | } | ||
88 | |||
89 | __attribute__ ((weak)) | ||
90 | void matrix_scan_user(void) { | ||
91 | } | ||
92 | |||
93 | inline | ||
94 | uint8_t matrix_rows(void) | ||
95 | { | ||
96 | return MATRIX_ROWS; | ||
97 | } | ||
98 | |||
99 | inline | ||
100 | uint8_t matrix_cols(void) | ||
101 | { | ||
102 | return MATRIX_COLS; | ||
103 | } | ||
104 | |||
105 | void matrix_init(void) | ||
106 | { | ||
107 | debug_enable = true; | ||
108 | debug_matrix = true; | ||
109 | debug_mouse = true; | ||
110 | // initialize row and col | ||
111 | unselect_rows(); | ||
112 | init_cols(); | ||
113 | |||
114 | TX_RX_LED_INIT; | ||
115 | |||
116 | // initialize matrix state: all keys off | ||
117 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
118 | matrix[i] = 0; | ||
119 | matrix_debouncing[i] = 0; | ||
120 | } | ||
121 | |||
122 | is_master = has_usb(); | ||
123 | |||
124 | matrix_init_quantum(); | ||
125 | } | ||
126 | |||
127 | uint8_t _matrix_scan(void) | ||
128 | { | ||
129 | // Right hand is stored after the left in the matirx so, we need to offset it | ||
130 | int offset = isLeftHand ? 0 : (ROWS_PER_HAND); | ||
131 | |||
132 | for (uint8_t i = 0; i < ROWS_PER_HAND; i++) { | ||
133 | select_row(i); | ||
134 | _delay_us(30); // without this wait read unstable value. | ||
135 | matrix_row_t cols = read_cols(); | ||
136 | if (matrix_debouncing[i+offset] != cols) { | ||
137 | matrix_debouncing[i+offset] = cols; | ||
138 | debouncing = DEBOUNCE; | ||
139 | } | ||
140 | unselect_rows(); | ||
141 | } | ||
142 | |||
143 | if (debouncing) { | ||
144 | if (--debouncing) { | ||
145 | _delay_ms(1); | ||
146 | } else { | ||
147 | for (uint8_t i = 0; i < ROWS_PER_HAND; i++) { | ||
148 | matrix[i+offset] = matrix_debouncing[i+offset]; | ||
149 | } | ||
150 | } | ||
151 | } | ||
152 | |||
153 | return 1; | ||
154 | } | ||
155 | |||
156 | #ifdef USE_MATRIX_I2C | ||
157 | |||
158 | // Get rows from other half over i2c | ||
159 | int i2c_transaction(void) { | ||
160 | int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0; | ||
161 | |||
162 | int err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE); | ||
163 | if (err) goto i2c_error; | ||
164 | |||
165 | // start of matrix stored at 0x00 | ||
166 | err = i2c_master_write(0x00); | ||
167 | if (err) goto i2c_error; | ||
168 | |||
169 | // Start read | ||
170 | err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_READ); | ||
171 | if (err) goto i2c_error; | ||
172 | |||
173 | if (!err) { | ||
174 | int i; | ||
175 | for (i = 0; i < ROWS_PER_HAND-1; ++i) { | ||
176 | matrix[slaveOffset+i] = i2c_master_read(I2C_ACK); | ||
177 | } | ||
178 | matrix[slaveOffset+i] = i2c_master_read(I2C_NACK); | ||
179 | i2c_master_stop(); | ||
180 | } else { | ||
181 | i2c_error: // the cable is disconnceted, or something else went wrong | ||
182 | i2c_reset_state(); | ||
183 | return err; | ||
184 | } | ||
185 | |||
186 | return 0; | ||
187 | } | ||
188 | |||
189 | #else // USE_SERIAL | ||
190 | |||
191 | int serial_transaction(void) { | ||
192 | int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0; | ||
193 | int ret=serial_update_buffers(); | ||
194 | if (ret ) { | ||
195 | if(ret==2)RXLED1; | ||
196 | return 1; | ||
197 | } | ||
198 | RXLED0; | ||
199 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | ||
200 | matrix[slaveOffset+i] = serial_slave_buffer[i]; | ||
201 | } | ||
202 | return 0; | ||
203 | } | ||
204 | #endif | ||
205 | |||
206 | uint8_t matrix_scan(void) | ||
207 | { | ||
208 | if (is_master) { | ||
209 | matrix_master_scan(); | ||
210 | }else{ | ||
211 | matrix_slave_scan(); | ||
212 | |||
213 | // if(serial_slave_DATA_CORRUPT()){ | ||
214 | // TXLED0; | ||
215 | int offset = (isLeftHand) ? ROWS_PER_HAND : 0; | ||
216 | |||
217 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | ||
218 | matrix[offset+i] = serial_master_buffer[i]; | ||
219 | } | ||
220 | |||
221 | // }else{ | ||
222 | // TXLED1; | ||
223 | // } | ||
224 | |||
225 | matrix_scan_quantum(); | ||
226 | } | ||
227 | return 1; | ||
228 | } | ||
229 | |||
230 | |||
231 | uint8_t matrix_master_scan(void) { | ||
232 | |||
233 | int ret = _matrix_scan(); | ||
234 | |||
235 | #ifndef KEYBOARD_helix_rev1 | ||
236 | int offset = (isLeftHand) ? 0 : ROWS_PER_HAND; | ||
237 | |||
238 | #ifdef USE_MATRIX_I2C | ||
239 | // for (int i = 0; i < ROWS_PER_HAND; ++i) { | ||
240 | /* i2c_slave_buffer[i] = matrix[offset+i]; */ | ||
241 | // i2c_slave_buffer[i] = matrix[offset+i]; | ||
242 | // } | ||
243 | #else // USE_SERIAL | ||
244 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | ||
245 | serial_master_buffer[i] = matrix[offset+i]; | ||
246 | } | ||
247 | #endif | ||
248 | #endif | ||
249 | |||
250 | #ifdef USE_MATRIX_I2C | ||
251 | if( i2c_transaction() ) { | ||
252 | #else // USE_SERIAL | ||
253 | if( serial_transaction() ) { | ||
254 | #endif | ||
255 | // turn on the indicator led when halves are disconnected | ||
256 | TXLED1; | ||
257 | |||
258 | error_count++; | ||
259 | |||
260 | if (error_count > ERROR_DISCONNECT_COUNT) { | ||
261 | // reset other half if disconnected | ||
262 | int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0; | ||
263 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | ||
264 | matrix[slaveOffset+i] = 0; | ||
265 | } | ||
266 | } | ||
267 | } else { | ||
268 | // turn off the indicator led on no error | ||
269 | TXLED0; | ||
270 | error_count = 0; | ||
271 | } | ||
272 | matrix_scan_quantum(); | ||
273 | return ret; | ||
274 | } | ||
275 | |||
276 | void matrix_slave_scan(void) { | ||
277 | _matrix_scan(); | ||
278 | |||
279 | int offset = (isLeftHand) ? 0 : ROWS_PER_HAND; | ||
280 | |||
281 | #ifdef USE_MATRIX_I2C | ||
282 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | ||
283 | /* i2c_slave_buffer[i] = matrix[offset+i]; */ | ||
284 | i2c_slave_buffer[i] = matrix[offset+i]; | ||
285 | } | ||
286 | #else // USE_SERIAL | ||
287 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | ||
288 | serial_slave_buffer[i] = matrix[offset+i]; | ||
289 | } | ||
290 | #endif | ||
291 | } | ||
292 | |||
293 | bool matrix_is_modified(void) | ||
294 | { | ||
295 | if (debouncing) return false; | ||
296 | return true; | ||
297 | } | ||
298 | |||
299 | inline | ||
300 | bool matrix_is_on(uint8_t row, uint8_t col) | ||
301 | { | ||
302 | return (matrix[row] & ((matrix_row_t)1<<col)); | ||
303 | } | ||
304 | |||
305 | inline | ||
306 | matrix_row_t matrix_get_row(uint8_t row) | ||
307 | { | ||
308 | return matrix[row]; | ||
309 | } | ||
310 | |||
311 | void matrix_print(void) | ||
312 | { | ||
313 | print("\nr/c 0123456789ABCDEF\n"); | ||
314 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
315 | phex(row); print(": "); | ||
316 | pbin_reverse16(matrix_get_row(row)); | ||
317 | print("\n"); | ||
318 | } | ||
319 | } | ||
320 | |||
321 | uint8_t matrix_key_count(void) | ||
322 | { | ||
323 | uint8_t count = 0; | ||
324 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
325 | count += bitpop16(matrix[i]); | ||
326 | } | ||
327 | return count; | ||
328 | } | ||
329 | |||
330 | static void init_cols(void) | ||
331 | { | ||
332 | for(int x = 0; x < MATRIX_COLS; x++) { | ||
333 | _SFR_IO8((col_pins[x] >> 4) + 1) &= ~_BV(col_pins[x] & 0xF); | ||
334 | _SFR_IO8((col_pins[x] >> 4) + 2) |= _BV(col_pins[x] & 0xF); | ||
335 | } | ||
336 | } | ||
337 | |||
338 | static matrix_row_t read_cols(void) | ||
339 | { | ||
340 | matrix_row_t result = 0; | ||
341 | for(int x = 0; x < MATRIX_COLS; x++) { | ||
342 | result |= (_SFR_IO8(col_pins[x] >> 4) & _BV(col_pins[x] & 0xF)) ? 0 : (1 << x); | ||
343 | } | ||
344 | return result; | ||
345 | } | ||
346 | |||
347 | static void unselect_rows(void) | ||
348 | { | ||
349 | for(int x = 0; x < ROWS_PER_HAND; x++) { | ||
350 | _SFR_IO8((row_pins[x] >> 4) + 1) &= ~_BV(row_pins[x] & 0xF); | ||
351 | _SFR_IO8((row_pins[x] >> 4) + 2) |= _BV(row_pins[x] & 0xF); | ||
352 | } | ||
353 | } | ||
354 | |||
355 | static void select_row(uint8_t row) | ||
356 | { | ||
357 | _SFR_IO8((row_pins[row] >> 4) + 1) |= _BV(row_pins[row] & 0xF); | ||
358 | _SFR_IO8((row_pins[row] >> 4) + 2) &= ~_BV(row_pins[row] & 0xF); | ||
359 | } | ||
diff --git a/keyboards/helix/rev2/rev2.c b/keyboards/helix/rev2/rev2.c new file mode 100644 index 000000000..1b23edb79 --- /dev/null +++ b/keyboards/helix/rev2/rev2.c | |||
@@ -0,0 +1,32 @@ | |||
1 | #include "helix.h" | ||
2 | |||
3 | |||
4 | #ifdef AUDIO_ENABLE | ||
5 | float tone_startup[][2] = SONG(STARTUP_SOUND); | ||
6 | float tone_goodbye[][2] = SONG(GOODBYE_SOUND); | ||
7 | #endif | ||
8 | |||
9 | #ifdef SSD1306OLED | ||
10 | void led_set_kb(uint8_t usb_led) { | ||
11 | // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here | ||
12 | //led_set_user(usb_led); | ||
13 | } | ||
14 | #endif | ||
15 | |||
16 | void matrix_init_kb(void) { | ||
17 | |||
18 | #ifdef AUDIO_ENABLE | ||
19 | _delay_ms(20); // gets rid of tick | ||
20 | PLAY_SONG(tone_startup); | ||
21 | #endif | ||
22 | |||
23 | matrix_init_user(); | ||
24 | }; | ||
25 | |||
26 | void shutdown_kb(void) { | ||
27 | #ifdef AUDIO_ENABLE | ||
28 | PLAY_SONG(tone_goodbye); | ||
29 | _delay_ms(150); | ||
30 | stop_all_notes(); | ||
31 | #endif | ||
32 | } | ||
diff --git a/keyboards/helix/rev2/rev2.h b/keyboards/helix/rev2/rev2.h new file mode 100644 index 000000000..7cab57ea0 --- /dev/null +++ b/keyboards/helix/rev2/rev2.h | |||
@@ -0,0 +1,115 @@ | |||
1 | #ifndef REV2_H | ||
2 | #define REV2_CONFIG_H | ||
3 | |||
4 | #include "../helix.h" | ||
5 | |||
6 | //void promicro_bootloader_jmp(bool program); | ||
7 | #include "quantum.h" | ||
8 | |||
9 | #ifdef RGBLIGHT_ENABLE | ||
10 | //rgb led driver | ||
11 | #include "ws2812.h" | ||
12 | #endif | ||
13 | |||
14 | #ifdef USE_I2C | ||
15 | #include <stddef.h> | ||
16 | #ifdef __AVR__ | ||
17 | #include <avr/io.h> | ||
18 | #include <avr/interrupt.h> | ||
19 | #endif | ||
20 | #endif | ||
21 | |||
22 | //void promicro_bootloader_jmp(bool program); | ||
23 | |||
24 | |||
25 | #if HELIX_ROWS == 4 | ||
26 | #ifndef FLIP_HALF | ||
27 | // Standard Keymap | ||
28 | // (TRRS jack on the left half is to the right, TRRS jack on the right half is to the left) | ||
29 | #define KEYMAP( \ | ||
30 | L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ | ||
31 | L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ | ||
32 | L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \ | ||
33 | L30, L31, L32, L33, L34, L35, L36, R36, R30, R31, R32, R33, R34, R35 \ | ||
34 | ) \ | ||
35 | { \ | ||
36 | { L00, L01, L02, L03, L04, L05, KC_NO }, \ | ||
37 | { L10, L11, L12, L13, L14, L15, KC_NO }, \ | ||
38 | { L20, L21, L22, L23, L24, L25, KC_NO }, \ | ||
39 | { L30, L31, L32, L33, L34, L35, L36 }, \ | ||
40 | { R05, R04, R03, R02, R01, R00, KC_NO }, \ | ||
41 | { R15, R14, R13, R12, R11, R10, KC_NO }, \ | ||
42 | { R25, R24, R23, R22, R21, R20, KC_NO }, \ | ||
43 | { R35, R34, R33, R32, R31, R30, R36 }, \ | ||
44 | } | ||
45 | #else | ||
46 | // Keymap with right side flipped | ||
47 | // (TRRS jack on both halves are to the right) | ||
48 | #define KEYMAP( \ | ||
49 | L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ | ||
50 | L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ | ||
51 | L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \ | ||
52 | L30, L31, L32, L33, L34, L35, L36, R36, R30, R31, R32, R33, R34, R35 \ | ||
53 | ) \ | ||
54 | { \ | ||
55 | { L00, L01, L02, L03, L04, L05, KC_NO }, \ | ||
56 | { L10, L11, L12, L13, L14, L15, KC_NO }, \ | ||
57 | { L20, L21, L22, L23, L24, L25, KC_NO }, \ | ||
58 | { L30, L31, L32, L33, L34, L35, L36 }, \ | ||
59 | { KC_NO, R00, R01, R02, R03, R04, R05 }, \ | ||
60 | { KC_NO, R10, R11, R12, R13, R14, R15 }, \ | ||
61 | { KC_NO, R20, R21, R22, R23, R24, R25 }, \ | ||
62 | { R36, R30, R31, R32, R33, R34, R35 }, \ | ||
63 | } | ||
64 | #endif | ||
65 | #elif HELIX_ROWS == 5 | ||
66 | #ifndef FLIP_HALF | ||
67 | // Standard Keymap | ||
68 | // (TRRS jack on the left half is to the right, TRRS jack on the right half is to the left) | ||
69 | #define KEYMAP( \ | ||
70 | L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ | ||
71 | L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ | ||
72 | L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \ | ||
73 | L30, L31, L32, L33, L34, L35, L36, R36, R30, R31, R32, R33, R34, R35, \ | ||
74 | L40, L41, L42, L43, L44, L45, L46, R46, R40, R41, R42, R43, R44, R45 \ | ||
75 | ) \ | ||
76 | { \ | ||
77 | { L00, L01, L02, L03, L04, L05, KC_NO }, \ | ||
78 | { L10, L11, L12, L13, L14, L15, KC_NO }, \ | ||
79 | { L20, L21, L22, L23, L24, L25, KC_NO }, \ | ||
80 | { L30, L31, L32, L33, L34, L35, L36 }, \ | ||
81 | { L40, L41, L42, L43, L44, L45, L46 }, \ | ||
82 | { R05, R04, R03, R02, R01, R00, KC_NO }, \ | ||
83 | { R15, R14, R13, R12, R11, R10, KC_NO }, \ | ||
84 | { R25, R24, R23, R22, R21, R20, KC_NO }, \ | ||
85 | { R35, R34, R33, R32, R31, R30, R36 }, \ | ||
86 | { R45, R44, R43, R42, R41, R40, R46 } \ | ||
87 | } | ||
88 | #else | ||
89 | // Keymap with right side flipped | ||
90 | // (TRRS jack on both halves are to the right) | ||
91 | #define KEYMAP( \ | ||
92 | L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ | ||
93 | L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ | ||
94 | L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \ | ||
95 | L30, L31, L32, L33, L34, L35, L36, R36, R30, R31, R32, R33, R34, R35, \ | ||
96 | L40, L41, L42, L43, L44, L45, L46, R46, R40, R41, R42, R43, R44, R45 \ | ||
97 | ) \ | ||
98 | { \ | ||
99 | { L00, L01, L02, L03, L04, L05, KC_NO }, \ | ||
100 | { L10, L11, L12, L13, L14, L15, KC_NO }, \ | ||
101 | { L20, L21, L22, L23, L24, L25, KC_NO }, \ | ||
102 | { L30, L31, L32, L33, L34, L35, L36 }, \ | ||
103 | { L40, L41, L42, L43, L44, L45, L46 }, \ | ||
104 | { KC_NO, R00, R01, R02, R03, R04, R05 }, \ | ||
105 | { KC_NO, R10, R11, R12, R13, R14, R15 }, \ | ||
106 | { KC_NO, R20, R21, R22, R23, R24, R25 }, \ | ||
107 | { R36, R30, R31, R32, R33, R34, R35 }, \ | ||
108 | { R46, R40, R41, R42, R43, R44, R45 } \ | ||
109 | } | ||
110 | #endif | ||
111 | #else | ||
112 | #error "expected HELIX_ROWS 4 or 5" | ||
113 | #endif | ||
114 | |||
115 | #endif | ||
diff --git a/keyboards/helix/rev2/rules.mk b/keyboards/helix/rev2/rules.mk new file mode 100644 index 000000000..6ab01f44b --- /dev/null +++ b/keyboards/helix/rev2/rules.mk | |||
@@ -0,0 +1,3 @@ | |||
1 | SRC += rev2/matrix.c \ | ||
2 | rev2/split_util.c \ | ||
3 | ws2812.c | ||
diff --git a/keyboards/helix/rev2/split_util.c b/keyboards/helix/rev2/split_util.c new file mode 100644 index 000000000..8bc064174 --- /dev/null +++ b/keyboards/helix/rev2/split_util.c | |||
@@ -0,0 +1,71 @@ | |||
1 | #include <avr/io.h> | ||
2 | #include <avr/wdt.h> | ||
3 | #include <avr/power.h> | ||
4 | #include <avr/interrupt.h> | ||
5 | #include <util/delay.h> | ||
6 | #include <avr/eeprom.h> | ||
7 | #include "split_util.h" | ||
8 | #include "matrix.h" | ||
9 | #include "keyboard.h" | ||
10 | #include "config.h" | ||
11 | |||
12 | #ifdef USE_MATRIX_I2C | ||
13 | # include "i2c.h" | ||
14 | #else | ||
15 | # include "serial.h" | ||
16 | #endif | ||
17 | |||
18 | volatile bool isLeftHand = true; | ||
19 | |||
20 | static 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 | |||
33 | static void keyboard_master_setup(void) { | ||
34 | |||
35 | #ifdef USE_MATRIX_I2C | ||
36 | i2c_master_init(); | ||
37 | #else | ||
38 | serial_master_init(); | ||
39 | #endif | ||
40 | } | ||
41 | |||
42 | static void keyboard_slave_setup(void) { | ||
43 | |||
44 | #ifdef USE_MATRIX_I2C | ||
45 | i2c_slave_init(SLAVE_I2C_ADDRESS); | ||
46 | #else | ||
47 | serial_slave_init(); | ||
48 | #endif | ||
49 | } | ||
50 | |||
51 | bool has_usb(void) { | ||
52 | USBCON |= (1 << OTGPADE); //enables VBUS pad | ||
53 | _delay_us(5); | ||
54 | return (USBSTA & (1<<VBUS)); //checks state of VBUS | ||
55 | } | ||
56 | |||
57 | void split_keyboard_setup(void) { | ||
58 | setup_handedness(); | ||
59 | |||
60 | if (has_usb()) { | ||
61 | keyboard_master_setup(); | ||
62 | } else { | ||
63 | keyboard_slave_setup(); | ||
64 | } | ||
65 | sei(); | ||
66 | } | ||
67 | |||
68 | // this code runs before the usb and keyboard is initialized | ||
69 | void matrix_setup(void) { | ||
70 | split_keyboard_setup(); | ||
71 | } | ||
diff --git a/keyboards/helix/rev2/split_util.h b/keyboards/helix/rev2/split_util.h new file mode 100644 index 000000000..757e934c7 --- /dev/null +++ b/keyboards/helix/rev2/split_util.h | |||
@@ -0,0 +1,23 @@ | |||
1 | #ifndef SPLIT_KEYBOARD_UTIL_H | ||
2 | #define SPLIT_KEYBOARD_UTIL_H | ||
3 | |||
4 | #include <stdbool.h> | ||
5 | |||
6 | #ifdef EE_HANDS | ||
7 | #define EECONFIG_BOOTMAGIC_END (uint8_t *)10 | ||
8 | #define EECONFIG_HANDEDNESS EECONFIG_BOOTMAGIC_END | ||
9 | #endif | ||
10 | |||
11 | #define SLAVE_I2C_ADDRESS 0x32 | ||
12 | |||
13 | extern volatile bool isLeftHand; | ||
14 | |||
15 | // slave version of matix scan, defined in matrix.c | ||
16 | void matrix_slave_scan(void); | ||
17 | |||
18 | void split_keyboard_setup(void); | ||
19 | bool has_usb(void); | ||
20 | |||
21 | void matrix_master_OLED_init (void); | ||
22 | |||
23 | #endif | ||
diff --git a/keyboards/helix/rules.mk b/keyboards/helix/rules.mk new file mode 100644 index 000000000..c35f93fb0 --- /dev/null +++ b/keyboards/helix/rules.mk | |||
@@ -0,0 +1,73 @@ | |||
1 | SRC += i2c.c \ | ||
2 | serial.c \ | ||
3 | ssd1306.c | ||
4 | |||
5 | # MCU name | ||
6 | #MCU = at90usb1287 | ||
7 | MCU = atmega32u4 | ||
8 | |||
9 | # Processor frequency. | ||
10 | # This will define a symbol, F_CPU, in all source code files equal to the | ||
11 | # processor frequency in Hz. You can then use this symbol in your source code to | ||
12 | # calculate timings. Do NOT tack on a 'UL' at the end, this will be done | ||
13 | # automatically to create a 32-bit value in your source code. | ||
14 | # | ||
15 | # This will be an integer division of F_USB below, as it is sourced by | ||
16 | # F_USB after it has run through any CPU prescalers. Note that this value | ||
17 | # does not *change* the processor frequency - it should merely be updated to | ||
18 | # reflect the processor speed set externally so that the code can use accurate | ||
19 | # software delays. | ||
20 | F_CPU = 16000000 | ||
21 | |||
22 | # | ||
23 | # LUFA specific | ||
24 | # | ||
25 | # Target architecture (see library "Board Types" documentation). | ||
26 | ARCH = AVR8 | ||
27 | |||
28 | # Input clock frequency. | ||
29 | # This will define a symbol, F_USB, in all source code files equal to the | ||
30 | # input clock frequency (before any prescaling is performed) in Hz. This value may | ||
31 | # differ from F_CPU if prescaling is used on the latter, and is required as the | ||
32 | # raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
33 | # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
34 | # at the end, this will be done automatically to create a 32-bit value in your | ||
35 | # source code. | ||
36 | # | ||
37 | # If no clock division is performed on the input clock inside the AVR (via the | ||
38 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
39 | F_USB = $(F_CPU) | ||
40 | |||
41 | # Bootloader | ||
42 | # This definition is optional, and if your keyboard supports multiple bootloaders of | ||
43 | # different sizes, comment this out, and the correct address will be loaded | ||
44 | # automatically (+60). See bootloader.mk for all options. | ||
45 | BOOTLOADER = caterina | ||
46 | |||
47 | # Interrupt driven control endpoint task(+60) | ||
48 | OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | ||
49 | |||
50 | # Build Options | ||
51 | # change to "no" to disable the options, or define them in the Makefile in | ||
52 | # the appropriate keymap folder that will get included automatically | ||
53 | # | ||
54 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) | ||
55 | MOUSEKEY_ENABLE = no # Mouse keys(+4700) | ||
56 | EXTRAKEY_ENABLE = no # Audio control and System control(+450) | ||
57 | CONSOLE_ENABLE = no # Console for debug(+400) | ||
58 | COMMAND_ENABLE = no # Commands for debug and configuration | ||
59 | NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
60 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality | ||
61 | MIDI_ENABLE = no # MIDI controls | ||
62 | AUDIO_ENABLE = no # Audio output on port C6 | ||
63 | UNICODE_ENABLE = no # Unicode | ||
64 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
65 | RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. | ||
66 | SUBPROJECT_rev1 = no | ||
67 | USE_I2C = yes | ||
68 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | ||
69 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | ||
70 | |||
71 | CUSTOM_MATRIX = yes | ||
72 | |||
73 | DEFAULT_FOLDER = helix/rev2 | ||
diff --git a/keyboards/helix/serial.c b/keyboards/helix/serial.c new file mode 100644 index 000000000..e918ab6ee --- /dev/null +++ b/keyboards/helix/serial.c | |||
@@ -0,0 +1,238 @@ | |||
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 | |||
21 | uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0}; | ||
22 | uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0}; | ||
23 | |||
24 | #define SLAVE_DATA_CORRUPT (1<<0) | ||
25 | volatile uint8_t status = 0; | ||
26 | |||
27 | inline static | ||
28 | void serial_delay(void) { | ||
29 | _delay_us(SERIAL_DELAY); | ||
30 | } | ||
31 | void serial_delay_short(void) { | ||
32 | _delay_us(SERIAL_DELAY-1); | ||
33 | } | ||
34 | inline static | ||
35 | void serial_output(void) { | ||
36 | SERIAL_PIN_DDR |= SERIAL_PIN_MASK; | ||
37 | } | ||
38 | |||
39 | // make the serial pin an input with pull-up resistor | ||
40 | inline static | ||
41 | void serial_input(void) { | ||
42 | SERIAL_PIN_DDR &= ~SERIAL_PIN_MASK; | ||
43 | SERIAL_PIN_PORT |= SERIAL_PIN_MASK; | ||
44 | } | ||
45 | |||
46 | inline static | ||
47 | uint8_t serial_read_pin(void) { | ||
48 | return !!(SERIAL_PIN_INPUT & SERIAL_PIN_MASK); | ||
49 | } | ||
50 | |||
51 | inline static | ||
52 | void serial_low(void) { | ||
53 | SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK; | ||
54 | } | ||
55 | |||
56 | inline static | ||
57 | void serial_high(void) { | ||
58 | SERIAL_PIN_PORT |= SERIAL_PIN_MASK; | ||
59 | } | ||
60 | |||
61 | void serial_master_init(void) { | ||
62 | serial_output(); | ||
63 | serial_high(); | ||
64 | } | ||
65 | |||
66 | void serial_slave_init(void) { | ||
67 | serial_input(); | ||
68 | |||
69 | #ifndef USE_SERIAL_PD2 | ||
70 | // Enable INT0 | ||
71 | EIMSK |= _BV(INT0); | ||
72 | // Trigger on falling edge of INT0 | ||
73 | EICRA &= ~(_BV(ISC00) | _BV(ISC01)); | ||
74 | #else | ||
75 | // Enable INT2 | ||
76 | EIMSK |= _BV(INT2); | ||
77 | // Trigger on falling edge of INT2 | ||
78 | EICRA &= ~(_BV(ISC20) | _BV(ISC21)); | ||
79 | #endif | ||
80 | } | ||
81 | |||
82 | // Used by the master to synchronize timing with the slave. | ||
83 | static | ||
84 | void sync_recv(void) { | ||
85 | serial_input(); | ||
86 | // This shouldn't hang if the slave disconnects because the | ||
87 | // serial line will float to high if the slave does disconnect. | ||
88 | while (!serial_read_pin()); | ||
89 | //serial_delay(); | ||
90 | _delay_us(SERIAL_DELAY-5); | ||
91 | } | ||
92 | |||
93 | // Used by the slave to send a synchronization signal to the master. | ||
94 | static | ||
95 | void sync_send(void) { | ||
96 | serial_output(); | ||
97 | |||
98 | serial_low(); | ||
99 | serial_delay(); | ||
100 | |||
101 | serial_high(); | ||
102 | } | ||
103 | |||
104 | // Reads a byte from the serial line | ||
105 | static | ||
106 | uint8_t serial_read_byte(void) { | ||
107 | uint8_t byte = 0; | ||
108 | serial_input(); | ||
109 | for ( uint8_t i = 0; i < 8; ++i) { | ||
110 | byte = (byte << 1) | serial_read_pin(); | ||
111 | serial_delay(); | ||
112 | _delay_us(1); | ||
113 | } | ||
114 | |||
115 | return byte; | ||
116 | } | ||
117 | |||
118 | // Sends a byte with MSB ordering | ||
119 | static | ||
120 | void serial_write_byte(uint8_t data) { | ||
121 | uint8_t b = 8; | ||
122 | serial_output(); | ||
123 | while( b-- ) { | ||
124 | if(data & (1 << b)) { | ||
125 | serial_high(); | ||
126 | } else { | ||
127 | serial_low(); | ||
128 | } | ||
129 | serial_delay(); | ||
130 | } | ||
131 | } | ||
132 | |||
133 | // interrupt handle to be used by the slave device | ||
134 | ISR(SERIAL_PIN_INTERRUPT) { | ||
135 | sync_send(); | ||
136 | |||
137 | uint8_t checksum = 0; | ||
138 | for (int i = 0; i < SERIAL_SLAVE_BUFFER_LENGTH; ++i) { | ||
139 | serial_write_byte(serial_slave_buffer[i]); | ||
140 | sync_send(); | ||
141 | checksum += serial_slave_buffer[i]; | ||
142 | } | ||
143 | serial_write_byte(checksum); | ||
144 | sync_send(); | ||
145 | |||
146 | // wait for the sync to finish sending | ||
147 | serial_delay(); | ||
148 | |||
149 | // read the middle of pulses | ||
150 | _delay_us(SERIAL_DELAY/2); | ||
151 | |||
152 | uint8_t checksum_computed = 0; | ||
153 | for (int i = 0; i < SERIAL_MASTER_BUFFER_LENGTH; ++i) { | ||
154 | serial_master_buffer[i] = serial_read_byte(); | ||
155 | sync_send(); | ||
156 | checksum_computed += serial_master_buffer[i]; | ||
157 | } | ||
158 | uint8_t checksum_received = serial_read_byte(); | ||
159 | sync_send(); | ||
160 | |||
161 | serial_input(); // end transaction | ||
162 | |||
163 | if ( checksum_computed != checksum_received ) { | ||
164 | status |= SLAVE_DATA_CORRUPT; | ||
165 | } else { | ||
166 | status &= ~SLAVE_DATA_CORRUPT; | ||
167 | } | ||
168 | } | ||
169 | |||
170 | inline | ||
171 | bool serial_slave_DATA_CORRUPT(void) { | ||
172 | return status & SLAVE_DATA_CORRUPT; | ||
173 | } | ||
174 | |||
175 | // Copies the serial_slave_buffer to the master and sends the | ||
176 | // serial_master_buffer to the slave. | ||
177 | // | ||
178 | // Returns: | ||
179 | // 0 => no error | ||
180 | // 1 => slave did not respond | ||
181 | int serial_update_buffers(void) { | ||
182 | // this code is very time dependent, so we need to disable interrupts | ||
183 | cli(); | ||
184 | |||
185 | // signal to the slave that we want to start a transaction | ||
186 | serial_output(); | ||
187 | serial_low(); | ||
188 | _delay_us(1); | ||
189 | |||
190 | // wait for the slaves response | ||
191 | serial_input(); | ||
192 | serial_high(); | ||
193 | _delay_us(SERIAL_DELAY); | ||
194 | |||
195 | // check if the slave is present | ||
196 | if (serial_read_pin()) { | ||
197 | // slave failed to pull the line low, assume not present | ||
198 | sei(); | ||
199 | return 1; | ||
200 | } | ||
201 | |||
202 | // if the slave is present syncronize with it | ||
203 | sync_recv(); | ||
204 | |||
205 | uint8_t checksum_computed = 0; | ||
206 | // receive data from the slave | ||
207 | for (int i = 0; i < SERIAL_SLAVE_BUFFER_LENGTH; ++i) { | ||
208 | serial_slave_buffer[i] = serial_read_byte(); | ||
209 | sync_recv(); | ||
210 | checksum_computed += serial_slave_buffer[i]; | ||
211 | } | ||
212 | uint8_t checksum_received = serial_read_byte(); | ||
213 | sync_recv(); | ||
214 | |||
215 | if (checksum_computed != checksum_received) { | ||
216 | sei(); | ||
217 | return 2; | ||
218 | } | ||
219 | |||
220 | uint8_t checksum = 0; | ||
221 | // send data to the slave | ||
222 | for (int i = 0; i < SERIAL_MASTER_BUFFER_LENGTH; ++i) { | ||
223 | serial_write_byte(serial_master_buffer[i]); | ||
224 | sync_recv(); | ||
225 | checksum += serial_master_buffer[i]; | ||
226 | } | ||
227 | serial_write_byte(checksum); | ||
228 | sync_recv(); | ||
229 | |||
230 | // always, release the line when not in use | ||
231 | serial_output(); | ||
232 | serial_high(); | ||
233 | |||
234 | sei(); | ||
235 | return 0; | ||
236 | } | ||
237 | |||
238 | #endif | ||
diff --git a/keyboards/helix/serial.h b/keyboards/helix/serial.h new file mode 100644 index 000000000..8f15d6675 --- /dev/null +++ b/keyboards/helix/serial.h | |||
@@ -0,0 +1,36 @@ | |||
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 | |||
12 | #ifndef USE_SERIAL_PD2 | ||
13 | #define SERIAL_PIN_MASK _BV(PD0) | ||
14 | #define SERIAL_PIN_INTERRUPT INT0_vect | ||
15 | #else | ||
16 | #define SERIAL_PIN_MASK _BV(PD2) | ||
17 | #define SERIAL_PIN_INTERRUPT INT2_vect | ||
18 | #endif | ||
19 | |||
20 | #define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2 | ||
21 | #ifdef KEYBOARD_helix_rev1 | ||
22 | #define SERIAL_MASTER_BUFFER_LENGTH 1 | ||
23 | #else | ||
24 | #define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2 | ||
25 | #endif | ||
26 | |||
27 | // Buffers for master - slave communication | ||
28 | extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH]; | ||
29 | extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH]; | ||
30 | |||
31 | void serial_master_init(void); | ||
32 | void serial_slave_init(void); | ||
33 | int serial_update_buffers(void); | ||
34 | bool serial_slave_data_corrupt(void); | ||
35 | |||
36 | #endif | ||
diff --git a/keyboards/helix/ssd1306.c b/keyboards/helix/ssd1306.c new file mode 100644 index 000000000..80efc3d16 --- /dev/null +++ b/keyboards/helix/ssd1306.c | |||
@@ -0,0 +1,324 @@ | |||
1 | #ifdef SSD1306OLED | ||
2 | |||
3 | #include "ssd1306.h" | ||
4 | #include "i2c.h" | ||
5 | #include <string.h> | ||
6 | #include "print.h" | ||
7 | #include "common/glcdfont.c" | ||
8 | #ifdef ADAFRUIT_BLE_ENABLE | ||
9 | #include "adafruit_ble.h" | ||
10 | #endif | ||
11 | #ifdef PROTOCOL_LUFA | ||
12 | #include "lufa.h" | ||
13 | #endif | ||
14 | #include "sendchar.h" | ||
15 | #include "timer.h" | ||
16 | |||
17 | // Set this to 1 to help diagnose early startup problems | ||
18 | // when testing power-on with ble. Turn it off otherwise, | ||
19 | // as the latency of printing most of the debug info messes | ||
20 | // with the matrix scan, causing keys to drop. | ||
21 | #define DEBUG_TO_SCREEN 0 | ||
22 | |||
23 | //static uint16_t last_battery_update; | ||
24 | //static uint32_t vbat; | ||
25 | //#define BatteryUpdateInterval 10000 /* milliseconds */ | ||
26 | #define ScreenOffInterval 300000 /* milliseconds */ | ||
27 | #if DEBUG_TO_SCREEN | ||
28 | static uint8_t displaying; | ||
29 | #endif | ||
30 | static uint16_t last_flush; | ||
31 | |||
32 | // Write command sequence. | ||
33 | // Returns true on success. | ||
34 | static inline bool _send_cmd1(uint8_t cmd) { | ||
35 | bool res = false; | ||
36 | |||
37 | if (i2c_start_write(SSD1306_ADDRESS)) { | ||
38 | xprintf("failed to start write to %d\n", SSD1306_ADDRESS); | ||
39 | goto done; | ||
40 | } | ||
41 | |||
42 | if (i2c_master_write(0x0 /* command byte follows */)) { | ||
43 | print("failed to write control byte\n"); | ||
44 | |||
45 | goto done; | ||
46 | } | ||
47 | |||
48 | if (i2c_master_write(cmd)) { | ||
49 | xprintf("failed to write command %d\n", cmd); | ||
50 | goto done; | ||
51 | } | ||
52 | res = true; | ||
53 | done: | ||
54 | i2c_master_stop(); | ||
55 | return res; | ||
56 | } | ||
57 | |||
58 | // Write 2-byte command sequence. | ||
59 | // Returns true on success | ||
60 | static inline bool _send_cmd2(uint8_t cmd, uint8_t opr) { | ||
61 | if (!_send_cmd1(cmd)) { | ||
62 | return false; | ||
63 | } | ||
64 | return _send_cmd1(opr); | ||
65 | } | ||
66 | |||
67 | // Write 3-byte command sequence. | ||
68 | // Returns true on success | ||
69 | static inline bool _send_cmd3(uint8_t cmd, uint8_t opr1, uint8_t opr2) { | ||
70 | if (!_send_cmd1(cmd)) { | ||
71 | return false; | ||
72 | } | ||
73 | if (!_send_cmd1(opr1)) { | ||
74 | return false; | ||
75 | } | ||
76 | return _send_cmd1(opr2); | ||
77 | } | ||
78 | |||
79 | #define send_cmd1(c) if (!_send_cmd1(c)) {goto done;} | ||
80 | #define send_cmd2(c,o) if (!_send_cmd2(c,o)) {goto done;} | ||
81 | #define send_cmd3(c,o1,o2) if (!_send_cmd3(c,o1,o2)) {goto done;} | ||
82 | |||
83 | static void clear_display(void) { | ||
84 | matrix_clear(&display); | ||
85 | |||
86 | // Clear all of the display bits (there can be random noise | ||
87 | // in the RAM on startup) | ||
88 | send_cmd3(PageAddr, 0, (DisplayHeight / 8) - 1); | ||
89 | send_cmd3(ColumnAddr, 0, DisplayWidth - 1); | ||
90 | |||
91 | if (i2c_start_write(SSD1306_ADDRESS)) { | ||
92 | goto done; | ||
93 | } | ||
94 | if (i2c_master_write(0x40)) { | ||
95 | // Data mode | ||
96 | goto done; | ||
97 | } | ||
98 | for (uint8_t row = 0; row < MatrixRows; ++row) { | ||
99 | for (uint8_t col = 0; col < DisplayWidth; ++col) { | ||
100 | i2c_master_write(0); | ||
101 | } | ||
102 | } | ||
103 | |||
104 | display.dirty = false; | ||
105 | |||
106 | done: | ||
107 | i2c_master_stop(); | ||
108 | } | ||
109 | |||
110 | #if DEBUG_TO_SCREEN | ||
111 | #undef sendchar | ||
112 | static int8_t capture_sendchar(uint8_t c) { | ||
113 | sendchar(c); | ||
114 | iota_gfx_write_char(c); | ||
115 | |||
116 | if (!displaying) { | ||
117 | iota_gfx_flush(); | ||
118 | } | ||
119 | return 0; | ||
120 | } | ||
121 | #endif | ||
122 | |||
123 | bool iota_gfx_init(bool rotate) { | ||
124 | bool success = false; | ||
125 | |||
126 | send_cmd1(DisplayOff); | ||
127 | send_cmd2(SetDisplayClockDiv, 0x80); | ||
128 | send_cmd2(SetMultiPlex, DisplayHeight - 1); | ||
129 | |||
130 | send_cmd2(SetDisplayOffset, 0); | ||
131 | |||
132 | |||
133 | send_cmd1(SetStartLine | 0x0); | ||
134 | send_cmd2(SetChargePump, 0x14 /* Enable */); | ||
135 | send_cmd2(SetMemoryMode, 0 /* horizontal addressing */); | ||
136 | |||
137 | if(rotate){ | ||
138 | // the following Flip the display orientation 180 degrees | ||
139 | send_cmd1(SegRemap); | ||
140 | send_cmd1(ComScanInc); | ||
141 | }else{ | ||
142 | // Flips the display orientation 0 degrees | ||
143 | send_cmd1(SegRemap | 0x1); | ||
144 | send_cmd1(ComScanDec); | ||
145 | } | ||
146 | |||
147 | send_cmd2(SetComPins, 0x2); | ||
148 | send_cmd2(SetContrast, 0x8f); | ||
149 | send_cmd2(SetPreCharge, 0xf1); | ||
150 | send_cmd2(SetVComDetect, 0x40); | ||
151 | send_cmd1(DisplayAllOnResume); | ||
152 | send_cmd1(NormalDisplay); | ||
153 | send_cmd1(DeActivateScroll); | ||
154 | send_cmd1(DisplayOn); | ||
155 | |||
156 | send_cmd2(SetContrast, 0); // Dim | ||
157 | |||
158 | clear_display(); | ||
159 | |||
160 | success = true; | ||
161 | |||
162 | iota_gfx_flush(); | ||
163 | |||
164 | #if DEBUG_TO_SCREEN | ||
165 | print_set_sendchar(capture_sendchar); | ||
166 | #endif | ||
167 | |||
168 | done: | ||
169 | return success; | ||
170 | } | ||
171 | |||
172 | bool iota_gfx_off(void) { | ||
173 | bool success = false; | ||
174 | |||
175 | send_cmd1(DisplayOff); | ||
176 | success = true; | ||
177 | |||
178 | done: | ||
179 | return success; | ||
180 | } | ||
181 | |||
182 | bool iota_gfx_on(void) { | ||
183 | bool success = false; | ||
184 | |||
185 | send_cmd1(DisplayOn); | ||
186 | success = true; | ||
187 | |||
188 | done: | ||
189 | return success; | ||
190 | } | ||
191 | |||
192 | void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c) { | ||
193 | *matrix->cursor = c; | ||
194 | ++matrix->cursor; | ||
195 | |||
196 | if (matrix->cursor - &matrix->display[0][0] == sizeof(matrix->display)) { | ||
197 | // We went off the end; scroll the display upwards by one line | ||
198 | memmove(&matrix->display[0], &matrix->display[1], | ||
199 | MatrixCols * (MatrixRows - 1)); | ||
200 | matrix->cursor = &matrix->display[MatrixRows - 1][0]; | ||
201 | memset(matrix->cursor, ' ', MatrixCols); | ||
202 | } | ||
203 | } | ||
204 | |||
205 | void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c) { | ||
206 | matrix->dirty = true; | ||
207 | |||
208 | if (c == '\n') { | ||
209 | // Clear to end of line from the cursor and then move to the | ||
210 | // start of the next line | ||
211 | uint8_t cursor_col = (matrix->cursor - &matrix->display[0][0]) % MatrixCols; | ||
212 | |||
213 | while (cursor_col++ < MatrixCols) { | ||
214 | matrix_write_char_inner(matrix, ' '); | ||
215 | } | ||
216 | return; | ||
217 | } | ||
218 | |||
219 | matrix_write_char_inner(matrix, c); | ||
220 | } | ||
221 | |||
222 | void iota_gfx_write_char(uint8_t c) { | ||
223 | matrix_write_char(&display, c); | ||
224 | } | ||
225 | |||
226 | void matrix_write(struct CharacterMatrix *matrix, const char *data) { | ||
227 | const char *end = data + strlen(data); | ||
228 | while (data < end) { | ||
229 | matrix_write_char(matrix, *data); | ||
230 | ++data; | ||
231 | } | ||
232 | } | ||
233 | |||
234 | void iota_gfx_write(const char *data) { | ||
235 | matrix_write(&display, data); | ||
236 | } | ||
237 | |||
238 | void matrix_write_P(struct CharacterMatrix *matrix, const char *data) { | ||
239 | while (true) { | ||
240 | uint8_t c = pgm_read_byte(data); | ||
241 | if (c == 0) { | ||
242 | return; | ||
243 | } | ||
244 | matrix_write_char(matrix, c); | ||
245 | ++data; | ||
246 | } | ||
247 | } | ||
248 | |||
249 | void iota_gfx_write_P(const char *data) { | ||
250 | matrix_write_P(&display, data); | ||
251 | } | ||
252 | |||
253 | void matrix_clear(struct CharacterMatrix *matrix) { | ||
254 | memset(matrix->display, ' ', sizeof(matrix->display)); | ||
255 | matrix->cursor = &matrix->display[0][0]; | ||
256 | matrix->dirty = true; | ||
257 | } | ||
258 | |||
259 | void iota_gfx_clear_screen(void) { | ||
260 | matrix_clear(&display); | ||
261 | } | ||
262 | |||
263 | void matrix_render(struct CharacterMatrix *matrix) { | ||
264 | last_flush = timer_read(); | ||
265 | iota_gfx_on(); | ||
266 | #if DEBUG_TO_SCREEN | ||
267 | ++displaying; | ||
268 | #endif | ||
269 | |||
270 | // Move to the home position | ||
271 | send_cmd3(PageAddr, 0, MatrixRows - 1); | ||
272 | send_cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1); | ||
273 | |||
274 | if (i2c_start_write(SSD1306_ADDRESS)) { | ||
275 | goto done; | ||
276 | } | ||
277 | if (i2c_master_write(0x40)) { | ||
278 | // Data mode | ||
279 | goto done; | ||
280 | } | ||
281 | |||
282 | for (uint8_t row = 0; row < MatrixRows; ++row) { | ||
283 | for (uint8_t col = 0; col < MatrixCols; ++col) { | ||
284 | const uint8_t *glyph = font + (matrix->display[row][col] * FontWidth); | ||
285 | |||
286 | for (uint8_t glyphCol = 0; glyphCol < FontWidth; ++glyphCol) { | ||
287 | uint8_t colBits = pgm_read_byte(glyph + glyphCol); | ||
288 | i2c_master_write(colBits); | ||
289 | } | ||
290 | |||
291 | // 1 column of space between chars (it's not included in the glyph) | ||
292 | //i2c_master_write(0); | ||
293 | } | ||
294 | } | ||
295 | |||
296 | matrix->dirty = false; | ||
297 | |||
298 | done: | ||
299 | i2c_master_stop(); | ||
300 | #if DEBUG_TO_SCREEN | ||
301 | --displaying; | ||
302 | #endif | ||
303 | } | ||
304 | |||
305 | void iota_gfx_flush(void) { | ||
306 | matrix_render(&display); | ||
307 | } | ||
308 | |||
309 | __attribute__ ((weak)) | ||
310 | void iota_gfx_task_user(void) { | ||
311 | } | ||
312 | |||
313 | void iota_gfx_task(void) { | ||
314 | iota_gfx_task_user(); | ||
315 | |||
316 | if (display.dirty) { | ||
317 | iota_gfx_flush(); | ||
318 | } | ||
319 | |||
320 | if (timer_elapsed(last_flush) > ScreenOffInterval) { | ||
321 | iota_gfx_off(); | ||
322 | } | ||
323 | } | ||
324 | #endif | ||
diff --git a/keyboards/helix/ssd1306.h b/keyboards/helix/ssd1306.h new file mode 100644 index 000000000..b65c505c9 --- /dev/null +++ b/keyboards/helix/ssd1306.h | |||
@@ -0,0 +1,93 @@ | |||
1 | #ifndef SSD1306_H | ||
2 | #define SSD1306_H | ||
3 | |||
4 | #include <stdbool.h> | ||
5 | #include <stdio.h> | ||
6 | #include "pincontrol.h" | ||
7 | #include "config.h" | ||
8 | |||
9 | enum ssd1306_cmds { | ||
10 | DisplayOff = 0xAE, | ||
11 | DisplayOn = 0xAF, | ||
12 | |||
13 | SetContrast = 0x81, | ||
14 | DisplayAllOnResume = 0xA4, | ||
15 | |||
16 | DisplayAllOn = 0xA5, | ||
17 | NormalDisplay = 0xA6, | ||
18 | InvertDisplay = 0xA7, | ||
19 | SetDisplayOffset = 0xD3, | ||
20 | SetComPins = 0xda, | ||
21 | SetVComDetect = 0xdb, | ||
22 | SetDisplayClockDiv = 0xD5, | ||
23 | SetPreCharge = 0xd9, | ||
24 | SetMultiPlex = 0xa8, | ||
25 | SetLowColumn = 0x00, | ||
26 | SetHighColumn = 0x10, | ||
27 | SetStartLine = 0x40, | ||
28 | |||
29 | SetMemoryMode = 0x20, | ||
30 | ColumnAddr = 0x21, | ||
31 | PageAddr = 0x22, | ||
32 | |||
33 | ComScanInc = 0xc0, | ||
34 | ComScanDec = 0xc8, | ||
35 | SegRemap = 0xa0, | ||
36 | SetChargePump = 0x8d, | ||
37 | ExternalVcc = 0x01, | ||
38 | SwitchCapVcc = 0x02, | ||
39 | |||
40 | ActivateScroll = 0x2f, | ||
41 | DeActivateScroll = 0x2e, | ||
42 | SetVerticalScrollArea = 0xa3, | ||
43 | RightHorizontalScroll = 0x26, | ||
44 | LeftHorizontalScroll = 0x27, | ||
45 | VerticalAndRightHorizontalScroll = 0x29, | ||
46 | VerticalAndLeftHorizontalScroll = 0x2a, | ||
47 | }; | ||
48 | |||
49 | // Controls the SSD1306 128x32 OLED display via i2c | ||
50 | |||
51 | #ifndef SSD1306_ADDRESS | ||
52 | #define SSD1306_ADDRESS 0x3C | ||
53 | #endif | ||
54 | |||
55 | #define DisplayHeight 32 | ||
56 | #define DisplayWidth 128 | ||
57 | |||
58 | #define FontHeight 8 | ||
59 | #define FontWidth 6 | ||
60 | |||
61 | #define MatrixRows (DisplayHeight / FontHeight) | ||
62 | #define MatrixCols (DisplayWidth / FontWidth) | ||
63 | |||
64 | struct CharacterMatrix { | ||
65 | uint8_t display[MatrixRows][MatrixCols]; | ||
66 | uint8_t *cursor; | ||
67 | bool dirty; | ||
68 | }; | ||
69 | |||
70 | struct CharacterMatrix display; | ||
71 | |||
72 | bool iota_gfx_init(bool rotate); | ||
73 | void iota_gfx_task(void); | ||
74 | bool iota_gfx_off(void); | ||
75 | bool iota_gfx_on(void); | ||
76 | void iota_gfx_flush(void); | ||
77 | void iota_gfx_write_char(uint8_t c); | ||
78 | void iota_gfx_write(const char *data); | ||
79 | void iota_gfx_write_P(const char *data); | ||
80 | void iota_gfx_clear_screen(void); | ||
81 | |||
82 | void iota_gfx_task_user(void); | ||
83 | |||
84 | void matrix_clear(struct CharacterMatrix *matrix); | ||
85 | void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c); | ||
86 | void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c); | ||
87 | void matrix_write(struct CharacterMatrix *matrix, const char *data); | ||
88 | void matrix_write_P(struct CharacterMatrix *matrix, const char *data); | ||
89 | void matrix_render(struct CharacterMatrix *matrix); | ||
90 | |||
91 | |||
92 | |||
93 | #endif | ||