From a2cec0594b15dc667adf7f1b0e35cb698dc1758d Mon Sep 17 00:00:00 2001
From: Drashna Jaelre <drashna@live.com>
Date: Mon, 22 Apr 2019 11:55:55 -0700
Subject: [Keymap] Update to Drashna Keymaps (#5594)

* Start to standardize macro timer

* Update Fractal layout

Specifically, limit the RGB Lighting, since it's too many for the power, and only have the KITT annimation on the front

* Update Iris keymap to use I2C for transport

* Remove TAP_CODE_DELAY from keyboard in favor of global setting

* Remove Woodpad

Since it\'s no longer in my possession

* Only enable LTO on AVR boards

* Run matrix_scans while doing startup light

* Run matrix_scan to get split keyboard code synced properly

* Fix rgb mode

* Remove custom debouncing settings

* Make RGB Light Startup Animation optional

* Fix opt def

* Remove extra tap code delay value

* Fix references to keebio boards

* Add support for LP Iris keyboard

* Add backlight code

* Make startup animation optional

* Update gitlab ci script

* Remove port declaration

* Revert avrgcc changes to gitlab ci file

* Don't re-set mods

* Remove MACRO_TIMER define

* Add custom name for crkbd

* Add name for Prime M pad

* Add names for ortho 4x12 boards

* Add some additional handling for rgb init

* Change thumb clusters on ergodox

* Switch Orthodox to I2C

* Fix Space in ergodox keymap

* Use OSL for ergodox layout

* Ugh, can't find a good layout

* Fix typo

* Fix up animation startup

* Cries in AVR

* Fix makefiles for ergodox ez boards

* Add support for "secret songs" in my userspace

* Reset debounce to 5ms for Ergodox EZ

* Fix gitlab CI yaml file

* More crying in AVR

* Cannot use rgb light and rgb matrix at the same time due to the WS2812 rgb matrix PR until the "Coexistance" PR is merged

* Update ODox for split common and i2c

* Add split config

* Impement Split code

* Add support for xscorpion OLED code

* Add OLED display config

* Fix OLED screen font

* Get OLED set up in vertical mode

* Remove old OLED code

* add per key support for crkbd

* Fix split changes

* RGB Tweeaks

* More OLED tweaks

* Fix rotation stuff

* Fix more OLED stuff

* Remove custom Debounce from Ergodox layout since it's no longer needed
---
 users/drashna/.gitignore        |  3 +++
 users/drashna/.gitlab-ci.yml    | 30 ++++--------------------------
 users/drashna/config.h          |  2 +-
 users/drashna/drashna.c         | 18 +++++++-----------
 users/drashna/drashna.h         |  6 +++++-
 users/drashna/process_records.c | 20 +++++++++-----------
 users/drashna/process_records.h |  2 ++
 users/drashna/rgb_stuff.c       | 25 ++++++++++++++-----------
 users/drashna/rules.mk          |  7 ++++++-
 9 files changed, 51 insertions(+), 62 deletions(-)
 create mode 100644 users/drashna/.gitignore

(limited to 'users/drashna')

diff --git a/users/drashna/.gitignore b/users/drashna/.gitignore
new file mode 100644
index 0000000000..f84d34d907
--- /dev/null
+++ b/users/drashna/.gitignore
@@ -0,0 +1,3 @@
+secrets.c
+secrets.h
+drashna_song_list.h
\ No newline at end of file
diff --git a/users/drashna/.gitlab-ci.yml b/users/drashna/.gitlab-ci.yml
index 9b18d44fb3..92813a27d3 100644
--- a/users/drashna/.gitlab-ci.yml
+++ b/users/drashna/.gitlab-ci.yml
@@ -3,7 +3,7 @@ stages:
   - build
   - deploy
 
-Tests:
+Preliminary Test:
   stage: test
   variables:
     GIT_SUBMODULE_STRATEGY: recursive
@@ -12,12 +12,12 @@ Tests:
   image: ubuntu:18.10
   before_script:
     - apt-get update -qy
-    - apt-get install -y build-essential avr-libc binutils-arm-none-eabi binutils-avr dfu-programmer dfu-util gcc gcc-arm-none-eabi gcc-avr git libnewlib-arm-none-eabi unzip wget zip
+    - apt-get install -y build-essential avr-libc binutils-arm-none-eabi binutils-avr dfu-programmer dfu-util gcc gcc-arm-none-eabi git libnewlib-arm-none-eabi gcc-avr unzip wget zip
     - avr-gcc --version
     - uname -a
   script:
     - make test:all
-    - make planck/rev6:default
+    - make planck/rev6:default planck/rev5:default
 
 QMK Firmware Defaults:
   stage: deploy
@@ -47,29 +47,7 @@ Drashna Firmware:
     - apt-get install -y build-essential avr-libc binutils-arm-none-eabi binutils-avr dfu-programmer dfu-util gcc gcc-arm-none-eabi gcc-avr git libnewlib-arm-none-eabi unzip wget zip
     - avr-gcc --version
   script:
-    - make iris/rev2:drashna iris/rev2:drashna_old ergodox_ez:drashna ergodox_ez:drashna_glow viterbi/rev1:drashna orthodox/rev1:drashna orthodox/rev3:drashna crkbd:drashna planck/light:drashna planck/rev6:drashna fractal:drashna
-  artifacts:
-    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
-    paths:
-      - ./*.hex
-      - ./*.bin
-    expire_in: 1 month
-
-Firmware Deploy:
-  stage: deploy
-  dependencies:
-    - Drashna Firmware
-  variables:
-    GIT_SUBMODULE_STRATEGY: recursive
-  tags:
-    - linux
-  image: ubuntu:18.10
-  before_script:
-    - apt-get update -qy
-    - apt-get install -y build-essential avr-libc binutils-arm-none-eabi binutils-avr dfu-programmer dfu-util gcc gcc-arm-none-eabi gcc-avr git libnewlib-arm-none-eabi unzip wget zip
-    - avr-gcc --version
-  script:
-    - make iris/rev2:drashna:production iris/rev2:drashna_old:production ergodox_ez:drashna ergodox_ez:drashna_glow viterbi/rev1:drashna:production orthodox/rev1:drashna:production orthodox/rev3:drashna:production crkbd:drashna:production planck/light:drashna planck/rev6:drashna fractal:drashna:production
+    - make keebio/iris/rev2:drashna keebio/iris/rev2:drashna_old ergodox_ez:drashna ergodox_ez:drashna_glow keebio/viterbi/rev1:drashna orthodox/rev1:drashna orthodox/rev3:drashna crkbd:drashna planck/light:drashna planck/rev6:drashna fractal:drashna primekb/prime_m:drashna -j16 --output-sync
   artifacts:
     name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
     paths:
diff --git a/users/drashna/config.h b/users/drashna/config.h
index 2abd326dac..1680eb4cb1 100644
--- a/users/drashna/config.h
+++ b/users/drashna/config.h
@@ -82,4 +82,4 @@
 #define NO_ACTION_MACRO
 #define NO_ACTION_FUNCTION
 
-#define MACRO_TIMER 5
+#define TAP_CODE_DELAY 5
diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c
index 6968a4b928..ec249dd224 100644
--- a/users/drashna/drashna.c
+++ b/users/drashna/drashna.c
@@ -38,9 +38,9 @@ bool send_game_macro(const char *str, keyrecord_t *record, bool override) {
     }
     clear_keyboard();
     tap_code(keycode);
-    wait_ms(50);
-    send_string_with_delay(str, MACRO_TIMER);
-    wait_ms(50);
+    wait_ms(TAP_CODE_DELAY);
+    send_string_with_delay(str, TAP_CODE_DELAY);
+    wait_ms(TAP_CODE_DELAY);
     tap_code(KC_ENTER);
   }
   if (override) wait_ms(3000);
@@ -53,12 +53,10 @@ bool mod_key_press_timer (uint16_t code, uint16_t mod_code, bool pressed) {
       this_timer= timer_read();
   } else {
       if (timer_elapsed(this_timer) < TAPPING_TERM){
-          register_code(code);
-          unregister_code(code);
+          tap_code(code);
       } else {
           register_code(mod_code);
-          register_code(code);
-          unregister_code(code);
+          tap_code(code);
           unregister_code(mod_code);
       }
   }
@@ -70,12 +68,10 @@ bool mod_key_press (uint16_t code, uint16_t mod_code, bool pressed, uint16_t thi
       this_timer= timer_read();
   } else {
       if (timer_elapsed(this_timer) < TAPPING_TERM){
-          register_code(code);
-          unregister_code(code);
+          tap_code(code);
       } else {
           register_code(mod_code);
-          register_code(code);
-          unregister_code(code);
+          tap_code(code);
           unregister_code(mod_code);
       }
   }
diff --git a/users/drashna/drashna.h b/users/drashna/drashna.h
index c19b189434..6645626d98 100644
--- a/users/drashna/drashna.h
+++ b/users/drashna/drashna.h
@@ -27,7 +27,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
   #include "rgb_stuff.h"
 #endif
-
+#if defined(AUDIO_ENABLE) && __GNUC__ > 7
+  #if __has_include("drashna_song_list.h")
+    #include "drashna_song_list.h"
+  #endif
+#endif
 
 /* Define layer names */
 enum userspace_layers {
diff --git a/users/drashna/process_records.c b/users/drashna/process_records.c
index 2d9025b375..2b6ccf510c 100644
--- a/users/drashna/process_records.c
+++ b/users/drashna/process_records.c
@@ -18,7 +18,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
 
   // If console is enabled, it will print the matrix position and status of each key pressed
 #ifdef KEYLOGGER_ENABLE
-  #if defined(KEYBOARD_ergodox_ez) || defined(KEYBOARD_iris_rev2)
+  #if defined(KEYBOARD_ergodox_ez) || defined(KEYBOARD_keebio_iris_rev2)
     xprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.row, record->event.key.col, record->event.pressed);
   #else
     xprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed);
