diff options
21 files changed, 655 insertions, 35 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4a43f5d..454ab79 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,10 @@ jobs: - iris_left - iris_right - romac + - romac_plus - settings_reset + - quefrency_left + - quefrency_right include: - board: proton_c shield: clueboard_california diff --git a/app/Kconfig b/app/Kconfig index 6180565..ccd40da 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -132,16 +132,30 @@ endif endif -if ZMK_BLE && (!ZMK_SPLIT_BLE || ZMK_SPLIT_BLE_ROLE_CENTRAL) +if ZMK_BLE + +if ZMK_SPLIT_BLE && ZMK_SPLIT_BLE_ROLE_CENTRAL config BT_MAX_CONN default 6 config BT_MAX_PAIRED + default 6 + +endif + +if !ZMK_SPLIT_BLE + +config BT_MAX_CONN + default 5 + +config BT_MAX_PAIRED default 5 endif +endif + endmenu config ZMK_KSCAN_MOCK_DRIVER diff --git a/app/boards/shields/quefrency/Kconfig.defconfig b/app/boards/shields/quefrency/Kconfig.defconfig new file mode 100644 index 0000000..2b00cb6 --- /dev/null +++ b/app/boards/shields/quefrency/Kconfig.defconfig @@ -0,0 +1,17 @@ +#Copyright (c) 2020 The ZMK Contributors +#SPDX-License-Identifier: MIT + + +if SHIELD_QUEFRENCY_LEFT + +config ZMK_KEYBOARD_NAME + default "Quefrency Left" + +endif + +if SHIELD_QUEFRENCY_RIGHT + +config ZMK_KEYBOARD_NAME + default "Quefrency Right" + +endif diff --git a/app/boards/shields/quefrency/Kconfig.shield b/app/boards/shields/quefrency/Kconfig.shield new file mode 100644 index 0000000..d205e58 --- /dev/null +++ b/app/boards/shields/quefrency/Kconfig.shield @@ -0,0 +1,8 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +config SHIELD_QUEFRENCY_LEFT + def_bool $(shields_list_contains,quefrency_left) + +config SHIELD_QUEFRENCY_RIGHT + def_bool $(shields_list_contains,quefrency_right) diff --git a/app/boards/shields/quefrency/quefrency.conf b/app/boards/shields/quefrency/quefrency.conf new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/boards/shields/quefrency/quefrency.conf diff --git a/app/boards/shields/quefrency/quefrency.dtsi b/app/boards/shields/quefrency/quefrency.dtsi new file mode 100644 index 0000000..5f1e908 --- /dev/null +++ b/app/boards/shields/quefrency/quefrency.dtsi @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include <dt-bindings/zmk/matrix-transform.h> + +/ { + chosen { + zmk,kscan = &kscan0; + + zmk,matrix_transform = &default_transform; + }; + + /* + * This transform correspondsto the 60% left without macro keypad and 65% right, even this + * combination of PCBs can have keys in different locations based on configuration. + */ + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <15>; + rows = <6>; + map = < +RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) /**/ RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11) RC(0,12) RC(0,14) RC(5,13) +RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) /**/RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11) RC(1,12) RC(1,13) RC(1,14) RC(5,14) +RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) /**/ RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11) RC(2,12) RC(2,14) RC(2,13) +RC(3,0) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) /**/ RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,12) RC(3,13) RC(3,14) RC(3,11) +RC(4,0) RC(4,1) RC(4,2) RC(4,4) RC(4,6) /**/ RC(4,7) RC(4,10) RC(4,11) RC(4,12) RC(4,13) RC(4,14) RC(4,9) + >; + }; +}; diff --git a/app/boards/shields/quefrency/quefrency.keymap b/app/boards/shields/quefrency/quefrency.keymap new file mode 100644 index 0000000..21c5ed4 --- /dev/null +++ b/app/boards/shields/quefrency/quefrency.keymap @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include <behaviors.dtsi> +#include <dt-bindings/zmk/bt.h> +#include <dt-bindings/zmk/keys.h> + +/ { + keymap { + compatible = "zmk,keymap"; + +// ---------------------------------------------- ----------------------------------------------------- +// | ESC | 1 | 2 | 3 | 4 | 5 | 6 | | 7 | 8 | 9 | 0 | - | = | BKSPC | ` | +// | TAB | Q | W | E | R | T | | Y | U | I | O | P | [ | ] | \ | DEL | +// | LCTRL | A | S | D | F | G | | H | J | K | L | ; | ' | ENTER | PGUP | +// | SHIFT | Z | X | C | V | B | | N | M | , | . | / | RSHFT | UP | PGDN | +// | LCTRL | LGUI | LALT | SPACE | FN | | SPACE | RALT | FN | RCTRL | LFT | DWN | RGHT | +// ------------------------------------------- ------------------------------------------------------ + + default_layer { + bindings = < + &kp ESC &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 /**/ &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp MINUS &kp EQL &kp BKSP &kp GRAV + &kp TAB &kp Q &kp W &kp E &kp R &kp T /**/ &kp Y &kp U &kp I &kp O &kp P &kp LBKT &kp RBKT &kp BSLH &kp HOME + &kp LCTL &kp A &kp S &kp D &kp F &kp G /**/ &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT &kp RET &kp PGUP + &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 UARW &kp PGDN + &kp LCTL &kp LGUI &kp LALT &kp SPC &mo 1 /**/ &kp SPC &kp RALT &mo 1 &kp RCTL &kp LARW &kp DARW &kp RARW + >; + }; + +// ---------------------------------------------- ----------------------------------------------------- +// |BT_CLR| F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 | |BT_CLR| +// | | BT-0 | BT-1| BT-2 | | | | | | | | | | | | | +// | | | | | | | | | | | | | | | | +// | | | | | | | | | | | | | | | | +// | | | | | | | | | | | | | | +// ------------------------------------------- ------------------------------------------------------ + + fn_layer { + bindings = < + &bt BT_CLR &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 /**/ &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &trans &bt BT_CLR + &trans &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &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 &trans &trans &trans + &trans &trans &trans &trans &trans /**/ &trans &trans &trans &trans &trans &trans &trans + >; + }; + }; +}; diff --git a/app/boards/shields/quefrency/quefrency_left.conf b/app/boards/shields/quefrency/quefrency_left.conf new file mode 100644 index 0000000..1e028a7 --- /dev/null +++ b/app/boards/shields/quefrency/quefrency_left.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/boards/shields/quefrency/quefrency_left.overlay b/app/boards/shields/quefrency/quefrency_left.overlay new file mode 100644 index 0000000..a385cc5 --- /dev/null +++ b/app/boards/shields/quefrency/quefrency_left.overlay @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include "quefrency.dtsi" + +/ { + /* This kscan is for the 60% left half without macro keys the + * macro pad layout may require different column and row pins + */ + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + diode-direction = "col2row"; + + + col-gpios + = <&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 16 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 10 GPIO_ACTIVE_HIGH> + ; + + row-gpios + = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_a 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_a 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_a 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + }; +}; diff --git a/app/boards/shields/quefrency/quefrency_right.conf b/app/boards/shields/quefrency/quefrency_right.conf new file mode 100644 index 0000000..990cf7c --- /dev/null +++ b/app/boards/shields/quefrency/quefrency_right.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/quefrency/quefrency_right.overlay b/app/boards/shields/quefrency/quefrency_right.overlay new file mode 100644 index 0000000..53e0f77 --- /dev/null +++ b/app/boards/shields/quefrency/quefrency_right.overlay @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include "quefrency.dtsi" + +&default_transform { + col-offset = <7>; +}; + +/ { + + /* This kscan is for the 65% right half the 60% right half + * may require different column and row pins + */ + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + diode-direction = "col2row"; + + + + col-gpios + = <&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 16 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 10 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 5 GPIO_ACTIVE_HIGH> + ; + + row-gpios + = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_a 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_a 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_a 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_a 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + }; +}; diff --git a/app/boards/shields/romac_plus/Kconfig.defconfig b/app/boards/shields/romac_plus/Kconfig.defconfig new file mode 100644 index 0000000..c4efdb9 --- /dev/null +++ b/app/boards/shields/romac_plus/Kconfig.defconfig @@ -0,0 +1,9 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +if SHIELD_ROMAC_PLUS + +config ZMK_KEYBOARD_NAME + default "RoMac+ v4" + +endif
\ No newline at end of file diff --git a/app/boards/shields/romac_plus/Kconfig.shield b/app/boards/shields/romac_plus/Kconfig.shield new file mode 100644 index 0000000..a7c7c61 --- /dev/null +++ b/app/boards/shields/romac_plus/Kconfig.shield @@ -0,0 +1,5 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +config SHIELD_ROMAC_PLUS + def_bool $(shields_list_contains,romac_plus) diff --git a/app/boards/shields/romac_plus/boards/nice_nano.overlay b/app/boards/shields/romac_plus/boards/nice_nano.overlay new file mode 100644 index 0000000..a8dafa2 --- /dev/null +++ b/app/boards/shields/romac_plus/boards/nice_nano.overlay @@ -0,0 +1,28 @@ +&spi1 {
+ compatible = "nordic,nrf-spi";
+ status = "okay";
+ mosi-pin = <6>;
+ // Unused pins, needed for SPI definition, but not used by the ws2812 driver itself.
+ sck-pin = <5>;
+ miso-pin = <7>;
+
+ led_strip: ws2812@0 {
+ compatible = "worldsemi,ws2812-spi";
+ label = "WS2812";
+
+ /* SPI */
+ reg = <0>; /* ignored, but necessary for SPI bindings */
+ spi-max-frequency = <4000000>;
+
+ /* WS2812 */
+ chain-length = <10>; /* arbitrary; change at will */
+ spi-one-frame = <0x70>;
+ spi-zero-frame = <0x40>;
+ };
+};
+
+/ {
+ chosen {
+ zmk,underglow = &led_strip;
+ };
+};
\ No newline at end of file diff --git a/app/boards/shields/romac_plus/romac_plus.conf b/app/boards/shields/romac_plus/romac_plus.conf new file mode 100644 index 0000000..d784dc4 --- /dev/null +++ b/app/boards/shields/romac_plus/romac_plus.conf @@ -0,0 +1,6 @@ +# Copyright (c) 2020 The ZMK Contributors
+# SPDX-License-Identifier: MIT
+
+# Uncomment to enable encoder
+#CONFIG_EC11=y
+#CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y
\ No newline at end of file diff --git a/app/boards/shields/romac_plus/romac_plus.dtsi b/app/boards/shields/romac_plus/romac_plus.dtsi new file mode 100644 index 0000000..9b148ca --- /dev/null +++ b/app/boards/shields/romac_plus/romac_plus.dtsi @@ -0,0 +1,56 @@ +/*
+ * Copyright (c) 2020 The ZMK Contributors
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include <dt-bindings/zmk/matrix-transform.h>
+
+/ {
+ chosen {
+ zmk,kscan = &kscan0;
+ zmk,matrix_transform = &default_transform;
+ };
+
+ default_transform: keymap_transform_0 {
+ compatible = "zmk,matrix-transform";
+ columns = <3>;
+ rows = <4>;
+
+ map = <
+RC(0,0) RC(0,1) RC(0,2)
+RC(1,0) RC(1,1) RC(1,2)
+RC(2,0) RC(2,1) RC(2,2)
+RC(3,0) RC(3,1) RC(3,2)
+ >;
+ };
+
+ kscan0: kscan {
+ compatible = "zmk,kscan-gpio-matrix";
+ label = "KSCAN";
+
+ diode-direction = "col2row";
+ row-gpios
+ = <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
+ , <&pro_micro_d 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
+ , <&pro_micro_d 0 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
+ , <&pro_micro_d 1 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
+ ;
+ };
+
+ left_encoder: encoder_left {
+ compatible = "alps,ec11";
+ label = "LEFT_ENCODER";
+ a-gpios = <&pro_micro_d 16 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
+ b-gpios = <&pro_micro_d 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
+ resolution = <4>;
+ status = "disabled";
+ };
+
+ sensors {
+ compatible = "zmk,keymap-sensors";
+ sensors = <&left_encoder>;
+ };
+
+ // TODO: per-key RGB node(s)?
+};
\ No newline at end of file diff --git a/app/boards/shields/romac_plus/romac_plus.keymap b/app/boards/shields/romac_plus/romac_plus.keymap new file mode 100644 index 0000000..d8d1f78 --- /dev/null +++ b/app/boards/shields/romac_plus/romac_plus.keymap @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include <behaviors.dtsi> +#include <dt-bindings/zmk/bt.h> +#include <dt-bindings/zmk/keys.h> + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { +// -------------------------- +// | 7 | 8 | 9 | +// | 4 | 5 | 6 | +// | 1 | 2 | 3 | +// | M_PLAY | 0 | MO(1) | +// -------------------------- + bindings = < + &kp NUM_7 &kp NUM_8 &kp NUM_9 + &kp NUM_4 &kp NUM_5 &kp NUM_6 + &kp NUM_1 &kp NUM_2 &kp NUM_3 + &cp M_PLAY &kp NUM_0 &mo 1 + >; + + sensor-bindings = <&inc_dec_cp M_NEXT M_PREV>; + }; + + nav_layer { +// -------------------------- +// | BT_CLR | HOME | PGUP | +// | _ | END | PGDN | +// | _ | _ | _ | +// | _ | _ | _ | +// -------------------------- + bindings = < + &bt BT_CLR &kp HOME &kp PGUP + &trans &kp END &kp PGDN + &trans &trans &trans + &trans &trans &trans + >; + + sensor-bindings = <&inc_dec_kp A B>; + }; + }; +};
\ No newline at end of file diff --git a/app/boards/shields/romac_plus/romac_plus.overlay b/app/boards/shields/romac_plus/romac_plus.overlay new file mode 100644 index 0000000..8643034 --- /dev/null +++ b/app/boards/shields/romac_plus/romac_plus.overlay @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include "romac_plus.dtsi" + +/ { + chosen { + zmk,kscan = &kscan0; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + + diode-direction = "col2row"; + + col-gpios + = <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 2 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 3 GPIO_ACTIVE_HIGH> + ; + }; + +}; + +&left_encoder { + status = "okay"; +};
\ No newline at end of file diff --git a/docs/docs/hardware.md b/docs/docs/hardware.md index 299d1f5..236aa97 100644 --- a/docs/docs/hardware.md +++ b/docs/docs/hardware.md @@ -26,6 +26,11 @@ That being said, there are currently only a few specific [boards](/docs/faq#what - [Kyria](https://splitkb.com/products/kyria-pcb-kit) (`kyria_left` and `kyria_right`) - [Corne](https://github.com/foostan/crkbd) (`corne_left` and `corne_right`) - [Lily58](https://github.com/kata0510/Lily58) (`lily58_left` and `lily58_right`) +- [Sofle](https://github.com/josefadamcik/SofleKeyboard) (`sofle_left` and `sofle_right`) +- [Splitreus62](https://github.com/Na-Cly/splitreus62) (`splitreus62_left` and `splitreus62_right`) +- [RoMac+ v4](https://www.littlekeyboards.com/products/romac) (`romac_plus`) +- [RoMac v2](https://mechboards.co.uk/shop/kits/romac-macro-pad/) (`romac') +- [QAZ](https://www.cbkbd.com/product/qaz-keyboard-kit) (`qaz`) ## Other Hardware diff --git a/docs/static/setup.ps1 b/docs/static/setup.ps1 new file mode 100644 index 0000000..3946e66 --- /dev/null +++ b/docs/static/setup.ps1 @@ -0,0 +1,193 @@ +# Copyright (c) 2020 The ZMK Contributors
+#
+# SPDX-License-Identifier: MIT
+
+$ErrorActionPreference = "Stop"
+
+function Get-Choice-From-Options {
+ param(
+ [String[]] $Options,
+ [String] $Prompt
+ )
+
+ while ($true) {
+ for ($i = 0; $i -lt $Options.length; $i++) {
+ Write-Host "$($i + 1)) $($Options[$i])"
+ }
+
+ Write-Host "$($Options.length + 1)) Quit"
+ $selection = Read-Host $Prompt
+
+ if ($selection -eq $Options.length + 1) {
+ Write-Host "Goodbye!"
+ exit 1
+ }
+ elseif ($selection -le $Options.length) {
+ $choice = $($selection - 1)
+ break
+ }
+ else {
+ Write-Host "Invalid Option. Try another one."
+ }
+ }
+
+ return $choice
+}
+
+function Test-Git-Config {
+ param(
+ [String] $Option,
+ [String] $ErrMsg
+ )
+
+ git config $Option | Out-Null
+
+ if ($lastExitCode -ne 0) {
+ Write-Host $ErrMsg
+ exit 1
+ }
+}
+
+try {
+ git | Out-Null
+}
+catch [System.Management.Automation.CommandNotFoundException] {
+ Write-Host "Git is not installed, and is required for this script!"
+ exit 1
+}
+
+Test-Git-Config -Option "user.name" -ErrMsg "Git username not set!`nRun: git config --global user.name 'My Name'"
+Test-Git-Config -Option "user.email" -ErrMsg "Git email not set!`nRun: git config --global user.name 'example@myemail.com'"
+
+$repo_path = "https://github.com/zmkfirmware/zmk-config-split-template.git"
+
+$title = "ZMK Config Setup:"
+$prompt = "Pick an MCU board"
+$options = "nice!nano", "QMK Proton-C", "BlueMicro840 (v1)"
+$boards = "nice_nano", "proton_c", "bluemicro840_v1"
+
+Write-Host "$title"
+Write-Host ""
+Write-Host "MCU Board Selection:"
+
+$choice = Get-Choice-From-Options -Options $options -Prompt $prompt
+$board = $($boards[$choice])
+
+Write-Host ""
+Write-Host "Keyboard Shield Selection:"
+$prompt = "Pick a keyboard"
+
+# TODO: Add support for "Other" and linking to docs on adding custom shields in user config repos.
+$options = "Kyria", "Lily58", "Corne", "Splitreus62", "Sofle", "Iris", "RoMac"
+$names = "kyria", "lily58", "corne", "splitreus62", "sofle", "iris", "romac"
+$splits = "y", "y", "y", "y", "y", "y", "n"
+
+$choice = Get-Choice-From-Options -Options $options -Prompt $prompt
+$shield_title = $($options[$choice])
+$shield = $($names[$choice])
+$split = $($splits[$choice])
+
+if ($split -eq "n") {
+ $repo_path = "https://github.com/zmkfirmware/zmk-config-template.git"
+}
+
+$copy_keymap = Read-Host "Copy in the stock keymap for customisation? [Yn]"
+
+if ($copy_keymap -eq "" -or $copy_keymap -eq "Y" -or $copy_keymap -eq "y") {
+ $copy_keymap = "yes"
+}
+
+$github_user = Read-Host "GitHub Username (leave empty to skip GitHub repo creation)"
+
+if ($github_user -ne "") {
+ $repo_name = Read-Host "GitHub Repo Name [zmk-config]"
+
+ if ($repo_name -eq "") {
+ $repo_name = "zmk-config"
+ }
+
+ $github_repo = Read-Host "GitHub Repo [https://github.com/$github_user/$repo_name.git]"
+
+ if ($github_repo -eq "") {
+ $github_repo = "https://github.com/$github_user/$repo_name.git"
+ }
+}
+else {
+ $repo_name = "zmk-config"
+ $github_repo = ""
+}
+
+Write-Host ""
+Write-Host "Preparing a user config for:"
+Write-Host "* MCU Board: ${board}"
+Write-Host "* Shield: ${shield}"
+
+if ($copy_keymap -eq "yes") {
+ Write-Host "* Copy Keymap?: Yes"
+}
+else {
+ Write-Host "* Copy Keymap?: No"
+}
+
+if ($github_repo -ne "") {
+ Write-Host "* GitHub Repo to Push (please create this in GH first!): $github_repo"
+}
+
+Write-Host ""
+$do_it = Read-Host "Continue? [Yn]"
+
+if ($do_it -ne "" -and $do_it -ne "Y" -and $do_it -ne "y") {
+ Write-Host "Aborting..."
+ exit 1
+}
+
+git clone --single-branch "$repo_path" "$repo_name"
+Set-Location "$repo_name"
+
+Push-Location config
+
+Invoke-RestMethod -Uri "https://raw.githubusercontent.com/zmkfirmware/zmk/main/app/boards/shields/${shield}/${shield}.conf" -OutFile "${shield}.conf"
+
+if ($copy_keymap -eq "yes") {
+ Invoke-RestMethod -Uri "https://raw.githubusercontent.com/zmkfirmware/zmk/main/app/boards/shields/${shield}/${shield}.keymap" -OutFile "${shield}.keymap"
+}
+
+Pop-Location
+
+$build_file = (Get-Content .github/workflows/build.yml).replace("BOARD_NAME", $board)
+$build_file = $build_file.replace("SHIELD_NAME", $shield)
+$build_file = $build_file.replace("KEYBOARD_TITLE", $shield_title)
+
+if ($board -eq "proton_c") {
+ $build_file = $build_file.replace("uf2", "hex")
+}
+
+Set-Content -Path .github/workflows/build.yml -Value $build_file
+
+Remove-Item -Recurse -Force .git
+git init .
+git add .
+git commit -m "Initial User Config."
+
+if ($github_repo -ne "") {
+ git remote add origin "$github_repo"
+
+ git push --set-upstream origin $(git symbolic-ref --short HEAD)
+
+ # If push failed, assume that the origin was incorrect and give instructions on fixing.
+ if ($lastExitCode -ne 0) {
+ Write-Host "Remote repository $github_repo not found..."
+ Write-Host "Check GitHub URL, and try adding again."
+ Write-Host "Run the following: "
+ Write-Host " git remote rm origin"
+ Write-Host " git remote add origin FIXED_URL"
+ Write-Host " git push --set-upstream origin $(git symbolic-ref --short HEAD)"
+ Write-Host "Once pushed, your firmware should be availalbe from GitHub Actions at: $actions"
+ exit 1
+ }
+
+ if ($github_repo -imatch "https") {
+ $actions = "$($github_repo.substring(0, $github_repo.length - 4))/actions"
+ Write-Host "Your firmware should be availalbe from GitHub Actions shortly: $actions"
+ }
+}
diff --git a/docs/static/setup.sh b/docs/static/setup.sh index 5d203a4..5bf3645 100644 --- a/docs/static/setup.sh +++ b/docs/static/setup.sh @@ -1,14 +1,29 @@ -#!/bin/sh +#!/bin/bash + +# Copyright (c) 2020 The ZMK Contributors +# +# SPDX-License-Identifier: MIT set -e -repo_path="https://github.com/zmkfirmware/zmk-config-split-template.git" -title="ZMK Config Setup:" +check_exists() { + command_to_run=$1 + error_message=$2 + if ! eval "$command_to_run" &> /dev/null; then + printf "%s\n" "$error_message" + exit 1 + fi +} -# TODO: Check for git being installed -# TODO: Check for curl being installed -# TODO: Check for user.name and user.email git configs being set +check_exists "command -v git" "git is not installed, and is required for this script!" +check_exists "command -v curl" "curl is not installed, and is required for this script!" + +check_exists "git config user.name" "Git username not set!\nRun: git config --global user.name 'My Name'" +check_exists "git config user.email" "Git email not set!\nRun: git config --global user.email 'example@myemail.com'" + +repo_path="https://github.com/zmkfirmware/zmk-config-split-template.git" +title="ZMK Config Setup:" prompt="Pick an MCU board:" options=("nice!nano" "QMK Proton-C" "BlueMicro840 (v1)") @@ -17,7 +32,7 @@ echo "$title" echo "" echo "MCU Board Selection:" PS3="$prompt " -select opt in "${options[@]}" "Quit"; do +select opt in "${options[@]}" "Quit"; do case "$REPLY" in @@ -25,15 +40,12 @@ select opt in "${options[@]}" "Quit"; do 2 ) board="proton_c"; break;; 3 ) board="bluemicro840_v1"; break;; - $(( ${#options[@]}+1 )) ) echo "Goodbye!"; exit;; - *) echo "Invalid option. Try another one.";continue;; + $(( ${#options[@]}+1 )) ) echo "Goodbye!"; exit 1;; + *) echo "Invalid option. Try another one."; continue;; esac done -#read -p "Is this board a complete keyboard [yN]: " complete -#echo "$complete" - echo "" echo "Keyboard Shield Selection:" @@ -42,8 +54,8 @@ options=("Kyria" "Lily58" "Corne" "Splitreus62" "Sofle" "Iris" "RoMac") PS3="$prompt " # TODO: Add support for "Other" and linking to docs on adding custom shields in user config repos. -# select opt in "${options[@]}" "Other" "Quit"; do -select opt in "${options[@]}" "Quit"; do +# select opt in "${options[@]}" "Other" "Quit"; do +select opt in "${options[@]}" "Quit"; do case "$REPLY" in @@ -56,8 +68,8 @@ select opt in "${options[@]}" "Quit"; do 7 ) shield_title="RoMac" shield="romac"; split="n"; break;; # Add link to docs on adding your own custom shield in your ZMK config! - # $(( ${#options[@]}+1 )) ) echo "Other!"; break;; - $(( ${#options[@]}+1 )) ) echo "Goodbye!"; exit;; + # $(( ${#options[@]}+1 )) ) echo "Other!"; break;; + $(( ${#options[@]}+1 )) ) echo "Goodbye!"; exit 1;; *) echo "Invalid option. Try another one.";continue;; esac @@ -67,41 +79,43 @@ if [ "$split" == "n" ]; then repo_path="https://github.com/zmkfirmware/zmk-config-template.git" fi -read -e -p "Copy in the stock keymap for customization? [Yn]: " copy_keymap +read -r -e -p "Copy in the stock keymap for customization? [Yn]: " copy_keymap if [ -z "$copy_keymap" ] || [ "$copy_keymap" == "Y" ] || [ "$copy_keymap" == "y" ]; then copy_keymap="yes"; fi -read -e -p "GitHub Username (leave empty to skip GitHub repo creation): " github_user +read -r -e -p "GitHub Username (leave empty to skip GitHub repo creation): " github_user if [ -n "$github_user" ]; then - read -p "GitHub Repo Name [zmk-config]: " repo_name - if [ -z "$repo_name" ]; then repo_name="zmk-config"; fi + read -r -p "GitHub Repo Name [zmk-config]: " repo_name + if [ -z "$repo_name" ]; then repo_name="zmk-config"; fi - read -p "GitHub Repo [https://github.com/${github_user}/${repo_name}.git]: " github_repo + read -r -p "GitHub Repo [https://github.com/${github_user}/${repo_name}.git]: " github_repo - if [ -z "$github_repo" ]; then github_repo="https://github.com/${github_user}/${repo_name}.git"; fi + if [ -z "$github_repo" ]; then github_repo="https://github.com/${github_user}/${repo_name}.git"; fi else - repo_name="zmk-config" + repo_name="zmk-config" fi echo "" echo "Preparing a user config for:" echo "* MCU Board: ${board}" echo "* Shield: ${shield}" + if [ "$copy_keymap" == "yes" ]; then echo "* Copy Keymap?: ✓" else echo "* Copy Keymap?: ❌" fi + if [ -n "$github_repo" ]; then - echo "* GitHub Repo To Push (please create this in GH first!): ${github_repo}" + echo "* GitHub Repo To Push (please create this in GH first!): ${github_repo}" fi echo "" -read -p "Continue? [Yn]: " do_it +read -r -p "Continue? [Yn]: " do_it if [ -n "$do_it" ] && [ "$do_it" != "y" ] && [ "$do_it" != "Y" ]; then - echo "Aborting..." - exit + echo "Aborting..." + exit 1 fi git clone --single-branch $repo_path ${repo_name} @@ -118,10 +132,10 @@ fi popd sed -i'.orig' \ - -e "s/BOARD_NAME/$board/" \ - -e "s/SHIELD_NAME/$shield/" \ - -e "s/KEYBOARD_TITLE/$shield_title/" \ - .github/workflows/build.yml + -e "s/BOARD_NAME/$board/" \ + -e "s/SHIELD_NAME/$shield/" \ + -e "s/KEYBOARD_TITLE/$shield_title/" \ + .github/workflows/build.yml if [ "$board" == "proton_c" ]; then # Proton-C board still fa @@ -136,11 +150,24 @@ git add . git commit -m "Initial User Config." if [ -n "$github_repo" ]; then - git remote add origin "$github_repo" - git push --set-upstream origin $(git symbolic-ref --short HEAD) + git remote add origin "$github_repo" + git push --set-upstream origin "$(git symbolic-ref --short HEAD)" + push_return_code=$? + + # If push failed, assume that the origin was incorrect and give instructions on fixing. + if [ ${push_return_code} -ne 0 ]; then + echo "Remote repository $github_repo not found..." + echo "Check GitHub URL, and try adding again." + echo "Run the following: " + echo " git remote rm origin" + echo " git remote add origin FIXED_URL" + echo " git push --set-upstream origin $(git symbolic-ref --short HEAD)" + echo "Once pushed, your firmware should be availalbe from GitHub Actions at: ${github_repo%.git}/actions" + exit 1 + fi # TODO: Support determing the actions URL when non-https:// repo URL is used. if [ "${github_repo}" != "${github_repo#https://}" ]; then - echo "Your firmware should be available from the GitHub Actions shortly: ${github_url%.git}/actions" + echo "Your firmware should be available from GitHub Actions shortly: ${github_repo%.git}/actions" fi fi |