diff --git a/boards/shields/corne/Kconfig.defconfig b/boards/shields/corne/Kconfig.defconfig new file mode 100644 index 0000000..6d92220 --- /dev/null +++ b/boards/shields/corne/Kconfig.defconfig @@ -0,0 +1,31 @@ +if SHIELD_CORNE_CENTRAL_LEFT + +config ZMK_SPLIT_ROLE_CENTRAL + default y + +config ZMK_KEYBOARD_NAME + default "Corne Left" + +endif + + +if SHIELD_CORNE_DONGLE + +config ZMK_SPLIT_ROLE_CENTRAL + default y + +config ZMK_KEYBOARD_NAME + default "Corne Dongle" + +config ZMK_USB + default y + +endif + + +if SHIELD_CORNE_LEFT || SHIELD_CORNE_RIGHT + +config ZMK_SPLIT + default y + +endif diff --git a/boards/shields/corne/Kconfig.shield b/boards/shields/corne/Kconfig.shield new file mode 100644 index 0000000..c7a56a2 --- /dev/null +++ b/boards/shields/corne/Kconfig.shield @@ -0,0 +1,14 @@ +# Copyright (c) 2020 Pete Johanson +# SPDX-License-Identifier: MIT + +config SHIELD_CORNE_LEFT + def_bool $(shields_list_contains,corne_left) + +config SHIELD_CORNE_CENTRAL_LEFT + def_bool $(shields_list_contains,corne_central_left) + +config SHIELD_CORNE_RIGHT + def_bool $(shields_list_contains,corne_right) + +config SHIELD_CORNE_DONGLE + def_bool $(shields_list_contains,corne_dongle) diff --git a/boards/shields/corne/boards/nice_nano.overlay b/boards/shields/corne/boards/nice_nano.overlay new file mode 100644 index 0000000..424a617 --- /dev/null +++ b/boards/shields/corne/boards/nice_nano.overlay @@ -0,0 +1,46 @@ +#include + +&pinctrl { + spi3_default: spi3_default { + group1 { + psels = ; + }; + }; + + spi3_sleep: spi3_sleep { + group1 { + psels = ; + low-power-enable; + }; + }; +}; + +&spi3 { + compatible = "nordic,nrf-spim"; + status = "okay"; + + pinctrl-0 = <&spi3_default>; + pinctrl-1 = <&spi3_sleep>; + pinctrl-names = "default", "sleep"; + + led_strip: ws2812@0 { + compatible = "worldsemi,ws2812-spi"; + + /* 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>; + + color-mapping = ; + }; +}; + +/ { + chosen { + zmk,underglow = &led_strip; + }; +}; diff --git a/boards/shields/corne/boards/nice_nano_v2.overlay b/boards/shields/corne/boards/nice_nano_v2.overlay new file mode 100644 index 0000000..424a617 --- /dev/null +++ b/boards/shields/corne/boards/nice_nano_v2.overlay @@ -0,0 +1,46 @@ +#include + +&pinctrl { + spi3_default: spi3_default { + group1 { + psels = ; + }; + }; + + spi3_sleep: spi3_sleep { + group1 { + psels = ; + low-power-enable; + }; + }; +}; + +&spi3 { + compatible = "nordic,nrf-spim"; + status = "okay"; + + pinctrl-0 = <&spi3_default>; + pinctrl-1 = <&spi3_sleep>; + pinctrl-names = "default", "sleep"; + + led_strip: ws2812@0 { + compatible = "worldsemi,ws2812-spi"; + + /* 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>; + + color-mapping = ; + }; +}; + +/ { + chosen { + zmk,underglow = &led_strip; + }; +}; diff --git a/boards/shields/corne/corne.conf b/boards/shields/corne/corne.conf new file mode 100644 index 0000000..e69de29 diff --git a/boards/shields/corne/corne.dtsi b/boards/shields/corne/corne.dtsi new file mode 100644 index 0000000..5058f67 --- /dev/null +++ b/boards/shields/corne/corne.dtsi @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + +#include + +/ { + chosen { + zephyr,display = &oled; + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <12>; + rows = <4>; +// | SW1 | SW2 | SW3 | SW4 | SW5 | SW6 | | SW6 | SW5 | SW4 | SW3 | SW2 | SW1 | +// | SW7 | SW8 | SW9 | SW10 | SW11 | SW12 | | SW12 | SW11 | SW10 | SW9 | SW8 | SW7 | +// | SW13 | SW14 | SW15 | SW16 | SW17 | SW18 | | SW18 | SW17 | SW16 | SW15 | SW14 | SW13 | +// | SW19 | SW20 | SW21 | | SW21 | SW20 | SW19 | + 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(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11) +RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11) + RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(3,8) + >; + }; + + five_column_transform: keymap_transform_1 { + compatible = "zmk,matrix-transform"; + columns = <10>; + rows = <4>; +// | SW2 | SW3 | SW4 | SW5 | SW6 | | SW6 | SW5 | SW4 | SW3 | SW2 | +// | SW8 | SW9 | SW10 | SW11 | SW12 | | SW12 | SW11 | SW10 | SW9 | SW8 | +// | SW14 | SW15 | SW16 | SW17 | SW18 | | SW18 | SW17 | SW16 | SW15 | SW14 | +// | SW19 | SW20 | SW21 | | SW21 | SW20 | SW19 | + map = < +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(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) +RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) + RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(3,8) + >; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + + diode-direction = "col2row"; + row-gpios + = <&pro_micro 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + + }; + + // TODO: per-key RGB node(s)? +}; + +&pro_micro_i2c { + status = "okay"; + + oled: ssd1306@3c { + compatible = "solomon,ssd1306fb"; + reg = <0x3c>; + width = <128>; + height = <32>; + segment-offset = <0>; + page-offset = <0>; + display-offset = <0>; + multiplex-ratio = <31>; + segment-remap; + com-invdir; + com-sequential; + prechargep = <0x22>; + }; +}; diff --git a/boards/shields/corne/corne.keymap b/boards/shields/corne/corne.keymap new file mode 100644 index 0000000..0555cf4 --- /dev/null +++ b/boards/shields/corne/corne.keymap @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { +// ----------------------------------------------------------------------------------------- +// | TAB | Q | W | E | R | T | | Y | U | I | O | P | BKSP | +// | CTRL | A | S | D | F | G | | H | J | K | L | ; | ' | +// | SHFT | Z | X | C | V | B | | N | M | , | . | / | ESC | +// | GUI | LWR | SPC | | ENT | RSE | ALT | + bindings = < + &kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BSPC + &kp LCTRL &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp SQT + &kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp ESC + &kp LGUI &mo 1 &kp SPACE &kp RET &mo 2 &kp RALT + >; + }; + lower_layer { +// ----------------------------------------------------------------------------------------- +// | TAB | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | BKSP | +// | BTCLR| BT1 | BT2 | BT3 | BT4 | BT5 | | LFT | DWN | UP | RGT | | | +// | SHFT | | | | | | | | | | | | | +// | GUI | | SPC | | ENT | | ALT | + bindings = < + &kp TAB &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp BSPC + &bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &kp LEFT &kp DOWN &kp UP &kp RIGHT &trans &trans + &kp LSHFT &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans + &kp LGUI &trans &kp SPACE &kp RET &trans &kp RALT + >; + }; + + raise_layer { +// ----------------------------------------------------------------------------------------- +// | TAB | ! | @ | # | $ | % | | ^ | & | * | ( | ) | BKSP | +// | CTRL | | | | | | | - | = | [ | ] | \ | ` | +// | SHFT | | | | | | | _ | + | { | } | "|" | ~ | +// | GUI | | SPC | | ENT | | ALT | + bindings = < + &kp TAB &kp EXCL &kp AT &kp HASH &kp DLLR &kp PRCNT &kp CARET &kp AMPS &kp KP_MULTIPLY &kp LPAR &kp RPAR &kp BSPC + &kp LCTRL &trans &trans &trans &trans &trans &kp MINUS &kp EQUAL &kp LBKT &kp RBKT &kp BSLH &kp GRAVE + &kp LSHFT &trans &trans &trans &trans &trans &kp UNDER &kp PLUS &kp LBRC &kp RBRC &kp PIPE &kp TILDE + &kp LGUI &trans &kp SPACE &kp RET &trans &kp RALT + >; + }; + }; +}; diff --git a/boards/shields/corne/corne.zmk.yml b/boards/shields/corne/corne.zmk.yml new file mode 100644 index 0000000..4e20fc2 --- /dev/null +++ b/boards/shields/corne/corne.zmk.yml @@ -0,0 +1,16 @@ +file_format: "1" +id: corne +name: Corne +type: shield +url: https://github.com/foostan/crkbd/ +requires: [pro_micro] +exposes: [i2c_oled] +features: + - keys + - display + - underglow +siblings: + - corne_left + - corne_central_left + - corne_right + - corne_dongle diff --git a/boards/shields/corne/corne_central_left.conf b/boards/shields/corne/corne_central_left.conf new file mode 100644 index 0000000..e69de29 diff --git a/boards/shields/corne/corne_central_left.overlay b/boards/shields/corne/corne_central_left.overlay new file mode 100644 index 0000000..117cb19 --- /dev/null +++ b/boards/shields/corne/corne_central_left.overlay @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + +#include "corne.dtsi" + +&kscan0 { + col-gpios + = <&pro_micro 21 GPIO_ACTIVE_HIGH> + , <&pro_micro 20 GPIO_ACTIVE_HIGH> + , <&pro_micro 19 GPIO_ACTIVE_HIGH> + , <&pro_micro 18 GPIO_ACTIVE_HIGH> + , <&pro_micro 15 GPIO_ACTIVE_HIGH> + , <&pro_micro 14 GPIO_ACTIVE_HIGH> + ; +}; diff --git a/boards/shields/corne/corne_dongle.conf b/boards/shields/corne/corne_dongle.conf new file mode 100644 index 0000000..dd14f2b --- /dev/null +++ b/boards/shields/corne/corne_dongle.conf @@ -0,0 +1,2 @@ +CONFIG_BT_CTLR_TX_PWR_PLUS_8=y +CONFIG_ZMK_SLEEP=n diff --git a/boards/shields/corne/corne_dongle.overlay b/boards/shields/corne/corne_dongle.overlay new file mode 100644 index 0000000..117cb19 --- /dev/null +++ b/boards/shields/corne/corne_dongle.overlay @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + +#include "corne.dtsi" + +&kscan0 { + col-gpios + = <&pro_micro 21 GPIO_ACTIVE_HIGH> + , <&pro_micro 20 GPIO_ACTIVE_HIGH> + , <&pro_micro 19 GPIO_ACTIVE_HIGH> + , <&pro_micro 18 GPIO_ACTIVE_HIGH> + , <&pro_micro 15 GPIO_ACTIVE_HIGH> + , <&pro_micro 14 GPIO_ACTIVE_HIGH> + ; +}; diff --git a/boards/shields/corne/corne_left.conf b/boards/shields/corne/corne_left.conf new file mode 100644 index 0000000..e69de29 diff --git a/boards/shields/corne/corne_left.overlay b/boards/shields/corne/corne_left.overlay new file mode 100644 index 0000000..117cb19 --- /dev/null +++ b/boards/shields/corne/corne_left.overlay @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + +#include "corne.dtsi" + +&kscan0 { + col-gpios + = <&pro_micro 21 GPIO_ACTIVE_HIGH> + , <&pro_micro 20 GPIO_ACTIVE_HIGH> + , <&pro_micro 19 GPIO_ACTIVE_HIGH> + , <&pro_micro 18 GPIO_ACTIVE_HIGH> + , <&pro_micro 15 GPIO_ACTIVE_HIGH> + , <&pro_micro 14 GPIO_ACTIVE_HIGH> + ; +}; diff --git a/boards/shields/corne/corne_right.conf b/boards/shields/corne/corne_right.conf new file mode 100644 index 0000000..e69de29 diff --git a/boards/shields/corne/corne_right.overlay b/boards/shields/corne/corne_right.overlay new file mode 100644 index 0000000..a8a0cfe --- /dev/null +++ b/boards/shields/corne/corne_right.overlay @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + +#include "corne.dtsi" + +&default_transform { + col-offset = <6>; +}; + +&five_column_transform { + col-offset = <6>; +}; + +&kscan0 { + col-gpios + = <&pro_micro 14 GPIO_ACTIVE_HIGH> + , <&pro_micro 15 GPIO_ACTIVE_HIGH> + , <&pro_micro 18 GPIO_ACTIVE_HIGH> + , <&pro_micro 19 GPIO_ACTIVE_HIGH> + , <&pro_micro 20 GPIO_ACTIVE_HIGH> + , <&pro_micro 21 GPIO_ACTIVE_HIGH> + ; +}; diff --git a/build.yaml b/build.yaml index 781c2f9..014d9ec 100644 --- a/build.yaml +++ b/build.yaml @@ -12,3 +12,19 @@ # shield: reviung41 # --- +include: + # centrals + - board: nrf52840dk_nrf52840 + shield: corne_dongle + - board: nice_nano_v2 + shield: corne_central_left + # peripherals + - board: nice_nano_v2 + shield: corne_left + - board: nice_nano_v2 + shield: corne_right + # To reset the boards + - board: nice_nano_v2 + shield: settings_reset + - board: nrf52840dk_nrf52840 + shield: settings_reset diff --git a/config/corne.conf b/config/corne.conf new file mode 100644 index 0000000..de02fc3 --- /dev/null +++ b/config/corne.conf @@ -0,0 +1,6 @@ +# CONFIG_ZMK_SLEEP=y +# CONFIG_ZMK_IDLE_TIMEOUT=30000 +# CONFIG_ZMK_IDLE_SLEEP_TIMEOUT=900000 + +# Uncomment the following line to enable the Corne OLED Display +# CONFIG_ZMK_DISPLAY=y diff --git a/config/corne.keymap b/config/corne.keymap new file mode 100644 index 0000000..3f451ad --- /dev/null +++ b/config/corne.keymap @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include +#include + +#define DEFAULT 0 +#define LOWER 1 +#define RAISE 2 +#define NAV 3 + +// todo: +// experiment with tapping-term-ms +// try balanced vs tap-preferred +// try caps-word +// emoji key: LCMD(LCTRL(SPACE)) + +// make dongle work. +// https://github.com/zmkfirmware/zmk/tree/main/app/boards/shields/corne +// https://github.com/aroum/zmk-enki42 + +< { + quick-tap-ms = <200>; + flavor = "balanced"; +}; + +/ { + behaviors { + hm: balanced_homerow_mods { + compatible = "zmk,behavior-hold-tap"; + #binding-cells = <2>; + tapping-term-ms = <150>; + quick-tap-ms = <200>; + flavor = "balanced"; + bindings = <&kp>, <&kp>; + }; + }; + keymap { + compatible = "zmk,keymap"; + default_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 DEL +//|---------+-------------+-----------+------------+-------------+-------| |------+-------------+------------+-----------+---------------+--------| + &kp ESC &hm LCTRL A &hm LALT S &hm LCMD D &hm LSHFT F &kp G &kp H &hm RSHFT J &hm RCMD K &hm RALT L &hm RCTL SEMI &kp SQT +//|---------+-------------+-----------+------------+-------------+-------| |------+-------------+------------+-----------+---------------+--------| + &kp BSLH &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &kp FSLH &trans +//|---------+-------------+-----------+------------+-------------+-------+----| |----+------+-------------+------------+-----------+---------------+--------| + &mo NAV < LOWER SPACE < RAISE BSPC < RAISE RET < LOWER SPACE &trans + //`--------+-----------------+---------------' `---------------+-----------------+-------' + >; + }; + lower_layer { + bindings = < +//,------------------------------------------------------------. ,---------------------------------------------------------------------------------. + &gresc &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &trans +//|-------+-----------+---------+----------+-----------+-------| |------+-----------------+---------------+---------------+----------------+-------| + &trans &kp LCTRL &kp LALT &kp LCMD &kp LSHFT &trans &trans &hm RSHFT RBKT &hm RCMD LBKT &hm RALT MINUS &hm RCTL EQUAL &trans +//|-------+-----------+---------+----------+-----------+-------| |------+-----------------+---------------+---------------+----------------+-------| + &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans +//|-------+-----------+---------+----------+-----------+-------+----| |----+------+-----------------+---------------+---------------+----------------+-------| + &trans &kp SPACE &kp BSPC &kp RET &kp SPACE &trans + //`-------+-----------+---------' `--------+-----------+-------' + >; + }; + raise_layer { + bindings = < +//,----------------------------------------------------. ,-----------------------------------------------------. + &kp F12 &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 +//|--------+--------+--------+--------+--------+-------| |------+---------+--------+--------+---------+--------| + &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 SPACE &kp BSPC &kp RET &kp SPACE &trans + //`-------+-----------+---------' `--------+-----------+-------' + >; + }; + nav_layer { + bindings = < +//,-----------------------------------------------------------------. ,----------------------------------------------------------. + &kp C_RESET &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans +//|------------+-----------+---------+----------+-----------+-------| |---------+----------+--------+-----------+--------+-------| + &trans &kp LCTRL &kp LALT &kp LCMD &kp LSHFT &trans &kp LEFT &kp DOWN &kp UP &kp RIGHT &trans &trans +//|------------+-----------+---------+----------+-----------+-------| |---------+----------+--------+-----------+--------+-------| + &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans +//|------------+-----------+---------+----------+-----------+-------+----| |----+---------+----------+--------+-----------+--------+-------| + &trans &kp SPACE &kp BSPC &kp RET &kp SPACE &trans + //`-------+-----------+---------' `--------+-----------+-------' + >; + }; + }; +}; diff --git a/config/west.yml b/config/west.yml index b886cbe..379d291 100644 --- a/config/west.yml +++ b/config/west.yml @@ -2,8 +2,6 @@ manifest: remotes: - name: zmkfirmware url-base: https://github.com/zmkfirmware - # Additional modules containing boards/shields/custom code can be listed here as well - # See https://docs.zephyrproject.org/3.2.0/develop/west/manifest.html#projects projects: - name: zmk remote: zmkfirmware