@@ -37,31 +37,29 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
       uint8_t temp_mod = get_mods();
       uint8_t temp_osm = get_oneshot_mods();
       clear_mods(); clear_oneshot_mods();
-      send_string_with_delay_P(PSTR("make " QMK_KEYBOARD ":" QMK_KEYMAP), MACRO_TIMER);
+      send_string_with_delay_P(PSTR("make " QMK_KEYBOARD ":" QMK_KEYMAP), TAP_CODE_DELAY);
 #ifndef MAKE_BOOTLOADER
       if ( ( temp_mod | temp_osm ) & MOD_MASK_SHIFT )
 #endif
       {
         #if defined(__arm__)
-          send_string_with_delay_P(PSTR(":dfu-util"), MACRO_TIMER);
+          send_string_with_delay_P(PSTR(":dfu-util"), TAP_CODE_DELAY);
         #elif defined(BOOTLOADER_DFU)
-          send_string_with_delay_P(PSTR(":dfu"), MACRO_TIMER);
+          send_string_with_delay_P(PSTR(":dfu"), TAP_CODE_DELAY);
         #elif defined(BOOTLOADER_HALFKAY)
-          send_string_with_delay_P(PSTR(":teensy"), MACRO_TIMER);
+          send_string_with_delay_P(PSTR(":teensy"), TAP_CODE_DELAY);
         #elif defined(BOOTLOADER_CATERINA)
-          send_string_with_delay_P(PSTR(":avrdude"), MACRO_TIMER);
+          send_string_with_delay_P(PSTR(":avrdude"), TAP_CODE_DELAY);
         #endif // bootloader options
        }
