summaryrefslogtreecommitdiff
path: root/keyboards/planck/ez/ez.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/planck/ez/ez.c')
-rw-r--r--keyboards/planck/ez/ez.c108
1 files changed, 80 insertions, 28 deletions
diff --git a/keyboards/planck/ez/ez.c b/keyboards/planck/ez/ez.c
index 8c498a5520..87ee3f7238 100644
--- a/keyboards/planck/ez/ez.c
+++ b/keyboards/planck/ez/ez.c
@@ -114,6 +114,10 @@ void suspend_power_down_kb(void) {
rgb_matrix_set_suspend_state(false);
suspend_wakeup_init_user();
}
+void keyboard_post_init_kb(void) {
+ rgb_matrix_enable_noeeprom();
+ keyboard_post_init_user();
+}
#endif
/* Left B9 Right B8 */
@@ -212,7 +216,7 @@ 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)
+#ifdef RGB_MATRIX_ENABLE
if (keyboard_config.rgb_matrix_enable) {
rgb_matrix_set_flags(LED_FLAG_ALL);
} else {
@@ -223,13 +227,6 @@ void keyboard_pre_init_kb(void) {
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;
@@ -238,34 +235,19 @@ void eeconfig_init_kb(void) { // EEPROM is getting reset!
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 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;
@@ -274,7 +256,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) {
@@ -321,7 +302,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
}
return process_record_user(keycode, record);
}
-#endif
+
#ifdef AUDIO_ENABLE
bool music_mask_kb(uint16_t keycode) {
@@ -338,3 +319,74 @@ 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(webusb_state.pairing == true) {
+ if(loops == 0) {
+ //lights off
+ }
+ if(loops % WEBUSB_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 > WEBUSB_BLINK_END * 2) {
+ webusb_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();
+}