From 94efa18c28c8c0e08526c9665a8f0d6a4e7d3e96 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Wed, 21 Aug 2019 17:19:07 -0700 Subject: [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 --- keyboards/ergodox_ez/config.h | 4 ++ keyboards/ergodox_ez/ergodox_ez.c | 74 +++++++++++++++++++++++++++ keyboards/ergodox_ez/ergodox_ez.h | 19 +++++++ keyboards/ergodox_ez/keymaps/default/keymap.c | 6 ++- 4 files changed, 102 insertions(+), 1 deletion(-) (limited to 'keyboards/ergodox_ez') diff --git a/keyboards/ergodox_ez/config.h b/keyboards/ergodox_ez/config.h index 45ca06a5d2..c35fe73941 100644 --- a/keyboards/ergodox_ez/config.h +++ b/keyboards/ergodox_ez/config.h @@ -85,6 +85,8 @@ along with this program. If not, see . #define RGBW 1 +#define RGBLIGHT_SLEEP + /* * The debounce filtering reports a key/switch change directly, * without any extra delay. After that the debounce logic will filter @@ -112,6 +114,8 @@ along with this program. If not, see . #define RGB_MATRIX_LED_PROCESS_LIMIT 5 #define RGB_MATRIX_LED_FLUSH_LIMIT 26 +#define RGB_DISABLE_WHEN_USB_SUSPENDED true + // #define RGBLIGHT_COLOR_LAYER_0 0x00, 0x00, 0xFF /* #define RGBLIGHT_COLOR_LAYER_1 0x00, 0x00, 0xFF */ /* #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 947a173e36..d313f7d5d9 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); extern inline void ergodox_led_all_set(uint8_t n); +keyboard_config_t keyboard_config; + bool i2c_initialized = 0; i2c_status_t mcp23018_status = 0x20; @@ -43,6 +45,16 @@ void matrix_init_kb(void) { PORTD |= (1<<5 | 1<<4); PORTE |= (1<<6); + keyboard_config.raw = eeconfig_read_kb(); + ergodox_led_all_set((uint8_t)keyboard_config.led_level * 255 / 4 ); +#ifdef RGB_MATRIX_ENABLE + if (keyboard_config.rgb_matrix_enable) { + rgb_matrix_set_flags(LED_FLAG_ALL); + } else { + rgb_matrix_set_flags(LED_FLAG_NONE); + } +#endif + ergodox_blink_all_leds(); matrix_init_user(); @@ -305,6 +317,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(); } @@ -314,4 +327,65 @@ void suspend_power_down_kb(void) { suspend_wakeup_init_user(); } +#ifdef ORYX_CONFIGURATOR +void keyboard_post_init_kb(void) { + rgb_matrix_enable_noeeprom(); + keyboard_post_init_user(); +} #endif +#endif + +#ifdef ORYX_CONFIGURATOR +bool process_record_kb(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case LED_LEVEL: + if (record->event.pressed) { + keyboard_config.led_level++; + if (keyboard_config.led_level > 4) { + keyboard_config.led_level = 0; + } + ergodox_led_all_set((uint8_t)keyboard_config.led_level * 255 / 4 ); + eeconfig_update_kb(keyboard_config.raw); + 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 process_record_user(keycode, record); +} +#endif + +void eeconfig_init_kb(void) { // EEPROM is getting reset! + keyboard_config.raw = 0; + keyboard_config.led_level = 4; + keyboard_config.rgb_matrix_enable = true; + eeconfig_update_kb(keyboard_config.raw); + eeconfig_init_user(); +} diff --git a/keyboards/ergodox_ez/ergodox_ez.h b/keyboards/ergodox_ez/ergodox_ez.h index 383702b957..7ff62d38a1 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) ergodox_right_led_3_set(n); } +#ifdef ORYX_CONFIGURATOR +enum ergodox_ez_keycodes { + LED_LEVEL = SAFE_RANGE, + TOGGLE_LAYER_COLOR, + EZ_SAFE_RANGE, +}; +#endif + +typedef union { + uint32_t raw; + struct { + uint8_t led_level :3; + bool disable_layer_led :1; + bool rgb_matrix_enable :1; + }; +} keyboard_config_t; + +extern keyboard_config_t keyboard_config; + /* * LEFT HAND: LINES 115-122 * RIGHT HAND: LINES 124-131 diff --git a/keyboards/ergodox_ez/keymaps/default/keymap.c b/keyboards/ergodox_ez/keymaps/default/keymap.c index 40d0a1eaf0..fb3d3896bf 100644 --- a/keyboards/ergodox_ez/keymaps/default/keymap.c +++ b/keyboards/ergodox_ez/keymaps/default/keymap.c @@ -6,7 +6,11 @@ #define MDIA 2 // media keys enum custom_keycodes { +#ifdef ORYX_CONFIGURATOR + EPRM = EZ_SAFE_RANGE, +#else EPRM = SAFE_RANGE, +#endif VRSN, RGB_SLD }; @@ -164,7 +168,7 @@ void matrix_init_user(void) { }; // Runs whenever there is a layer state change. -uint32_t layer_state_set_user(uint32_t state) { +layer_state_t layer_state_set_user(layer_state_t state) { ergodox_board_led_off(); ergodox_right_led_1_off(); ergodox_right_led_2_off(); -- cgit v1.2.3