-      if ( ( temp_mod | temp_osm ) & MOD_MASK_CTRL) { send_string_with_delay_P(PSTR(" -j8 --output-sync"), MACRO_TIMER); }
-      send_string_with_delay_P(PSTR(SS_TAP(X_ENTER)), MACRO_TIMER);
-      set_mods(temp_mod);
-      set_oneshot_mods(temp_osm);
+      if ( ( temp_mod | temp_osm ) & MOD_MASK_CTRL) { send_string_with_delay_P(PSTR(" -j8 --output-sync"), TAP_CODE_DELAY); }
+      send_string_with_delay_P(PSTR(SS_TAP(X_ENTER)), TAP_CODE_DELAY);
     }
     break;
 
   case VRSN: // Prints firmware version
     if (record->event.pressed) {
-      send_string_with_delay_P(PSTR(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION ", Built on: " QMK_BUILDDATE), MACRO_TIMER);
+      send_string_with_delay_P(PSTR(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION ", Built on: " QMK_BUILDDATE), TAP_CODE_DELAY);
     }
     break;
 
diff --git a/users/drashna/process_records.h b/users/drashna/process_records.h
index f7f2193ec6..5e3374d3f2 100644
--- a/users/drashna/process_records.h
+++ b/users/drashna/process_records.h
@@ -56,6 +56,8 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record);
 #define ADJUST MO(_ADJUST)
 #define TG_MODS TG(_MODS)
 #define TG_GAME TG(_GAMEPAD)
