diff options
Diffstat (limited to 'keyboards/planck/ez')
-rw-r--r-- | keyboards/planck/ez/config.h | 1 | ||||
-rw-r--r-- | keyboards/planck/ez/ez.c | 94 | ||||
-rw-r--r-- | keyboards/planck/ez/ez.h | 5 | ||||
-rw-r--r-- | keyboards/planck/ez/readme.md | 41 |
4 files changed, 132 insertions, 9 deletions
diff --git a/keyboards/planck/ez/config.h b/keyboards/planck/ez/config.h index 61d9981c18..0cb428dd85 100644 --- a/keyboards/planck/ez/config.h +++ b/keyboards/planck/ez/config.h @@ -139,6 +139,7 @@ #define RGB_MATRIX_KEYPRESSES #define RGB_MATRIX_FRAMEBUFFER_EFFECTS +#define RGB_DISABLE_WHEN_USB_SUSPENDED true #define RGB_MATRIX_LED_PROCESS_LIMIT 5 #define RGB_MATRIX_LED_FLUSH_LIMIT 26 diff --git a/keyboards/planck/ez/ez.c b/keyboards/planck/ez/ez.c index 8734042a42..8369ce50c1 100644 --- a/keyboards/planck/ez/ez.c +++ b/keyboards/planck/ez/ez.c @@ -16,8 +16,8 @@ #include "ez.h" #include "ch.h" #include "hal.h" - keyboard_config_t keyboard_config; +keyboard_config_t keyboard_config; #ifdef RGB_MATRIX_ENABLE const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { @@ -106,6 +106,7 @@ led_config_t g_led_config = { { } }; void suspend_power_down_kb(void) { + rgb_matrix_set_color_all(0, 0, 0); rgb_matrix_set_suspend_state(true); suspend_power_down_user(); } @@ -207,33 +208,65 @@ void led_initialize_hardware(void) { } void keyboard_pre_init_kb(void) { + if (!eeconfig_is_enabled()) { + eeconfig_init(); + } // read kb settings from eeprom keyboard_config.raw = eeconfig_read_kb(); - - // initialize settings for front LEDs +#if defined(RGB_MATRIX_ENABLE) && defined(ORYX_CONFIGURATOR) + if (keyboard_config.rgb_matrix_enable) { + rgb_matrix_set_flags(LED_FLAG_ALL); + } else { + rgb_matrix_set_flags(LED_FLAG_NONE); + } +#endif led_initialize_hardware(); + keyboard_pre_init_user(); +} + +#if defined(RGB_MATRIX_ENABLE) && defined(ORYX_CONFIGURATOR) +void keyboard_post_init_kb(void) { + rgb_matrix_enable_noeeprom(); + keyboard_post_init_user(); } +#endif void eeconfig_init_kb(void) { // EEPROM is getting reset! keyboard_config.raw = 0; + keyboard_config.rgb_matrix_enable = true; keyboard_config.led_level = 4; eeconfig_update_kb(keyboard_config.raw); eeconfig_init_user(); } + +#ifdef ORYX_CONFIGURATOR + +#ifndef PLANCK_EZ_USER_LEDS + +#ifndef PLANCK_EZ_LED_LOWER +# define PLANCK_EZ_LED_LOWER 3 +#endif +#ifndef PLANCK_EZ_LED_RAISE +# define PLANCK_EZ_LED_RAISE 4 +#endif +#ifndef PLANCK_EZ_LED_ADJUST +# define PLANCK_EZ_LED_ADJUST 6 +#endif + layer_state_t layer_state_set_kb(layer_state_t state) { planck_ez_left_led_off(); planck_ez_right_led_off(); state = layer_state_set_user(state); uint8_t layer = biton32(state); switch (layer) { - case 3: + case PLANCK_EZ_LED_LOWER: planck_ez_left_led_on(); break; - case 4: + case PLANCK_EZ_LED_RAISE: planck_ez_right_led_on(); break; - case 6: + case PLANCK_EZ_LED_ADJUST: planck_ez_right_led_on(); planck_ez_left_led_on(); break; @@ -242,7 +275,7 @@ layer_state_t layer_state_set_kb(layer_state_t state) { } return state; } - +#endif bool process_record_kb(uint16_t keycode, keyrecord_t *record) { switch (keycode) { @@ -258,6 +291,51 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { layer_state_set_kb(layer_state); } break; +#ifdef RGB_MATRIX_ENABLE + case TOGGLE_LAYER_COLOR: + if (record->event.pressed) { + keyboard_config.disable_layer_led ^= 1; + if (keyboard_config.disable_layer_led) + rgb_matrix_set_color_all(0, 0, 0); + eeconfig_update_kb(keyboard_config.raw); + } + break; + case RGB_TOG: + if (record->event.pressed) { + switch (rgb_matrix_get_flags()) { + case LED_FLAG_ALL: { + rgb_matrix_set_flags(LED_FLAG_NONE); + keyboard_config.rgb_matrix_enable = false; + rgb_matrix_set_color_all(0, 0, 0); + } + break; + default: { + rgb_matrix_set_flags(LED_FLAG_ALL); + keyboard_config.rgb_matrix_enable = true; + } + break; + } + eeconfig_update_kb(keyboard_config.raw); + } + return false; +#endif } - return true; + return process_record_user(keycode, record); } +#endif + +#ifdef AUDIO_ENABLE +bool music_mask_kb(uint16_t keycode) { + switch (keycode) { + case QK_LAYER_TAP ... QK_ONE_SHOT_LAYER_MAX: + case QK_LAYER_TAP_TOGGLE ... QK_LAYER_MOD_MAX: + case QK_MOD_TAP ... QK_MOD_TAP_MAX: + case AU_ON ... MUV_DE: + case RESET: + case EEP_RST: + return false; + default: + return music_mask_user(keycode); + } +} +#endif diff --git a/keyboards/planck/ez/ez.h b/keyboards/planck/ez/ez.h index e2ddaf3cec..29bcc1b83c 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); enum planck_ez_keycodes { LED_LEVEL = SAFE_RANGE, + TOGGLE_LAYER_COLOR, EZ_SAFE_RANGE, }; typedef union { uint32_t raw; struct { - uint8_t led_level :3; + uint8_t led_level :3; + bool disable_layer_led :1; + bool rgb_matrix_enable :1; }; } keyboard_config_t; diff --git a/keyboards/planck/ez/readme.md b/keyboards/planck/ez/readme.md index 9bd161abdf..df8d1b46bb 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): make planck/ez:default See 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). + +## Planck EZ Configuration (from Oryx) + +### Indicator LEDs + +The 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) + +Alternatively, you can set the brightness by calling the following functions: + +```c +void planck_ez_right_led_level(uint8_t level); +void planck_ez_left_led_level(uint8_t level); +``` + +These settings are not persistent, so you'd need to reset it every time the board starts. + +These are on a 0-255 scale + +#### Layer indication + +By 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. + +This will remove the default behavior for changing the LEDs based on layer, and allow you to control them manually. + +Alternatively, 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. + +```c +#define PLANCK_EZ_LED_LOWER 3 +#define PLANCK_EZ_LED_RAISE 4 +#define PLANCK_EZ_LED_ADJUST 6 +``` + +This will allow you to change the layers that are used, without having to add anything code to your `keymap.c` + +### RGB Matrix Features + +If 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`. + +This 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. + +Additionally, a new keycode has been added to toggle the Smart LEDs. Use `TOGGLE_LAYER_COLOR`, if you aren't already. |