diff --git a/app/boards/shields/mercury/Kconfig.defconfig b/app/boards/shields/mercury/Kconfig.defconfig new file mode 100644 index 00000000..a91c986f --- /dev/null +++ b/app/boards/shields/mercury/Kconfig.defconfig @@ -0,0 +1,25 @@ +if SHIELD_MERCURY_LEFT + +config ZMK_KEYBOARD_NAME + default "Mercury-U" + +config ZMK_SPLIT_BLE_ROLE_CENTRAL + default y + +endif + + +if SHIELD_MERCURY_RIGHT + +config ZMK_KEYBOARD_NAME + default "Mercury-R" + +endif + + +if SHIELD_MERCURY_LEFT || SHIELD_MERCURY_RIGHT + +config ZMK_SPLIT + default y + +endif \ No newline at end of file diff --git a/app/boards/shields/mercury/Kconfig.shield b/app/boards/shields/mercury/Kconfig.shield new file mode 100644 index 00000000..2ede2264 --- /dev/null +++ b/app/boards/shields/mercury/Kconfig.shield @@ -0,0 +1,5 @@ +config SHIELD_MERCURY_LEFT + def_bool $(shields_list_contains,mercury_left) + +config SHIELD_MERCURY_RIGHT + def_bool $(shields_list_contains,mercury_right) diff --git a/app/boards/shields/mercury/mercury.conf b/app/boards/shields/mercury/mercury.conf new file mode 100644 index 00000000..e69de29b diff --git a/app/boards/shields/mercury/mercury.dtsi b/app/boards/shields/mercury/mercury.dtsi new file mode 100644 index 00000000..57124b94 --- /dev/null +++ b/app/boards/shields/mercury/mercury.dtsi @@ -0,0 +1,35 @@ +#include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <7>; + rows = <6>; + map = < +RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) +RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,4) RC(4,5) +RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(5,0) RC(5,1) RC(5,2) RC(5,3) RC(5,4) RC(5,5) + RC(2,6) RC(1,6) RC(0,6) RC(5,6) RC(4,6) RC(3,6) + >; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + + diode-direction = "col2row"; + row-gpios + = <&pro_micro_d 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + }; +}; \ No newline at end of file diff --git a/app/boards/shields/mercury/mercury.keymap b/app/boards/shields/mercury/mercury.keymap new file mode 100644 index 00000000..61be99b3 --- /dev/null +++ b/app/boards/shields/mercury/mercury.keymap @@ -0,0 +1,301 @@ +#include +#include +#include +#include + +#define WIN 0 +#define APL 1 +#define GAM 2 +#define NUM 3 +#define FUN 4 +#define NAV 5 +#define MED 6 +#define SYS 7 +#define DL 8 +#define SFL 9 +#define KL 10 +#define LL 11 + +// Words like "sounds" can sometimes come out as "soun" because the final "ds" gets interpreted as a combo. +// Reducing timeout helps prevent this. However, reducing timeout too much makes it difficult to trigger +// the combo when desired. A timeout of 50 ms to 75 ms seems to strike a good balance for most typists. +#define RH_COMBO_TIMEOUT 50 +#define LH_COMBO_TIMEOUT 50 + +// Single finger combos are like "rg" or "hj", where the combined keys are normally typed using +// the same finger. As a result, such sequences are typically typed quite slowly. A very long timeout +// can be used for to be very timing-tolerant, while also not risking accidentally triggering the combo. +#define SINGLE_FINGER_COMBO_TIMEOUT 200 + +/ { + behaviors { + pht: pos_hold_tap { + compatible = "zmk,behavior-hold-tap"; + label = "POS_HOLD_TAP"; + #binding-cells = <2>; + flavor = "tap-unless-interrupted"; + tapping-term-ms = ; + bindings = <&kp>, <&kp>; + hold-trigger-key-positions = <12 13>; + }; + }; + + macros { + mcs: macro_s { + label = "MACRO_S"; + compatible = "zmk,behavior-macro"; + #binding-cells = <0>; + wait-ms = <0>; + bindings + = <¯o_press &mo SFL &kp LSFT> + , <¯o_pause_for_release> + , <¯o_release &mo SFL &kp LSFT> + ; + }; + + mcf: macro_f { + label = "MACRO_F"; + compatible = "zmk,behavior-macro"; + #binding-cells = <0>; + wait-ms = <0>; + bindings + = <¯o_press &mo SFL &mo NUM> + , <¯o_pause_for_release> + , <¯o_release &mo SFL &mo NUM> + ; + }; + + mcl: macro_l { + label = "MACRO_L"; + compatible = "zmk,behavior-macro"; + #binding-cells = <0>; + wait-ms = <0>; + bindings + = <¯o_press &mo KL &kp RSFT> + , <¯o_pause_for_release> + , <¯o_release &mo KL &kp RSFT> + ; + }; + }; + + behaviors { + smt: s_macro_tap { + compatible = "zmk,behavior-hold-tap"; + label = "S_MACRO_TAP"; + #binding-cells = <2>; + flavor = "tap-unless-interrupted"; + tapping-term-ms = ; + bindings = <&mcs>, <&kp>; + hold-trigger-key-positions = <15 16 36 37 38 40 41>; + }; + + dlt: d_layer_tap { + compatible = "zmk,behavior-hold-tap"; + label = "D_LAYER_TAP"; + #binding-cells = <2>; + flavor = "tap-unless-interrupted"; + tapping-term-ms = ; + bindings = <&mo>, <&kp>; + hold-trigger-key-positions = <14 16 36 37 38 40 41>; + }; + + fmt: f_macro_tap { + compatible = "zmk,behavior-hold-tap"; + label = "F_MACRO_TAP"; + #binding-cells = <2>; + flavor = "tap-unless-interrupted"; + tapping-term-ms = ; + bindings = <&mcf>, <&kp>; + hold-trigger-key-positions = <14 15 36 37 38 40 41>; + }; + + klt: k_layer_tap { + compatible = "zmk,behavior-hold-tap"; + label = "K_LAYER_TAP"; + #binding-cells = <2>; + flavor = "tap-unless-interrupted"; + tapping-term-ms = ; + bindings = <&mo>, <&kp>; + hold-trigger-key-positions = <21 36 37 38 40 41>; + }; + + lmt: l_macro_tap { + compatible = "zmk,behavior-hold-tap"; + label = "L_MACRO_TAP"; + #binding-cells = <2>; + flavor = "tap-unless-interrupted"; + tapping-term-ms = ; + bindings = <&mcl>, <&kp>; + hold-trigger-key-positions = <20 36 37 38 40 41>; + }; + }; + + sl { + release-after-ms = <20000>; // 20 seconds + }; + + combos { + compatible = "zmk,combos"; + // Mode switching combos: + combo_sys { + timeout-ms = ; + key-positions = <1 2 3>; + bindings = <&sl SYS>; + }; + combo_standard { + timeout-ms = ; + key-positions = <3 4 5>; + bindings = <&to WIN>; + }; + combo_game { + timeout-ms = ; + key-positions = <2 3 4>; + bindings = <&to GAM>; + }; + + // Slow combos: + // Because these combos use only keys controlled by a single index finger, + // it is very unlikely that a standard touch-typist will accidentally trigger + // during normal typing. We can use a very long timeout for these. + combo_tab { + timeout-ms = ; + key-positions = <4 17>; + bindings = <&kp TAB>; + }; + combo_esc { + timeout-ms = ; + // 16,17 is a great location for ESC: convenient and safe. However, it is just affected + // by the hold-tap => combo mis-fire bug: https://github.com/zmkfirmware/zmk/issues/1395 + // Until that is resolved, use positions 4,5 + key-positions = <16 17>; + bindings = <&kp ESC>; + }; + combo_quote { + timeout-ms = ; + key-positions = <18 19>; + bindings = <&kp QUOT>; + }; + combo_caps { + timeout-ms = ; + key-positions = <30 31>; + bindings = <&kp CAPS>; + }; + combo_menu { + timeout-ms = ; + key-positions = <7 18>; + bindings = <&kp K_CMENU>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + + windows_layer { + bindings = < +&none &kp Q &kp W &kp E &kp R &kp T /**/ &kp Y &kp U &kp I &kp O &kp P &kp BSLH +&mo FUN &pht LSFT A &smt S S &dlt DL D &fmt F F &kp G /**/ &kp H &kp J &klt KL K &lmt L L &kp SCLN &kp QUOT +&none &kp Z &kp X &kp C &kp V &kp B /**/ &kp N &kp M &kp CMMA &kp DOT &kp FSLH &none + &kp LGUI &kp LALT &kp LCTL /**/ &kp SPC &mo NAV &mo MED + >; + }; + + apple_layer { + bindings = < +&trans &trans &trans &trans &trans &trans /**/ &trans &trans &trans &trans &trans &trans +&trans &trans &trans &trans &trans &trans /**/ &trans &trans &trans &trans &trans &trans +&trans &trans &trans &trans &trans &trans /**/ &trans &trans &trans &trans &trans &trans + &kp LCTL &kp LALT &kp LGUI /**/ &kp SPC &mo NAV &mo MED + >; + }; + + game_layer { + bindings = < +&kp TAB &kp Q &kp W &kp E &kp R &kp T /**/ &kp Y &kp U &kp I &kp O &kp P &kp BSLH +&kp ESC &kp A &kp S &kp D &kp F &kp G /**/ &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT +&kp LSFT &kp Z &kp X &kp C &kp V &kp B /**/ &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT + &kp GRAV &kp LALT &kp LCTL /**/ &kp SPC &mo NAV &mo MED + >; + }; + + num_layer { + bindings = < +&trans &trans &trans &trans &trans &trans /**/ &kp GRAV &kp N7 &kp N8 &kp N9 &kp LBKT &kp RBKT +&trans &trans &kp LSFT &mo DL &trans &trans /**/ &kp EQL &kp N4 &kp N5 &kp N6 &kp N0 &kp DOT +&trans &trans &trans &trans &trans &trans /**/ &kp MINUS &kp N1 &kp N2 &kp N3 &kp FSLH &kp DOT + &trans &trans &trans /**/ &trans &trans &trans + >; + }; + + function_layer { + bindings = < +&trans &trans &trans &trans &trans &trans /**/ &kp F12 &kp F7 &kp F8 &kp F9 &kp LBKT &kp RBKT +&trans &kp LSFT &trans &trans &trans &trans /**/ &kp F11 &kp F4 &kp F5 &kp F6 &trans &kp DOT +&trans &trans &trans &trans &trans &trans /**/ &kp F10 &kp F1 &kp F2 &kp F3 &kp FSLH &kp DOT + &trans &trans &trans /**/ &trans &trans &trans + >; + }; + + nav_layer { + bindings = < +&trans &trans &trans &trans &trans &trans /**/ &trans &trans &kp UARW &kp PGUP &kp DEL &trans +&trans &trans &trans &trans &trans &trans /**/ &trans &kp LARW &kp DARW &kp RARW &kp BKSP &trans +&trans &trans &trans &trans &trans &trans /**/ &trans &kp PGDN &kp HOME &kp END &kp RET &trans + &trans &trans &trans /**/ &trans &trans &trans + >; + }; + + media_layer { + bindings = < +&trans &trans &trans &trans &trans &trans /**/ &trans &trans &kp C_VOL_UP &trans &kp PRSC &trans +&trans &trans &kp SLCK &trans &trans &trans /**/ &trans &kp C_BRI_DN &kp C_VOL_DN &kp C_BRI_UP &trans &trans +&trans &trans &trans &trans &trans &kp PAUSE_BREAK /**/ &kp INS &kp C_MUTE &kp C_PREV &kp C_PLAY_PAUSE &kp C_NEXT &trans + &trans &trans &trans /**/ &trans &trans &trans + >; + }; + + system_layer { + bindings = < +&trans &trans &to WIN &trans &trans &trans /**/ &trans &trans &trans &trans &trans &trans +&trans &to APL &out OUT_USB &trans &trans &trans /**/ &trans &trans &trans &trans &trans &trans +&trans &trans &trans &bt BT_CLR &trans &out OUT_BLE /**/ &trans &trans &trans &trans &trans &trans + &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 /**/ &trans &trans &trans + >; + }; + + d_key_layer { + bindings = < +&trans &trans &trans &trans &trans &trans /**/ &trans &trans &trans &trans &trans &trans +&trans &trans &kp LSFT &none &mo NUM &trans /**/ &trans &trans &trans &trans &trans &trans +&trans &trans &trans &trans &trans &trans /**/ &trans &trans &trans &trans &trans &trans + &trans &trans &trans /**/ &trans &trans &trans + >; + }; + + sf_key_layer { + bindings = < +&trans &trans &trans &trans &trans &trans /**/ &trans &trans &trans &trans &trans &trans +&trans &trans &trans &mo DL &trans &trans /**/ &trans &trans &trans &trans &trans &trans +&trans &trans &trans &trans &trans &trans /**/ &trans &trans &trans &trans &trans &trans + &trans &trans &trans /**/ &trans &trans &trans + >; + }; + + k_key_layer { + bindings = < +&trans &trans &trans &trans &trans &trans /**/ &trans &trans &trans &trans &trans &trans +&trans &trans &trans &trans &trans &trans /**/ &trans &trans &none &kp RSFT &trans &trans +&trans &trans &trans &trans &trans &trans /**/ &trans &trans &trans &trans &trans &trans + &trans &trans &trans /**/ &trans &trans &trans + >; + }; + + l_key_layer { + bindings = < +&trans &trans &trans &trans &trans &trans /**/ &trans &trans &trans &trans &trans &trans +&trans &trans &trans &trans &trans &trans /**/ &trans &trans &mo KL &trans &trans &trans +&trans &trans &trans &trans &trans &trans /**/ &trans &trans &trans &trans &trans &trans + &trans &trans &trans /**/ &trans &trans &trans + >; + }; + }; +}; diff --git a/app/boards/shields/mercury/mercury_left.conf b/app/boards/shields/mercury/mercury_left.conf new file mode 100644 index 00000000..eb04ef76 --- /dev/null +++ b/app/boards/shields/mercury/mercury_left.conf @@ -0,0 +1,8 @@ +# Increases power consumption slightly, but improves signal strength +CONFIG_BT_CTLR_TX_PWR_PLUS_8=y + +# Put into deep sleep if keyboard is idle for a long enough time +CONFIG_ZMK_SLEEP=y + +# Log to USB for debugging purposes +# CONFIG_ZMK_USB_LOGGING=y \ No newline at end of file diff --git a/app/boards/shields/mercury/mercury_left.overlay b/app/boards/shields/mercury/mercury_left.overlay new file mode 100644 index 00000000..529ede85 --- /dev/null +++ b/app/boards/shields/mercury/mercury_left.overlay @@ -0,0 +1,13 @@ +#include "mercury.dtsi" + +&kscan0 { + col-gpios + = <&pro_micro_a 3 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 2 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 1 GPIO_ACTIVE_HIGH> + ; +}; \ No newline at end of file diff --git a/app/boards/shields/mercury/mercury_right.conf b/app/boards/shields/mercury/mercury_right.conf new file mode 100644 index 00000000..eb04ef76 --- /dev/null +++ b/app/boards/shields/mercury/mercury_right.conf @@ -0,0 +1,8 @@ +# Increases power consumption slightly, but improves signal strength +CONFIG_BT_CTLR_TX_PWR_PLUS_8=y + +# Put into deep sleep if keyboard is idle for a long enough time +CONFIG_ZMK_SLEEP=y + +# Log to USB for debugging purposes +# CONFIG_ZMK_USB_LOGGING=y \ No newline at end of file diff --git a/app/boards/shields/mercury/mercury_right.overlay b/app/boards/shields/mercury/mercury_right.overlay new file mode 100644 index 00000000..529ede85 --- /dev/null +++ b/app/boards/shields/mercury/mercury_right.overlay @@ -0,0 +1,13 @@ +#include "mercury.dtsi" + +&kscan0 { + col-gpios + = <&pro_micro_a 3 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 2 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 1 GPIO_ACTIVE_HIGH> + ; +}; \ No newline at end of file diff --git a/app/boards/shields/mercury/readme.txt b/app/boards/shields/mercury/readme.txt new file mode 100644 index 00000000..4ed99419 --- /dev/null +++ b/app/boards/shields/mercury/readme.txt @@ -0,0 +1,7 @@ +from Windows CMD: +cd zmk\app +west build -d build/left -p -b nice_nano -- -DSHIELD=mercury_left +west build -d build/right -p -b nice_nano -- -DSHIELD=mercury_right + +west build -d build/left -p -b nice_nano_v2 -- -DSHIELD=mercury_left +west build -d build/right -p -b nice_nano_v2 -- -DSHIELD=mercury_right \ No newline at end of file