summaryrefslogtreecommitdiff
path: root/keyboards/ergodox_ez/ergodox_ez.c
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 /keyboards/ergodox_ez/ergodox_ez.c
parent1c5b0cbbeb049b1ce3fb2da6a81fbf83dd9a3ea7 (diff)
[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
Diffstat (limited to 'keyboards/ergodox_ez/ergodox_ez.c')
-rw-r--r--keyboards/ergodox_ez/ergodox_ez.c74
1 files changed, 74 insertions, 0 deletions
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();
+}