summaryrefslogtreecommitdiff
path: root/keyboards/ergodox_ez/ergodox_ez.c
diff options
context:
space:
mode:
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();
+}