+#define OS_LWR OSL(_LOWER)
+#define OS_RSE OSL(_RAISE)
 
 #define KC_SEC1 KC_SECRET_1
 #define KC_SEC2 KC_SECRET_2
diff --git a/users/drashna/rgb_stuff.c b/users/drashna/rgb_stuff.c
index a98ad590cc..b5e145842f 100644
--- a/users/drashna/rgb_stuff.c
+++ b/users/drashna/rgb_stuff.c
@@ -247,17 +247,20 @@ bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) {
 
 
 void keyboard_post_init_rgb(void) {
-#ifdef RGBLIGHT_ENABLE
-	rgblight_enable_noeeprom();
-	layer_state_set_user(layer_state);
-  uint16_t old_hue = rgblight_config.hue;
-	rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
-	for (uint16_t i = 360; i > 0; i--) {
-		rgblight_sethsv_noeeprom( ( i + old_hue) % 360, 255, 255);
-    wait_ms(10);
-	}
-	layer_state_set_user(layer_state);
+#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_STARTUP_ANIMATION)
+  if (userspace_config.rgb_layer_change) { rgblight_enable_noeeprom(); }
+	if (rgblight_config.enable) {
+    layer_state_set_user(layer_state);
+    uint16_t old_hue = rgblight_config.hue;
+    rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
+    for (uint16_t i = 360; i > 0; i--) {
+      rgblight_sethsv_noeeprom( ( i + old_hue) % 360, 255, 255);
+      matrix_scan();
+      wait_ms(10);
+    }
+  }
 #endif
+  layer_state_set_user(layer_state);
 }
 
 void matrix_scan_rgb(void) {
@@ -278,7 +281,7 @@ uint32_t layer_state_set_rgb(uint32_t state) {
     switch (biton32(state)) {
     case _MACROS:
       rgblight_sethsv_noeeprom_orange();
-      userspace_config.is_overwatch ? rgblight_effect_snake(RGBLIGHT_MODE_SNAKE + 2) : rgblight_effect_snake(RGBLIGHT_MODE_SNAKE + 3);
+      userspace_config.is_overwatch ? rgblight_mode_noeeprom(RGBLIGHT_MODE_SNAKE + 2) : rgblight_mode_noeeprom(RGBLIGHT_MODE_SNAKE + 3);
       break;
     case _MEDIA:
       rgblight_sethsv_noeeprom_chartreuse();
diff --git a/users/drashna/rules.mk b/users/drashna/rules.mk
index 5050704a53..bef25e2594 100644
--- a/users/drashna/rules.mk
+++ b/users/drashna/rules.mk
@@ -9,7 +9,9 @@ ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
   SRC += tap_dances.c
 endif
 
-EXTRAFLAGS += -flto
+ifeq ($(PLATFORM),AVR)
+  EXTRAFLAGS += -flto
+endif
 
 ifeq ($(strip $(NO_SECRETS)), yes)
     OPT_DEFS += -DNO_SECRETS
@@ -26,6 +28,9 @@ ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
   ifeq ($(strip $(RGBLIGHT_NOEEPROM)), yes)
     OPT_DEFS += -DRGBLIGHT_NOEEPROM
   endif
+  ifeq ($(strip $(RGBLIGHT_STARTUP_ANIMATION)), yes)
+    OPT_DEFS += -DRGBLIGHT_STARTUP_ANIMATION
+  endif
 endif
 
 ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
-- 
cgit v1.2.3