diff options
Diffstat (limited to 'keyboards/planck/ez/ez.c')
-rw-r--r-- | keyboards/planck/ez/ez.c | 119 |
1 files changed, 80 insertions, 39 deletions
diff --git a/keyboards/planck/ez/ez.c b/keyboards/planck/ez/ez.c index 25dfe9adfb..93a17be293 100644 --- a/keyboards/planck/ez/ez.c +++ b/keyboards/planck/ez/ez.c @@ -106,6 +106,10 @@ led_config_t g_led_config = { { 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1 } }; +void keyboard_post_init_kb(void) { + rgb_matrix_enable_noeeprom(); + keyboard_post_init_user(); +} #endif /* Left B9 Right B8 */ @@ -204,60 +208,30 @@ void keyboard_pre_init_kb(void) { } // read kb settings from eeprom keyboard_config.raw = eeconfig_read_kb(); -#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 = get_highest_layer(state); switch (layer) { - case PLANCK_EZ_LED_LOWER: + case 1: planck_ez_left_led_on(); break; - case PLANCK_EZ_LED_RAISE: + case 2: planck_ez_right_led_on(); break; - case PLANCK_EZ_LED_ADJUST: + case 3: planck_ez_right_led_on(); planck_ez_left_led_on(); break; @@ -266,7 +240,6 @@ 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) { @@ -296,24 +269,21 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { 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 + #ifdef AUDIO_ENABLE bool music_mask_kb(uint16_t keycode) { @@ -331,6 +301,77 @@ bool music_mask_kb(uint16_t keycode) { } #endif +#ifdef ORYX_ENABLE +static uint16_t loops = 0; +static bool is_on = false; +#endif + +#ifdef DYNAMIC_MACRO_ENABLE +static bool is_dynamic_recording = false; +static uint16_t dynamic_loop_timer; + +void dynamic_macro_record_start_user(void) { + is_dynamic_recording = true; + dynamic_loop_timer = timer_read(); + planck_ez_left_led_on(); +} + +void dynamic_macro_record_end_user(int8_t direction) { + is_dynamic_recording = false; + layer_state_set_kb(layer_state); +} +#endif + +void matrix_scan_kb(void) { +#ifdef ORYX_ENABLE + if(rawhid_state.pairing == true) { + if(loops == 0) { + //lights off + } + if(loops % PAIRING_BLINK_STEPS == 0) { + if(is_on) { + planck_ez_left_led_on(); + planck_ez_right_led_off(); + } + else { + planck_ez_left_led_off(); + planck_ez_right_led_on(); + } + is_on ^= 1; + } + if(loops > PAIRING_BLINK_END * 2) { + rawhid_state.pairing = false; + loops = 0; + planck_ez_left_led_off(); + planck_ez_right_led_off(); + } + loops++; + } + else if(loops > 0) { + loops = 0; + planck_ez_left_led_off(); + planck_ez_right_led_off(); + } +#endif +#ifdef DYNAMIC_MACRO_ENABLE + if (is_dynamic_recording) { + if (timer_elapsed(dynamic_loop_timer) > 1) + { + static uint8_t counter; + counter++; + if (counter > 100) { + planck_ez_left_led_on(); + } else { + planck_ez_left_led_off(); + + } + dynamic_loop_timer = timer_read(); + } + } +#endif + matrix_scan_user(); +} + #ifdef SWAP_HANDS_ENABLE __attribute__ ((weak)) const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = { @@ -338,7 +379,7 @@ const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = { {{5, 5}, {4, 5}, {3, 5}, {2, 5}, {1, 5}, {0, 5}}, {{5, 6}, {4, 6}, {3, 6}, {2, 6}, {1, 6}, {0, 6}}, {{5, 3}, {4, 3}, {3, 3}, {2, 3}, {1, 3}, {0, 3}}, - + {{5, 0}, {4, 0}, {3, 0}, {2, 0}, {1, 0}, {0, 0}}, {{5, 1}, {4, 1}, {3, 1}, {2, 1}, {1, 1}, {0, 1}}, {{5, 2}, {4, 2}, {3, 2}, {2, 2}, {1, 2}, {0, 2}}, |