diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d7011283..5470febb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,12 +3,12 @@ name: Build on: push: paths: - - ".github/workflows/build.yml" - - "app/**" + - '.github/workflows/build.yml' + - 'app/**' pull_request: paths: - - ".github/workflows/build.yml" - - "app/**" + - '.github/workflows/build.yml' + - 'app/**' jobs: build: @@ -60,7 +60,9 @@ jobs: - splitreus62_right - tg4x - tidbit - cmake-args: [""] + - helix_4_left + - helix_4_right + cmake-args: [''] include: - board: bdn9_rev2 - board: dz60rgb_rev1 @@ -124,7 +126,7 @@ jobs: if: ${{ !matrix.skip-archive }} uses: actions/upload-artifact@v2 with: - name: "${{ steps.variables.outputs.artifact-name }}" + name: '${{ steps.variables.outputs.artifact-name }}' path: | build/zephyr/zmk.hex build/zephyr/zmk.uf2 diff --git a/app/boards/shields/helix_4/Kconfig.defconfig b/app/boards/shields/helix_4/Kconfig.defconfig new file mode 100644 index 00000000..66e88cca --- /dev/null +++ b/app/boards/shields/helix_4/Kconfig.defconfig @@ -0,0 +1,48 @@ + +if SHIELD_HELIX_4_LEFT + +config ZMK_KEYBOARD_NAME + default "Helix" + +config ZMK_SPLIT_BLE_ROLE_CENTRAL + default y + +endif + + +if SHIELD_HELIX_4_RIGHT + +config ZMK_KEYBOARD_NAME + default "Helix Right" + +endif + +if SHIELD_HELIX_4_LEFT || SHIELD_HELIX_4_RIGHT + +config ZMK_SPLIT + default y + +config DEVICE_POWER_MANAGEMENT + default y + +if ZMK_RGB_UNDERGLOW + +config WS2812_STRIP + default y + +endif # ZMK_RGB_UNDERGLOW + +if ZMK_DISPLAY + +config I2C + default y + +config SSD1306 + default y + +config SSD1306_REVERSE_MODE + default y + +endif # ZMK_DISPLAY + +endif diff --git a/app/boards/shields/helix_4/Kconfig.shield b/app/boards/shields/helix_4/Kconfig.shield new file mode 100644 index 00000000..6163b752 --- /dev/null +++ b/app/boards/shields/helix_4/Kconfig.shield @@ -0,0 +1,8 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +config SHIELD_HELIX_4_LEFT + def_bool $(shields_list_contains,helix_4_left) + +config SHIELD_HELIX_4_RIGHT + def_bool $(shields_list_contains,helix_4_right) diff --git a/app/boards/shields/helix_4/boards/nice_nano.overlay b/app/boards/shields/helix_4/boards/nice_nano.overlay new file mode 100644 index 00000000..35b95239 --- /dev/null +++ b/app/boards/shields/helix_4/boards/nice_nano.overlay @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +&spi1 { + compatible = "nordic,nrf-spim"; + 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 = <25>; + spi-one-frame = <0x70>; + spi-zero-frame = <0x40>; + }; +}; + +/ { + chosen { + zmk,underglow = &led_strip; + }; +}; diff --git a/app/boards/shields/helix_4/helix_4.conf b/app/boards/shields/helix_4/helix_4.conf new file mode 100644 index 00000000..e69de29b diff --git a/app/boards/shields/helix_4/helix_4.dtsi b/app/boards/shields/helix_4/helix_4.dtsi new file mode 100644 index 00000000..374b8801 --- /dev/null +++ b/app/boards/shields/helix_4/helix_4.dtsi @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <14>; + rows = <4>; + + map = < +RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,8) RC(0,9) RC(0,10) RC(0,11) RC(0,12) RC(0,13) +RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,8) RC(1,9) RC(1,10) RC(1,11) RC(1,12) RC(1,13) +RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,8) RC(2,9) RC(2,10) RC(2,11) RC(2,12) RC(2,13) +RC(3,0) RC(3,1) 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,11) RC(3,12) RC(3,13) + >; + }; + + 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 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + }; + + bt_unpair_combo: bt_unpair_combo { + compatible = "zmk,bt-unpair-combo"; + }; +}; + +&pro_micro_i2c { + status = "okay"; + + ssd1306@3c { + compatible = "solomon,ssd1306fb"; + reg = <0x3c>; + label = "DISPLAY"; + width = <128>; + height = <32>; + segment-offset = <0>; + page-offset = <0>; + display-offset = <0>; + multiplex-ratio = <63>; + prechargep = <0x22>; + }; +}; diff --git a/app/boards/shields/helix_4/helix_4.keymap b/app/boards/shields/helix_4/helix_4.keymap new file mode 100644 index 00000000..1d8d9a90 --- /dev/null +++ b/app/boards/shields/helix_4/helix_4.keymap @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include +#include + +#define DEFAULT 0 +#define LWR 1 +#define RSE 2 +#define ADJ 3 + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { + bindings = < +&kp ESC &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BSPC +&kp TAB &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 RET +&mo ADJ &kp LCTRL &kp LALT &kp LGUI &mo LWR &kp SPACE &kp SPACE &kp SPACE &kp SPACE &mo RSE &kp LEFT &kp UP &kp DOWN &kp RIGHT + >; + }; + + lower_layer { + bindings = < +&kp TILDE &kp EXCL &kp AT &kp HASH &kp DLLR &kp PRCNT &kp CARET &kp AMPS &kp STAR &kp LPAR &kp RPAR &trans +&trans &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp MINUS &kp EQUAL &kp LBRC &kp RBRC &kp GRAVE +&trans &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &trans &trans &trans &kp PIPE &trans +&trans &trans &trans &trans &trans &trans &none &trans &trans &trans &kp HOME &kp PG_DN &kp PG_UP &kp END + >; + }; + + raise_layer { + bindings = < +&kp GRAVE &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &trans +&trans &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp UNDER &kp PLUS &kp LBKT &kp RBKT &kp RALT +&trans &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &none &trans &trans &kp BSLH &kp RSHFT +&trans &trans &trans &trans &trans &trans &trans &none &trans &trans &trans &trans &trans &kp RGUI + >; + }; + + adjust_layer { + bindings = < +&trans &reset &trans &trans &trans &trans &trans &trans &trans &trans &trans &kp DEL +&bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &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/helix_4/helix_4_left.conf b/app/boards/shields/helix_4/helix_4_left.conf new file mode 100644 index 00000000..e69de29b diff --git a/app/boards/shields/helix_4/helix_4_left.overlay b/app/boards/shields/helix_4/helix_4_left.overlay new file mode 100644 index 00000000..0ea9fe2b --- /dev/null +++ b/app/boards/shields/helix_4/helix_4_left.overlay @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include "helix_4.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 16 GPIO_ACTIVE_HIGH> + ; +}; + +&bt_unpair_combo { + key-positions = <40 42>; +}; diff --git a/app/boards/shields/helix_4/helix_4_right.conf b/app/boards/shields/helix_4/helix_4_right.conf new file mode 100644 index 00000000..e69de29b diff --git a/app/boards/shields/helix_4/helix_4_right.overlay b/app/boards/shields/helix_4/helix_4_right.overlay new file mode 100644 index 00000000..5ff34a63 --- /dev/null +++ b/app/boards/shields/helix_4/helix_4_right.overlay @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include "helix_4.dtsi" + +&default_transform { + col-offset = <7>; +}; + +&kscan0 { + col-gpios + = <&pro_micro_d 16 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 2 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 3 GPIO_ACTIVE_HIGH> + ; +}; + +&bt_unpair_combo { + key-positions = <43 45>; +}; + diff --git a/app/src/display.c b/app/src/display.c new file mode 100644 index 00000000..ecd19086 --- /dev/null +++ b/app/src/display.c @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include +#include + +#include +LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); + +#include +#include + +#define ZMK_DISPLAY_NAME CONFIG_LVGL_DISPLAY_DEV_NAME + +static struct device *display; + +static lv_obj_t *screen; + +int zmk_display_init() { + lv_obj_t *hello_world_label; + lv_obj_t *count_label; + + LOG_DBG(""); + + display = device_get_binding(ZMK_DISPLAY_NAME); + if (display == NULL) { + LOG_ERR("Failed to find display device"); + return -EINVAL; + } + + screen = lv_obj_create(NULL, NULL); + lv_scr_load(screen); + + hello_world_label = lv_label_create(lv_scr_act(), NULL); + lv_label_set_text(hello_world_label, "ZMK v0.1.0"); + lv_obj_align(hello_world_label, NULL, LV_ALIGN_CENTER, 0, 0); + count_label = lv_label_create(lv_scr_act(), NULL); + lv_label_set_text(count_label, CONFIG_ZMK_KEYBOARD_NAME); + lv_obj_align(count_label, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0); + lv_task_handler(); + display_blanking_off(display); + + return 0; +} + +void zmk_display_task_handler() { + lv_tick_inc(10); + lv_task_handler(); + k_sleep(K_MSEC(10)); +}