aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2019-08-21 17:19:07 -0700
committerGitHub <noreply@github.com>2019-08-21 17:19:07 -0700
commit94efa18c28c8c0e08526c9665a8f0d6a4e7d3e96 (patch)
treef45a54ddfa7a8ec4539c78bbadeb1d3960727f2e
parent1c5b0cbbeb049b1ce3fb2da6a81fbf83dd9a3ea7 (diff)
downloadqmk_firmware-94efa18c28c8c0e08526c9665a8f0d6a4e7d3e96.tar.gz
qmk_firmware-94efa18c28c8c0e08526c9665a8f0d6a4e7d3e96.zip
[Keyboard] Updates to ZSA boards (#6513)
* Update Layer functions to use layer_state_t in ZSA Boards * Update Music Mask for ZSA boards Fixes an issue with the board getting stuck on Adjust layer when activating music mode * Add Support for SMART LED Toggle to Planck EZ * Add support for SMART LED toggle in Ergodox EZ * Ifdef swiss cheeze for Oryx Configurator * Documentation and updates * Add Oryx Keymap * Add option to configure the layers for the Layer Indicator * Update keymap with better examples * Make sure eeprom is initialized before reading from it * Force flush of LED matrix when suspending board This fixes an issue where the LEDs don't fully clear sometimes when the host system goes to sleep * Enable RGB Sleeping by default * Add clarification about planck ez led layer config
-rw-r--r--keyboards/ergodox_ez/config.h4
-rw-r--r--keyboards/ergodox_ez/ergodox_ez.c74
-rw-r--r--keyboards/ergodox_ez/ergodox_ez.h19
-rw-r--r--keyboards/ergodox_ez/keymaps/default/keymap.c6
-rw-r--r--keyboards/planck/ez/config.h1
-rw-r--r--keyboards/planck/ez/ez.c94
-rw-r--r--keyboards/planck/ez/ez.h5
-rw-r--r--keyboards/planck/ez/readme.md41
-rw-r--r--keyboards/planck/keymaps/default/keymap.c2
-rw-r--r--keyboards/planck/keymaps/oryx/config.h16
-rw-r--r--keyboards/planck/keymaps/oryx/keymap.c372
-rw-r--r--keyboards/planck/keymaps/oryx/rules.mk6
12 files changed, 629 insertions, 11 deletions
diff --git a/keyboards/ergodox_ez/config.h b/keyboards/ergodox_ez/config.h
index 45ca06a5d..c35fe7394 100644
--- a/keyboards/ergodox_ez/config.h
+++ b/keyboards/ergodox_ez/config.h
@@ -85,6 +85,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
85 85
86#define RGBW 1 86#define RGBW 1
87 87
88#define RGBLIGHT_SLEEP
89
88/* 90/*
89 * The debounce filtering reports a key/switch change directly, 91 * The debounce filtering reports a key/switch change directly,
90 * without any extra delay. After that the debounce logic will filter 92 * without any extra delay. After that the debounce logic will filter
@@ -112,6 +114,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
112#define RGB_MATRIX_LED_PROCESS_LIMIT 5 114#define RGB_MATRIX_LED_PROCESS_LIMIT 5
113#define RGB_MATRIX_LED_FLUSH_LIMIT 26 115#define RGB_MATRIX_LED_FLUSH_LIMIT 26
114 116
117#define RGB_DISABLE_WHEN_USB_SUSPENDED true
118
115// #define RGBLIGHT_COLOR_LAYER_0 0x00, 0x00, 0xFF 119// #define RGBLIGHT_COLOR_LAYER_0 0x00, 0x00, 0xFF
116/* #define RGBLIGHT_COLOR_LAYER_1 0x00, 0x00, 0xFF */ 120/* #define RGBLIGHT_COLOR_LAYER_1 0x00, 0x00, 0xFF */
117/* #define RGBLIGHT_COLOR_LAYER_2 0xFF, 0x00, 0x00 */ 121/* #define RGBLIGHT_COLOR_LAYER_2 0xFF, 0x00, 0x00 */
diff --git a/keyboards/ergodox_ez/ergodox_ez.c b/keyboards/ergodox_ez/ergodox_ez.c
index 947a173e3..d313f7d5d 100644
--- a/keyboards/ergodox_ez/ergodox_ez.c
+++ b/keyboards/ergodox_ez/ergodox_ez.c
@@ -22,6 +22,8 @@ extern inline void ergodox_right_led_set(uint8_t led, uint8_t n);
22 22
23extern inline void ergodox_led_all_set(uint8_t n); 23extern inline void ergodox_led_all_set(uint8_t n);
24 24
25keyboard_config_t keyboard_config;
26
25bool i2c_initialized = 0; 27bool i2c_initialized = 0;
26i2c_status_t mcp23018_status = 0x20; 28i2c_status_t mcp23018_status = 0x20;
27 29
@@ -43,6 +45,16 @@ void matrix_init_kb(void) {
43 PORTD |= (1<<5 | 1<<4); 45 PORTD |= (1<<5 | 1<<4);
44 PORTE |= (1<<6); 46 PORTE |= (1<<6);
45 47
48 keyboard_config.raw = eeconfig_read_kb();
49 ergodox_led_all_set((uint8_t)keyboard_config.led_level * 255 / 4 );
50#ifdef RGB_MATRIX_ENABLE
51 if (keyboard_config.rgb_matrix_enable) {
52 rgb_matrix_set_flags(LED_FLAG_ALL);
53 } else {
54 rgb_matrix_set_flags(LED_FLAG_NONE);
55 }
56#endif
57
46 ergodox_blink_all_leds(); 58 ergodox_blink_all_leds();
47 59
48 matrix_init_user(); 60 matrix_init_user();
@@ -305,6 +317,7 @@ led_config_t g_led_config = { {
305} }; 317} };
306 318
307void suspend_power_down_kb(void) { 319void suspend_power_down_kb(void) {
320 rgb_matrix_set_color_all(0, 0, 0);
308 rgb_matrix_set_suspend_state(true); 321 rgb_matrix_set_suspend_state(true);
309 suspend_power_down_user(); 322 suspend_power_down_user();
310} 323}
@@ -314,4 +327,65 @@ void suspend_power_down_kb(void) {
314 suspend_wakeup_init_user(); 327 suspend_wakeup_init_user();
315} 328}
316 329
330#ifdef ORYX_CONFIGURATOR
331void keyboard_post_init_kb(void) {
332 rgb_matrix_enable_noeeprom();
333 keyboard_post_init_user();
334}
317#endif 335#endif
336#endif
337
338#ifdef ORYX_CONFIGURATOR
339bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
340 switch (keycode) {
341 case LED_LEVEL:
342 if (record->event.pressed) {
343 keyboard_config.led_level++;
344 if (keyboard_config.led_level > 4) {
345 keyboard_config.led_level = 0;
346 }
347 ergodox_led_all_set((uint8_t)keyboard_config.led_level * 255 / 4 );
348 eeconfig_update_kb(keyboard_config.raw);
349 layer_state_set_kb(layer_state);
350 }
351 break;
352#ifdef RGB_MATRIX_ENABLE
353 case TOGGLE_LAYER_COLOR:
354 if (record->event.pressed) {
355 keyboard_config.disable_layer_led ^= 1;
356 if (keyboard_config.disable_layer_led)
357 rgb_matrix_set_color_all(0, 0, 0);
358 eeconfig_update_kb(keyboard_config.raw);
359 }
360 break;
361 case RGB_TOG:
362 if (record->event.pressed) {
363 switch (rgb_matrix_get_flags()) {
364 case LED_FLAG_ALL: {
365 rgb_matrix_set_flags(LED_FLAG_NONE);
366 keyboard_config.rgb_matrix_enable = false;
367 rgb_matrix_set_color_all(0, 0, 0);
368 }
369 break;
370 default: {
371 rgb_matrix_set_flags(LED_FLAG_ALL);
372 keyboard_config.rgb_matrix_enable = true;
373 }
374 break;
375 }
376 eeconfig_update_kb(keyboard_config.raw);
377 }
378 return false;
379#endif
380 }
381 return process_record_user(keycode, record);
382}
383#endif
384
385void eeconfig_init_kb(void) { // EEPROM is getting reset!
386 keyboard_config.raw = 0;
387 keyboard_config.led_level = 4;
388 keyboard_config.rgb_matrix_enable = true;
389 eeconfig_update_kb(keyboard_config.raw);
390 eeconfig_init_user();
391}
diff --git a/keyboards/ergodox_ez/ergodox_ez.h b/keyboards/ergodox_ez/ergodox_ez.h
index 383702b95..7ff62d38a 100644
--- a/keyboards/ergodox_ez/ergodox_ez.h
+++ b/keyboards/ergodox_ez/ergodox_ez.h
@@ -107,6 +107,25 @@ inline void ergodox_led_all_set(uint8_t n)
107 ergodox_right_led_3_set(n); 107 ergodox_right_led_3_set(n);
108} 108}
109 109
110#ifdef ORYX_CONFIGURATOR
111enum ergodox_ez_keycodes {
112 LED_LEVEL = SAFE_RANGE,
113 TOGGLE_LAYER_COLOR,
114 EZ_SAFE_RANGE,
115};
116#endif
117
118typedef union {
119 uint32_t raw;
120 struct {
121 uint8_t led_level :3;
122 bool disable_layer_led :1;
123 bool rgb_matrix_enable :1;
124 };
125} keyboard_config_t;
126
127extern keyboard_config_t keyboard_config;
128
110/* 129/*
111 * LEFT HAND: LINES 115-122 130 * LEFT HAND: LINES 115-122
112 * RIGHT HAND: LINES 124-131 131 * RIGHT HAND: LINES 124-131
diff --git a/keyboards/ergodox_ez/keymaps/default/keymap.c b/keyboards/ergodox_ez/keymaps/default/keymap.c
index 40d0a1eaf..fb3d3896b 100644
--- a/keyboards/ergodox_ez/keymaps/default/keymap.c
+++ b/keyboards/ergodox_ez/keymaps/default/keymap.c
@@ -6,7 +6,11 @@
6#define MDIA 2 // media keys 6#define MDIA 2 // media keys
7 7
8enum custom_keycodes { 8enum custom_keycodes {
9#ifdef ORYX_CONFIGURATOR
10 EPRM = EZ_SAFE_RANGE,
11#else
9 EPRM = SAFE_RANGE, 12 EPRM = SAFE_RANGE,
13#endif
10 VRSN, 14 VRSN,
11 RGB_SLD 15 RGB_SLD
12}; 16};
@@ -164,7 +168,7 @@ void matrix_init_user(void) {
164}; 168};
165 169
166// Runs whenever there is a layer state change. 170// Runs whenever there is a layer state change.
167uint32_t layer_state_set_user(uint32_t state) { 171layer_state_t layer_state_set_user(layer_state_t state) {
168 ergodox_board_led_off(); 172 ergodox_board_led_off();
169 ergodox_right_led_1_off(); 173 ergodox_right_led_1_off();
170 ergodox_right_led_2_off(); 174 ergodox_right_led_2_off();
diff --git a/keyboards/planck/ez/config.h b/keyboards/planck/ez/config.h
index 61d9981c1..0cb428dd8 100644
--- a/keyboards/planck/ez/config.h
+++ b/keyboards/planck/ez/config.h
@@ -139,6 +139,7 @@
139 139
140#define RGB_MATRIX_KEYPRESSES 140#define RGB_MATRIX_KEYPRESSES
141#define RGB_MATRIX_FRAMEBUFFER_EFFECTS 141#define RGB_MATRIX_FRAMEBUFFER_EFFECTS
142#define RGB_DISABLE_WHEN_USB_SUSPENDED true
142 143
143#define RGB_MATRIX_LED_PROCESS_LIMIT 5 144#define RGB_MATRIX_LED_PROCESS_LIMIT 5
144#define RGB_MATRIX_LED_FLUSH_LIMIT 26 145#define RGB_MATRIX_LED_FLUSH_LIMIT 26
diff --git a/keyboards/planck/ez/ez.c b/keyboards/planck/ez/ez.c
index 8734042a4..8369ce50c 100644
--- a/keyboards/planck/ez/ez.c
+++ b/keyboards/planck/ez/ez.c
@@ -16,8 +16,8 @@
16#include "ez.h" 16#include "ez.h"
17#include "ch.h" 17#include "ch.h"
18#include "hal.h" 18#include "hal.h"
19 keyboard_config_t keyboard_config;
20 19
20keyboard_config_t keyboard_config;
21 21
22#ifdef RGB_MATRIX_ENABLE 22#ifdef RGB_MATRIX_ENABLE
23const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { 23const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
@@ -106,6 +106,7 @@ led_config_t g_led_config = { {
106} }; 106} };
107 107
108void suspend_power_down_kb(void) { 108void suspend_power_down_kb(void) {
109 rgb_matrix_set_color_all(0, 0, 0);
109 rgb_matrix_set_suspend_state(true); 110 rgb_matrix_set_suspend_state(true);
110 suspend_power_down_user(); 111 suspend_power_down_user();
111} 112}
@@ -207,33 +208,65 @@ void led_initialize_hardware(void) {
207} 208}
208 209
209void keyboard_pre_init_kb(void) { 210void keyboard_pre_init_kb(void) {
211 if (!eeconfig_is_enabled()) {
212 eeconfig_init();
213 }
210 // read kb settings from eeprom 214 // read kb settings from eeprom
211 keyboard_config.raw = eeconfig_read_kb(); 215 keyboard_config.raw = eeconfig_read_kb();
212 216#if defined(RGB_MATRIX_ENABLE) && defined(ORYX_CONFIGURATOR)
213 // initialize settings for front LEDs 217 if (keyboard_config.rgb_matrix_enable) {
218 rgb_matrix_set_flags(LED_FLAG_ALL);
219 } else {
220 rgb_matrix_set_flags(LED_FLAG_NONE);
221 }
222#endif
214 led_initialize_hardware(); 223 led_initialize_hardware();
224 keyboard_pre_init_user();
225}
226
227#if defined(RGB_MATRIX_ENABLE) && defined(ORYX_CONFIGURATOR)
228void keyboard_post_init_kb(void) {
229 rgb_matrix_enable_noeeprom();
230 keyboard_post_init_user();
215} 231}
232#endif
216 233
217void eeconfig_init_kb(void) { // EEPROM is getting reset! 234void eeconfig_init_kb(void) { // EEPROM is getting reset!
218 keyboard_config.raw = 0; 235 keyboard_config.raw = 0;
236 keyboard_config.rgb_matrix_enable = true;
219 keyboard_config.led_level = 4; 237 keyboard_config.led_level = 4;
220 eeconfig_update_kb(keyboard_config.raw); 238 eeconfig_update_kb(keyboard_config.raw);
221 eeconfig_init_user(); 239 eeconfig_init_user();
222} 240}
223 241
242
243#ifdef ORYX_CONFIGURATOR
244
245#ifndef PLANCK_EZ_USER_LEDS
246
247#ifndef PLANCK_EZ_LED_LOWER
248# define PLANCK_EZ_LED_LOWER 3
249#endif
250#ifndef PLANCK_EZ_LED_RAISE
251# define PLANCK_EZ_LED_RAISE 4
252#endif
253#ifndef PLANCK_EZ_LED_ADJUST
254# define PLANCK_EZ_LED_ADJUST 6
255#endif
256
224layer_state_t layer_state_set_kb(layer_state_t state) { 257layer_state_t layer_state_set_kb(layer_state_t state) {
225 planck_ez_left_led_off(); 258 planck_ez_left_led_off();
226 planck_ez_right_led_off(); 259 planck_ez_right_led_off();
227 state = layer_state_set_user(state); 260 state = layer_state_set_user(state);
228 uint8_t layer = biton32(state); 261 uint8_t layer = biton32(state);
229 switch (layer) { 262 switch (layer) {
230 case 3: 263 case PLANCK_EZ_LED_LOWER:
231 planck_ez_left_led_on(); 264 planck_ez_left_led_on();
232 break; 265 break;
233 case 4: 266 case PLANCK_EZ_LED_RAISE:
234 planck_ez_right_led_on(); 267 planck_ez_right_led_on();
235 break; 268 break;
236 case 6: 269 case PLANCK_EZ_LED_ADJUST:
237 planck_ez_right_led_on(); 270 planck_ez_right_led_on();
238 planck_ez_left_led_on(); 271 planck_ez_left_led_on();
239 break; 272 break;
@@ -242,7 +275,7 @@ layer_state_t layer_state_set_kb(layer_state_t state) {
242 } 275 }
243 return state; 276 return state;
244} 277}
245 278#endif
246 279
247bool process_record_kb(uint16_t keycode, keyrecord_t *record) { 280bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
248 switch (keycode) { 281 switch (keycode) {
@@ -258,6 +291,51 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
258 layer_state_set_kb(layer_state); 291 layer_state_set_kb(layer_state);
259 } 292 }
260 break; 293 break;
294#ifdef RGB_MATRIX_ENABLE
295 case TOGGLE_LAYER_COLOR:
296 if (record->event.pressed) {
297 keyboard_config.disable_layer_led ^= 1;
298 if (keyboard_config.disable_layer_led)
299 rgb_matrix_set_color_all(0, 0, 0);
300 eeconfig_update_kb(keyboard_config.raw);
301 }
302 break;
303 case RGB_TOG:
304 if (record->event.pressed) {
305 switch (rgb_matrix_get_flags()) {
306 case LED_FLAG_ALL: {
307 rgb_matrix_set_flags(LED_FLAG_NONE);
308 keyboard_config.rgb_matrix_enable = false;
309 rgb_matrix_set_color_all(0, 0, 0);
310 }
311 break;
312 default: {
313 rgb_matrix_set_flags(LED_FLAG_ALL);
314 keyboard_config.rgb_matrix_enable = true;
315 }
316 break;
317 }
318 eeconfig_update_kb(keyboard_config.raw);
319 }
320 return false;
321#endif
261 } 322 }
262 return true; 323 return process_record_user(keycode, record);
263} 324}
325#endif
326
327#ifdef AUDIO_ENABLE
328bool music_mask_kb(uint16_t keycode) {
329 switch (keycode) {
330 case QK_LAYER_TAP ... QK_ONE_SHOT_LAYER_MAX:
331 case QK_LAYER_TAP_TOGGLE ... QK_LAYER_MOD_MAX:
332 case QK_MOD_TAP ... QK_MOD_TAP_MAX:
333 case AU_ON ... MUV_DE:
334 case RESET:
335 case EEP_RST:
336 return false;
337 default:
338 return music_mask_user(keycode);
339 }
340}
341#endif
diff --git a/keyboards/planck/ez/ez.h b/keyboards/planck/ez/ez.h
index e2ddaf3ce..29bcc1b83 100644
--- a/keyboards/planck/ez/ez.h
+++ b/keyboards/planck/ez/ez.h
@@ -60,13 +60,16 @@ void planck_ez_left_led_level(uint8_t level);
60 60
61enum planck_ez_keycodes { 61enum planck_ez_keycodes {
62 LED_LEVEL = SAFE_RANGE, 62 LED_LEVEL = SAFE_RANGE,
63 TOGGLE_LAYER_COLOR,
63 EZ_SAFE_RANGE, 64 EZ_SAFE_RANGE,
64}; 65};
65 66
66typedef union { 67typedef union {
67 uint32_t raw; 68 uint32_t raw;
68 struct { 69 struct {
69 uint8_t led_level :3; 70 uint8_t led_level :3;
71 bool disable_layer_led :1;
72 bool rgb_matrix_enable :1;
70 }; 73 };
71} keyboard_config_t; 74} keyboard_config_t;
72 75
diff --git a/keyboards/planck/ez/readme.md b/keyboards/planck/ez/readme.md
index 9bd161abd..df8d1b46b 100644
--- a/keyboards/planck/ez/readme.md
+++ b/keyboards/planck/ez/readme.md
@@ -13,3 +13,44 @@ Make example for this keyboard (after setting up your build environment):
13 make planck/ez:default 13 make planck/ez:default
14 14
15See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). 15See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
16
17## Planck EZ Configuration (from Oryx)
18
19### Indicator LEDs
20
21The two front "teeth" LED indicators are PWM controlled. If you have `ORYX_CONFIGURATOR` defined in your keymap's `config.h`, you can use the `LED_LEVEL` to cycle through preset vales (0, 25%, 50%, 75%, 100%), and will be saved to EEPROM (persistent storage)
22
23Alternatively, you can set the brightness by calling the following functions:
24
25```c
26void planck_ez_right_led_level(uint8_t level);
27void planck_ez_left_led_level(uint8_t level);
28```
29
30These settings are not persistent, so you'd need to reset it every time the board starts.
31
32These are on a 0-255 scale
33
34#### Layer indication
35
36By default, the indicator lights are used for layer indication, expecting the specific layers used in the default keymap. However, this may not work for you. And if that is the case, you can add `#define PLANCK_EZ_USER_LEDS` to your `config.h` file.
37
38This will remove the default behavior for changing the LEDs based on layer, and allow you to control them manually.
39
40Alternatively, you can use the following defines in your keymap's `config.h` to control which layers are used, as long as you have `ORYX_CONFIGURATOR` defined in your keymap's `config.h` file, as well.
41
42```c
43#define PLANCK_EZ_LED_LOWER 3
44#define PLANCK_EZ_LED_RAISE 4
45#define PLANCK_EZ_LED_ADJUST 6
46```
47
48This will allow you to change the layers that are used, without having to add anything code to your `keymap.c`
49
50### RGB Matrix Features
51
52If you're using the Smart LED (layer indication) feature from the Oryx Configurator, you want to make sure that you enable these options by adding `#define ORYX_CONFIGURATOR` to your keymap's `config.h`.
53
54This changes the `RGB_TOG` keycode so that it will toggle the lights on and off, in a way that will allow the Smart LEDs to continue to work, even with the rest of the LEDs turned off.
55
56Additionally, a new keycode has been added to toggle the Smart LEDs. Use `TOGGLE_LAYER_COLOR`, if you aren't already.
diff --git a/keyboards/planck/keymaps/default/keymap.c b/keyboards/planck/keymaps/default/keymap.c
index 588ee646e..901977198 100644
--- a/keyboards/planck/keymaps/default/keymap.c
+++ b/keyboards/planck/keymaps/default/keymap.c
@@ -177,7 +177,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
177 float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND); 177 float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND);
178#endif 178#endif
179 179
180uint32_t layer_state_set_user(uint32_t state) { 180layer_state_t layer_state_set_user(layer_state_t state) {
181 return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST); 181 return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
182} 182}
183 183
diff --git a/keyboards/planck/keymaps/oryx/config.h b/keyboards/planck/keymaps/oryx/config.h
new file mode 100644
index 000000000..a9171bf53
--- /dev/null
+++ b/keyboards/planck/keymaps/oryx/config.h
@@ -0,0 +1,16 @@
1#pragma once
2
3#ifdef AUDIO_ENABLE
4#define STARTUP_SONG SONG(PLANCK_SOUND)
5#endif
6
7#define MIDI_BASIC
8
9#define ENCODER_RESOLUTION 4
10
11#define ORYX_CONFIGURATOR
12
13/*
14 Set any config.h overrides for your specific keymap here.
15 See config.h options at https://docs.qmk.fm/#/config_options?id=the-configh-file
16*/
diff --git a/keyboards/planck/keymaps/oryx/keymap.c b/keyboards/planck/keymaps/oryx/keymap.c
new file mode 100644
index 000000000..7892d1a5f
--- /dev/null
+++ b/keyboards/planck/keymaps/oryx/keymap.c
@@ -0,0 +1,372 @@
1#include QMK_KEYBOARD_H
2#include "muse.h"
3#include "eeprom.h"
4#include "keymap_german.h"
5#include "keymap_nordic.h"
6#include "keymap_french.h"
7#include "keymap_spanish.h"
8#include "keymap_hungarian.h"
9#include "keymap_swedish.h"
10//#include "keymap_br_abnt2.h"
11#include "keymap_canadian_multilingual.h"
12#include "keymap_german_ch.h"
13
14#define KC_MAC_UNDO LGUI(KC_Z)
15#define KC_MAC_CUT LGUI(KC_X)
16#define KC_MAC_COPY LGUI(KC_C)
17#define KC_MAC_PASTE LGUI(KC_V)
18#define KC_PC_UNDO LCTL(KC_Z)
19#define KC_PC_CUT LCTL(KC_X)
20#define KC_PC_COPY LCTL(KC_C)
21#define KC_PC_PASTE LCTL(KC_V)
22#define NO_TH ALGR(KC_T)
23#define NO_ETH ALGR(KC_D)
24
25enum planck_layers {
26 _QWERTY,
27 _COLEMAK,
28 _DVORAK,
29 _LOWER,
30 _RAISE,
31 _PLOVER,
32 _ADJUST
33};
34
35enum planck_keycodes {
36 QWERTY = EZ_SAFE_RANGE,
37 COLEMAK,
38 DVORAK,
39 PLOVER,
40 BACKLIT,
41 EXT_PLV,
42 RGB_SLD
43};
44
45#define LOWER MO(_LOWER)
46#define RAISE MO(_RAISE)
47
48
49const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
50
51/* Qwerty
52 * ,-----------------------------------------------------------------------------------.
53 * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp |
54 * |------+------+------+------+------+------+------+------+------+------+------+------|
55 * | Esc | A | S | D | F | G | H | J | K | L | ; | " |
56 * |------+------+------+------+------+------+------+------+------+------+------+------|
57 * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
58 * |------+------+------+------+------+------+------+------+------+------+------+------|
59 * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
60 * `-----------------------------------------------------------------------------------'
61 */
62[_QWERTY] = LAYOUT_planck_grid(
63 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
64 KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
65 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT ,
66 BACKLIT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
67),
68
69/* Colemak
70 * ,-----------------------------------------------------------------------------------.
71 * | Tab | Q | W | F | P | G | J | L | U | Y | ; | Bksp |
72 * |------+------+------+------+------+------+------+------+------+------+------+------|
73 * | Esc | A | R | S | T | D | H | N | E | I | O | " |
74 * |------+------+------+------+------+------+------+------+------+------+------+------|
75 * | Shift| Z | X | C | V | B | K | M | , | . | / |Enter |
76 * |------+------+------+------+------+------+------+------+------+------+------+------|
77 * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
78 * `-----------------------------------------------------------------------------------'
79 */
80[_COLEMAK] = LAYOUT_planck_grid(
81 KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC,
82 KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT,
83 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT ,
84 BACKLIT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
85),
86
87/* Dvorak
88 * ,-----------------------------------------------------------------------------------.
89 * | Tab | " | , | . | P | Y | F | G | C | R | L | Bksp |
90 * |------+------+------+------+------+------+------+------+------+------+------+------|
91 * | Esc | A | O | E | U | I | D | H | T | N | S | / |
92 * |------+------+------+------+------+------+------+------+------+------+------+------|
93 * | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter |
94 * |------+------+------+------+------+------+------+------+------+------+------+------|
95 * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right |
96 * `-----------------------------------------------------------------------------------'
97 */
98[_DVORAK] = LAYOUT_planck_grid(
99 KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC,
100 KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH,
101 KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT ,
102 BACKLIT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
103),
104
105/* Lower
106 * ,-----------------------------------------------------------------------------------.
107 * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
108 * |------+------+------+------+------+------+------+------+------+------+------+------|
109 * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | |
110 * |------+------+------+------+------+------+------+------+------+------+------+------|
111 * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | Home | End | |
112 * |------+------+------+------+------+------+------+------+------+------+------+------|
113 * | | | | | | | | Next | Vol- | Vol+ | Play |
114 * `-----------------------------------------------------------------------------------'
115 */
116[_LOWER] = LAYOUT_planck_grid(
117 KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC,
118 KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE,
119 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, S(KC_NUHS), S(KC_NUBS), KC_HOME, KC_END, _______,
120 _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY
121),
122
123/* Raise
124 * ,-----------------------------------------------------------------------------------.
125 * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
126 * |------+------+------+------+------+------+------+------+------+------+------+------|
127 * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ |
128 * |------+------+------+------+------+------+------+------+------+------+------+------|
129 * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / |Pg Up |Pg Dn | |
130 * |------+------+------+------+------+------+------+------+------+------+------+------|
131 * | | | | | | | | Next | Vol- | Vol+ | Play |
132 * `-----------------------------------------------------------------------------------'
133 */
134[_RAISE] = LAYOUT_planck_grid(
135 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
136 KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS,
137 _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, KC_PGUP, KC_PGDN, _______,
138 _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY
139),
140
141/* Plover layer (http://opensteno.org)
142 * ,-----------------------------------------------------------------------------------.
143 * | # | # | # | # | # | # | # | # | # | # | # | # |
144 * |------+------+------+------+------+------+------+------+------+------+------+------|
145 * | | S | T | P | H | * | * | F | P | L | T | D |
146 * |------+------+------+------+------+------+------+------+------+------+------+------|
147 * | | S | K | W | R | * | * | R | B | G | S | Z |
148 * |------+------+------+------+------+------+------+------+------+------+------+------|
149 * | Exit | | | A | O | | E | U | | | |
150 * `-----------------------------------------------------------------------------------'
151 */
152[_PLOVER] = LAYOUT_planck_grid(
153 KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1 ,
154 XXXXXXX, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC,
155 XXXXXXX, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
156 EXT_PLV, XXXXXXX, XXXXXXX, KC_C, KC_V, XXXXXXX, XXXXXXX, KC_N, KC_M, XXXXXXX, XXXXXXX, XXXXXXX
157),
158
159/* Adjust (Lower + Raise)
160 * v------------------------RGB CONTROL--------------------v
161 * ,-----------------------------------------------------------------------------------
162 * | | Reset|Debug | RGB |RGBMOD| HUE+ | HUE- | SAT+ | SAT- |BRGTH+|BRGTH-| Del |
163 * |------+------+------+------+------+------+------+------+------+------+------+------|
164 * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak|Plover| |
165 * |------+------+------+------+------+------+------+------+------+------+------+------|
166 * | |Voice-|Voice+|Mus on|Musoff|MIDIon|MIDIof| | | | | |
167 * |------+------+------+------+------+------+------+------+------+------+------+------|
168 * | | | | | | | | | | | |
169 * `-----------------------------------------------------------------------------------'
170 */
171[_ADJUST] = LAYOUT_planck_grid(
172 _______, RESET, DEBUG, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, KC_DEL ,
173 _______, _______, MU_MOD, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______,
174 _______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, TERM_ON, TERM_OFF, TOGGLE_LAYER_COLOR, LED_LEVEL, _______,
175 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
176)
177
178};
179
180
181#ifdef AUDIO_ENABLE
182 float plover_song[][2] = SONG(PLOVER_SOUND);
183 float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND);
184#endif
185
186layer_state_t layer_state_set_user(layer_state_t state) {
187 return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
188}
189
190const uint8_t PROGMEM ledmap[][DRIVER_LED_TOTAL][3] = {
191 [0] = { {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255}, {130,255,255} },
192
193 [1] = { {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {146,224,255}, {146,224,255}, {146,224,255}, {146,224,255}, {146,224,255}, {146,224,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {146,224,255}, {146,224,255}, {146,224,255}, {146,224,255}, {146,224,255}, {146,224,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {42,255,255}, {32,255,234}, {32,255,234}, {32,255,234}, {32,255,234} },
194
195 [2] = { {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {169,120,255}, {169,120,255}, {169,120,255}, {169,120,255}, {169,120,255}, {169,120,255}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {169,120,255}, {169,120,255}, {169,120,255}, {169,120,255}, {169,120,255}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246}, {89,255,246} },
196
197 [3] = { {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {249,228,255}, {249,228,255}, {249,228,255}, {216,255,255}, {216,255,255}, {105,255,255}, {105,255,255}, {105,255,255}, {216,255,255}, {14,255,255}, {216,255,255}, {216,255,255}, {249,228,255}, {249,228,255}, {249,228,255}, {216,255,255}, {216,255,255}, {105,255,255}, {105,255,255}, {105,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255}, {216,255,255} },
198
199};
200
201void set_layer_color(int layer) {
202 for (int i = 0; i < DRIVER_LED_TOTAL; i++) {
203 HSV hsv = {
204 .h = pgm_read_byte(&ledmap[layer][i][0]),
205 .s = pgm_read_byte(&ledmap[layer][i][1]),
206 .v = pgm_read_byte(&ledmap[layer][i][2]),
207 };
208 if (!hsv.h && !hsv.s && !hsv.v) {
209 rgb_matrix_set_color( i, 0, 0, 0 );
210 } else {
211 RGB rgb = hsv_to_rgb( hsv );
212 float f = (float)rgb_matrix_config.hsv.v / UINT8_MAX;
213 rgb_matrix_set_color( i, f * rgb.r, f * rgb.g, f * rgb.b );
214 }
215 }
216}
217
218void rgb_matrix_indicators_user(void) {
219 if (g_suspend_state || keyboard_config.disable_layer_led) { return; }
220 switch (biton32(layer_state)) {
221 case 0:
222 set_layer_color(0);
223 break;
224 case 3:
225 set_layer_color(1);
226 break;
227 case 4:
228 set_layer_color(2);
229 break;
230 case 6:
231 set_layer_color(3);
232 break;
233 default:
234 if (rgb_matrix_get_flags() == LED_FLAG_NONE)
235 rgb_matrix_set_color_all(0, 0, 0);
236 break;
237 }
238}
239
240
241bool process_record_user(uint16_t keycode, keyrecord_t *record) {
242 switch (keycode) {
243 case RGB_SLD:
244 if (record->event.pressed) {
245 rgblight_mode(1);
246 }
247 return false;
248 case QWERTY:
249 if (record->event.pressed) {
250 print("mode just switched to qwerty and this is a huge string\n");
251 set_single_persistent_default_layer(_QWERTY);
252 }
253 return false;
254 break;
255 case COLEMAK:
256 if (record->event.pressed) {
257 set_single_persistent_default_layer(_COLEMAK);
258 }
259 return false;
260 break;
261 case DVORAK:
262 if (record->event.pressed) {
263 set_single_persistent_default_layer(_DVORAK);
264 }
265 return false;
266 break;
267 case BACKLIT:
268 if (record->event.pressed) {
269 register_code(KC_RSFT);
270 #ifdef BACKLIGHT_ENABLE
271 backlight_step();
272 #endif
273 #ifdef KEYBOARD_planck_rev5
274 PORTE &= ~(1<<6);
275 #endif
276 } else {
277 unregister_code(KC_RSFT);
278 #ifdef KEYBOARD_planck_rev5
279 PORTE |= (1<<6);
280 #endif
281 }
282 return false;
283 break;
284 case PLOVER:
285 if (record->event.pressed) {
286 #ifdef AUDIO_ENABLE
287 stop_all_notes();
288 PLAY_SONG(plover_song);
289 #endif
290 layer_off(_RAISE);
291 layer_off(_LOWER);
292 layer_off(_ADJUST);
293 layer_on(_PLOVER);
294 if (!eeconfig_is_enabled()) {
295 eeconfig_init();
296 }
297 keymap_config.raw = eeconfig_read_keymap();
298 keymap_config.nkro = 1;
299 eeconfig_update_keymap(keymap_config.raw);
300 }
301 return false;
302 break;
303 case EXT_PLV:
304 if (record->event.pressed) {
305 #ifdef AUDIO_ENABLE
306 PLAY_SONG(plover_gb_song);
307 #endif
308 layer_off(_PLOVER);
309 }
310 return false;
311 break;
312 }
313 return true;
314}
315
316bool muse_mode = false;
317uint8_t last_muse_note = 0;
318uint16_t muse_counter = 0;
319uint8_t muse_offset = 70;
320uint16_t muse_tempo = 50;
321
322void encoder_update(bool clockwise) {
323 if (muse_mode) {
324 if (IS_LAYER_ON(_RAISE)) {
325 if (clockwise) {
326 muse_offset++;
327 } else {
328 muse_offset--;
329 }
330 } else {
331 if (clockwise) {
332 muse_tempo+=1;
333 } else {
334 muse_tempo-=1;
335 }
336 }
337 } else {
338 if (clockwise) {
339 #ifdef MOUSEKEY_ENABLE
340 register_code(KC_MS_WH_DOWN);
341 unregister_code(KC_MS_WH_DOWN);
342 #else
343 register_code(KC_PGDN);
344 unregister_code(KC_PGDN);
345 #endif
346 } else {
347 #ifdef MOUSEKEY_ENABLE
348 register_code(KC_MS_WH_UP);
349 unregister_code(KC_MS_WH_UP);
350 #else
351 register_code(KC_PGUP);
352 unregister_code(KC_PGUP);
353 #endif
354 }
355 }
356}
357
358void matrix_scan_user(void) {
359#ifdef AUDIO_ENABLE
360 if (muse_mode) {
361 if (muse_counter == 0) {
362 uint8_t muse_note = muse_offset + SCALE[muse_clock_pulse()];
363 if (muse_note != last_muse_note) {
364 stop_note(compute_freq_for_midi_note(last_muse_note));
365 play_note(compute_freq_for_midi_note(muse_note), 0xF);
366 last_muse_note = muse_note;
367 }
368 }
369 muse_counter = (muse_counter + 1) % muse_tempo;
370 }
371#endif
372}
diff --git a/keyboards/planck/keymaps/oryx/rules.mk b/keyboards/planck/keymaps/oryx/rules.mk
new file mode 100644
index 000000000..fb44d6b95
--- /dev/null
+++ b/keyboards/planck/keymaps/oryx/rules.mk
@@ -0,0 +1,6 @@
1SRC += muse.c
2# Set any rules.mk overrides for your specific keymap here.
3# See rules at https://docs.qmk.fm/#/config_options?id=the-rulesmk-file
4LINK_TIME_OPTIMIZATION_ENABLE = yes
5COMMAND_ENABLE = no
6MOUSEKEY_ENABLE = no