فهرست منبع

[Keymap] Add indicator light bootup fanfare (#10158)

* Add indicator light bootup fanfare

* move fanfare code to new file

* fanfare code in new file and remove unused boards

* new startup fanfare code

* add lock/unlock indicator animation

* input key presses before changing lights

* remove old code
stanrc85 4 سال پیش
والد
کامیت
6c3e404839
4فایلهای تغییر یافته به همراه80 افزوده شده و 55 حذف شده
  1. 0 38
      users/stanrc85/rgblight_layers.c
  2. 2 16
      users/stanrc85/rules.mk
  3. 35 1
      users/stanrc85/stanrc85.c
  4. 43 0
      users/stanrc85/startup_fanfare.c

+ 0 - 38
users/stanrc85/rgblight_layers.c

@@ -3,44 +3,7 @@
 static uint8_t middle = 0;
 static uint8_t bottom = 0;
 
-const rgblight_segment_t PROGMEM my_capslock_layer[] = RGBLIGHT_LAYER_SEGMENTS(
-    {3, 2, HSV_RED},
-    {10, 2, HSV_RED}
-);
-
-const rgblight_segment_t PROGMEM my_layer1_layer[] = RGBLIGHT_LAYER_SEGMENTS(
-    {3, 1, HSV_GREEN},
-    {11, 1, HSV_GREEN}
-);   
-
-const rgblight_segment_t PROGMEM my_layer2_layer[] = RGBLIGHT_LAYER_SEGMENTS(
-    {3, 1, HSV_BLUE},
-    {11, 1, HSV_BLUE} 
-);
-
-const rgblight_segment_t PROGMEM my_layer3_layer[] = RGBLIGHT_LAYER_SEGMENTS(
-    {3, 1, HSV_WHITE},
-    {11, 1, HSV_WHITE}
-);
-
-// Now define the array of layers. Later layers take precedence
-const rgblight_segment_t* const PROGMEM my_rgb_layers[] = RGBLIGHT_LAYERS_LIST(
-    my_capslock_layer,
-    my_layer1_layer,
-    my_layer2_layer,
-    my_layer3_layer
-);
-
-void keyboard_post_init_user(void) {
-    // Enable the LED layers
-    rgblight_layers = my_rgb_layers;
-}
-
 layer_state_t layer_state_set_user(layer_state_t state) {
-    // Both layers will light up if both kb layers are active
-    rgblight_set_layer_state(1, layer_state_cmp(state, 1));
-    rgblight_set_layer_state(2, layer_state_cmp(state, 2));
-    rgblight_set_layer_state(3, layer_state_cmp(state, 3));
     middle = bottom = 0;
     switch (get_highest_layer(state)) {
     case _FN1_60:
@@ -60,7 +23,6 @@ layer_state_t layer_state_set_user(layer_state_t state) {
 }
 
 bool led_update_user(led_t led_state) {
-    //rgblight_set_layer_state(0, led_state.caps_lock);
     writePin(INDICATOR_PIN_0, !led_state.caps_lock);
     writePin(INDICATOR_PIN_1, !middle);
     writePin(INDICATOR_PIN_2, !bottom);

+ 2 - 16
users/stanrc85/rules.mk

@@ -10,24 +10,10 @@ NKRO_ENABLE = no
 
 SRC += stanrc85.c
 
-ifeq ($(strip $(KEYBOARD)), 1upkeyboards/1up60hse)
-  SRC += layer_rgb.c
-  VIA_ENABLE = yes
-  LTO_ENABLE = yes
-endif
-ifeq ($(strip $(KEYBOARD)), dz60)
-  SRC += layer_rgb.c
-  VIA_ENABLE = yes
-  LTO_ENABLE = yes
-endif
-ifeq ($(strip $(KEYBOARD)), projectkb/alice/rev1)
-  SRC += rgblight_layers.c
-  VIA_ENABLE = yes
-  LTO_ENABLE = no
-  VELOCIKEY_ENABLE=yes
-endif
 ifeq ($(strip $(KEYBOARD)), projectkb/alice/rev2)
   SRC += rgblight_layers.c
+  SRC += startup_fanfare.c
+  OPT_DEFS += -DHAS_INDICATORS
   VIA_ENABLE = yes
   LTO_ENABLE = no
   VELOCIKEY_ENABLE=yes

+ 35 - 1
users/stanrc85/stanrc85.c

@@ -44,8 +44,42 @@ void ctl_copy_reset (qk_tap_dance_state_t *state, void *user_data) {
   }
 }
 
+#if defined(HAS_INDICATORS)
+  static uint8_t led_user = 0;
+#endif
+
+void lock_unlock (qk_tap_dance_state_t *state, void *user_data) {
+  td_state = cur_dance(state);
+  switch (td_state) {
+    case SINGLE_TAP: // Ctl + Alt + Del to unlock workstation
+    tap_code16(KC_CAD);
+    #if defined(HAS_INDICATORS)
+      led_user = 0;
+      writePin(INDICATOR_PIN_0, !led_user);
+      wait_ms(200);
+      writePin(INDICATOR_PIN_1, !led_user);
+      wait_ms(200);
+      writePin(INDICATOR_PIN_2, !led_user);
+    #endif      
+      break;
+    case SINGLE_HOLD:
+      break;
+    case DOUBLE_TAP: //Lock workstation
+    tap_code16(KC_LOCK);
+    #if defined(HAS_INDICATORS)
+      led_user = 1;
+      writePin(INDICATOR_PIN_2, !led_user);
+      wait_ms(200);
+      writePin(INDICATOR_PIN_1, !led_user);
+      wait_ms(200);
+      writePin(INDICATOR_PIN_0, !led_user);
+    #endif    
+      break;
+  }
+}
+
 qk_tap_dance_action_t tap_dance_actions[] = {
-  [TD_WIN] = ACTION_TAP_DANCE_DOUBLE(KC_CAD, KC_LOCK),
+  [TD_WIN] = ACTION_TAP_DANCE_FN(lock_unlock),
   [TD_ESC] = ACTION_TAP_DANCE_DOUBLE(KC_ESC, KC_GRV),
   [TD_RCTL] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, ctl_copy_finished, ctl_copy_reset)
 };

+ 43 - 0
users/stanrc85/startup_fanfare.c

@@ -0,0 +1,43 @@
+#include "stanrc85.h"
+
+static uint8_t top = 0;
+static uint8_t middle = 0;
+static uint8_t bottom = 0;
+
+static bool is_enabled = true;
+static bool is_rgblight_startup = true;
+static uint16_t rgblight_startup_loop_timer;
+
+void matrix_scan_user(void) {
+    // Boot up "fanfare"
+    if (is_rgblight_startup && is_keyboard_master()) {
+        if (timer_elapsed(rgblight_startup_loop_timer) > 10) {
+            static uint8_t counter;
+            counter++;
+            if (counter == 1) {
+                top = 1;
+                writePin(INDICATOR_PIN_0, !top);
+                wait_ms(200);
+                top = 0;
+                writePin(INDICATOR_PIN_0, !top);
+            }
+            if (counter == 2) {
+                middle = 1;
+                writePin(INDICATOR_PIN_1, !middle);
+                wait_ms(200);
+                middle = 0;
+                writePin(INDICATOR_PIN_1, !middle);
+            }
+            if (counter == 3) {
+                bottom = 1;
+                writePin(INDICATOR_PIN_2, !bottom);
+                wait_ms(200);
+                bottom = 0;
+                writePin(INDICATOR_PIN_2, !bottom);
+            }
+            if (counter == 4) {
+                is_enabled = is_rgblight_startup = false;
+            }
+        }
+    }
+}