diff --git a/.devcontainer/.bashrc b/.devcontainer/.bashrc new file mode 100644 index 00000000..855ea755 --- /dev/null +++ b/.devcontainer/.bashrc @@ -0,0 +1,6 @@ +export LS_OPTIONS='-F --color=auto' +eval "`dircolors`" +alias ls='ls $LS_OPTIONS' +if [ -f "$WORKSPACE_DIR/zephyr/zephyr-env.sh" ]; then + source "$WORKSPACE_DIR/zephyr/zephyr-env.sh" +fi diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..184aae9a --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,11 @@ +FROM zmkfirmware/zephyr-west-action-arm + +RUN apt-get -y update && \ + apt-get -y upgrade && \ + apt-get install --no-install-recommends -y \ + ssh \ + gpg && \ + rm -rf /var/lib/apt/lists/* + +COPY .bashrc tmp +RUN mv /tmp/.bashrc ~/.bashrc diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..940b78b8 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,8 @@ +{ + "name": "ZMK Development", + "dockerFile": "Dockerfile", + "extensions": ["ms-vscode.cpptools"], + "runArgs": ["--security-opt", "label=disable"], + "containerEnv": {"WORKSPACE_DIR": "${containerWorkspaceFolder}"} +} + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 454ab796..60c337de 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -75,7 +75,7 @@ jobs: args: 'build "-s app -b ${{ matrix.board }} -- -DSHIELD=${{ matrix.shield }}"' - name: Archive Build uses: actions/upload-artifact@v2 - if: ${{ matrix.board == 'nice_nano' }} + if: ${{ matrix.board != 'proton_c' }} with: name: "${{ matrix.board }}-${{ matrix.shield }}-zmk-uf2" path: build/zephyr/zmk.uf2 diff --git a/.github/workflows/clang-format-lint.yml b/.github/workflows/clang-format-lint.yml index 061bc3da..70ae9863 100644 --- a/.github/workflows/clang-format-lint.yml +++ b/.github/workflows/clang-format-lint.yml @@ -6,11 +6,15 @@ on: - "app/boards/**/*.c" - "app/include/**/*.h" - "app/src/**" + - "app/drivers/**/*.c" + - "app/drivers/**/*.h" pull_request: paths: - "app/boards/**/*.c" - "app/include/**/*.h" - "app/src/**" + - "app/drivers/**/*.c" + - "app/drivers/**/*.h" jobs: build: diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 3e0560b7..31d28f57 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -23,6 +23,7 @@ zephyr_linker_sources(RODATA include/linker/zmk-events.ld) # Add your source file to the "app" target. This must come after # find_package(Zephyr) which defines the target. target_include_directories(app PRIVATE include) +target_sources_ifdef(CONFIG_ZMK_SLEEP app PRIVATE src/power.c) target_sources(app PRIVATE src/kscan.c) target_sources(app PRIVATE src/matrix_transform.c) target_sources(app PRIVATE src/hid.c) @@ -30,6 +31,7 @@ target_sources(app PRIVATE src/sensors.c) target_sources_ifdef(CONFIG_ZMK_DISPLAY app PRIVATE src/display.c) target_sources(app PRIVATE src/event_manager.c) target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/ble_unpair_combo.c) +target_sources_ifdef(CONFIG_ZMK_EXT_POWER app PRIVATE src/ext_power_generic.c) target_sources(app PRIVATE src/events/position_state_changed.c) target_sources(app PRIVATE src/events/keycode_state_changed.c) target_sources(app PRIVATE src/events/modifiers_state_changed.c) @@ -54,7 +56,7 @@ target_sources_ifdef(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL app PRIVATE src/split/ target_sources_ifdef(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL app PRIVATE src/split/bluetooth/central.c) target_sources_ifdef(CONFIG_ZMK_KSCAN_MOCK_DRIVER app PRIVATE src/kscan_mock.c) target_sources_ifdef(CONFIG_ZMK_KSCAN_COMPOSITE_DRIVER app PRIVATE src/kscan_composite.c) -target_sources_ifdef(CONFIG_ZMK_USB app PRIVATE src/usb_hid.c) +target_sources_ifdef(CONFIG_USB app PRIVATE src/usb.c) target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/hog.c) target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/rgb_underglow.c) target_sources(app PRIVATE src/endpoints.c) diff --git a/app/Kconfig b/app/Kconfig index ccd40da5..fca49124 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -21,12 +21,16 @@ menuconfig ZMK_USB select USB_DEVICE_STACK select USB_DEVICE_HID -if ZMK_USB +if USB config ZMK_USB_INIT_PRIORITY int "Init Priority" default 50 +endif + +if ZMK_USB + config USB_NUMOF_EP_WRITE_RETRIES default 10 @@ -72,6 +76,29 @@ endif endmenu +menuconfig ZMK_SLEEP + bool "Enable deep sleep support" + imply USB + +if ZMK_SLEEP + +config SYS_POWER_DEEP_SLEEP_STATES + default y + +choice SYS_PM_POLICY + default SYS_PM_POLICY_APP +endchoice + +config ZMK_IDLE_SLEEP_TIMEOUT + int "Milliseconds to wait to sleep when going idle" + default 900000 + +endif + +config ZMK_EXT_POWER + bool "Enable support to control external power output" + default y + config ZMK_DISPLAY bool "ZMK display support" default n @@ -108,7 +135,6 @@ config ZMK_SPLIT_BLE_ROLE_CENTRAL config ZMK_SPLIT_BLE_ROLE_PERIPHERAL bool "Peripheral" - select BT_KEYS_OVERWRITE_OLDEST if ZMK_SPLIT_BLE_ROLE_PERIPHERAL diff --git a/app/boards/arm/nice_nano/nice_nano.dts b/app/boards/arm/nice_nano/nice_nano.dts index 2e9556b8..0538b1df 100644 --- a/app/boards/arm/nice_nano/nice_nano.dts +++ b/app/boards/arm/nice_nano/nice_nano.dts @@ -29,6 +29,15 @@ }; }; + ext-power { + compatible = "zmk,ext-power-generic"; + label = "EXT_POWER"; + control-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>; + }; +}; + +&gpiote { + status = "okay"; }; &gpio0 { diff --git a/app/boards/arm/nrf52840_m2/CMakeLists.txt b/app/boards/arm/nrf52840_m2/CMakeLists.txt new file mode 100644 index 00000000..84b2ab99 --- /dev/null +++ b/app/boards/arm/nrf52840_m2/CMakeLists.txt @@ -0,0 +1,13 @@ +# +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT +# + +set_property(GLOBAL APPEND PROPERTY extra_post_build_commands + COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/../tools/uf2/utils/uf2conv.py + -c + -b 0x26000 + -f 0xADA52840 + -o ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.uf2 + ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.bin +) diff --git a/app/boards/arm/nrf52840_m2/Kconfig b/app/boards/arm/nrf52840_m2/Kconfig new file mode 100644 index 00000000..faff4925 --- /dev/null +++ b/app/boards/arm/nrf52840_m2/Kconfig @@ -0,0 +1,10 @@ +# +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT +# + +config BOARD_ENABLE_DCDC + bool "Enable DCDC mode" + select SOC_DCDC_NRF52X + default y + depends on BOARD_NRF52840_M2 diff --git a/app/boards/arm/nrf52840_m2/Kconfig.board b/app/boards/arm/nrf52840_m2/Kconfig.board new file mode 100644 index 00000000..6ade68c1 --- /dev/null +++ b/app/boards/arm/nrf52840_m2/Kconfig.board @@ -0,0 +1,10 @@ +# Maker Diary nrf52840 M.2 board configuration +# +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT +# + +config BOARD_NRF52840_M2 + bool "nrf52480_m2" + depends on SOC_NRF52840_QIAA + diff --git a/app/boards/arm/nrf52840_m2/Kconfig.defconfig b/app/boards/arm/nrf52840_m2/Kconfig.defconfig new file mode 100644 index 00000000..98fcd083 --- /dev/null +++ b/app/boards/arm/nrf52840_m2/Kconfig.defconfig @@ -0,0 +1,30 @@ +# +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT +# + +if BOARD_NRF52840_M2 + +config BOARD + default "nrf52480_m2" + +if USB + +config USB_NRFX + default y + +config USB_DEVICE_STACK + default y + +endif # USB + +config BT_CTLR + default BT + +config ZMK_BLE + default y + +config ZMK_USB + default y + +endif # BOARD_NRF52840_M2 diff --git a/app/boards/arm/nrf52840_m2/board.cmake b/app/boards/arm/nrf52840_m2/board.cmake new file mode 100644 index 00000000..55b44e27 --- /dev/null +++ b/app/boards/arm/nrf52840_m2/board.cmake @@ -0,0 +1,9 @@ +# +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT +# + +board_runner_args(nrfjprog "--nrf-family=NRF52" "--softreset") + +include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake) +include(${ZEPHYR_BASE}/boards/common/blackmagicprobe.board.cmake) diff --git a/app/boards/arm/nrf52840_m2/nrf52840_m2.dts b/app/boards/arm/nrf52840_m2/nrf52840_m2.dts new file mode 100644 index 00000000..fb5b0ff6 --- /dev/null +++ b/app/boards/arm/nrf52840_m2/nrf52840_m2.dts @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * SPDX-License-Identifier: MIT + */ + +/dts-v1/; +#include + +/ { + model = "Makerdiary nRF52840 M.2 module"; + compatible = "makerdiary,nrf52840_m2"; + + chosen { + zephyr,code-partition = &code_partition; + //zephyr,console = &uart0; + //zephyr,bt-mon-uart = &uart0; + //zephyr,bt-c2h-uart = &uart0; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + }; + + leds { + compatible = "gpio-leds"; + red_led: led_0 { + gpios = <&gpio0 30 GPIO_ACTIVE_HIGH>; + label = "Red LED"; + }; + green_led: led_1 { + gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>; + label = "Green LED"; + }; + blue_led: led_2 { + gpios = <&gpio0 31 GPIO_ACTIVE_HIGH>; + label = "Blue LED"; + }; + }; + +}; + +&gpio0 { + status = "okay"; +}; + +&gpio1 { + status = "okay"; +}; + +&uart0 { + compatible = "nordic,nrf-uart"; + status = "okay"; + current-speed = <115200>; + tx-pin = <16>; + rx-pin = <15>; + rts-pin = <14>; + cts-pin = <13>; +}; + +&usbd { + compatible = "nordic,nrf-usbd"; + status = "okay"; +}; + + +&flash0 { + /* + * For more information, see: + * http://docs.zephyrproject.org/latest/devices/dts/flash_partitions.html + */ + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@0 { + label = "adafruit_boot"; + reg = <0x000000000 0x0000C000>; + }; + code_partition: partition@26000 { + label = "code_partition"; + reg = <0x00026000 0x000d2000>; + }; + + /* + * The flash starting at 0x000f8000 and ending at + * 0x000fffff is reserved for use by the application. + */ + + /* + * Storage partition will be used by FCB/LittleFS/NVS + * if enabled. + */ + storage_partition: partition@f8000 { + label = "storage"; + reg = <0x000f8000 0x00008000>; + }; + }; +}; diff --git a/app/boards/arm/nrf52840_m2/nrf52840_m2.yaml b/app/boards/arm/nrf52840_m2/nrf52840_m2.yaml new file mode 100644 index 00000000..0a999bbf --- /dev/null +++ b/app/boards/arm/nrf52840_m2/nrf52840_m2.yaml @@ -0,0 +1,15 @@ +identifier: nrf52840_m2 +name: Makerdiary nRF52840 M.2 module +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb + - xtools +supported: + - adc + - usb_device + - ble + - ieee802154 + - pwm + - watchdog diff --git a/app/boards/arm/nrf52840_m2/nrf52840_m2_defconfig b/app/boards/arm/nrf52840_m2/nrf52840_m2_defconfig new file mode 100644 index 00000000..e74438b7 --- /dev/null +++ b/app/boards/arm/nrf52840_m2/nrf52840_m2_defconfig @@ -0,0 +1,23 @@ +# +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT +# + +CONFIG_SOC_SERIES_NRF52X=y +CONFIG_SOC_NRF52840_QIAA=y +CONFIG_BOARD_NRF52840_M2=y + +# Enable MPU +CONFIG_ARM_MPU=y + +# enable GPIO +CONFIG_GPIO=y + +CONFIG_USE_DT_CODE_PARTITION=y + +CONFIG_MPU_ALLOW_FLASH_WRITE=y +CONFIG_NVS=y +CONFIG_SETTINGS_NVS=y +CONFIG_FLASH=y +CONFIG_FLASH_PAGE_LAYOUT=y +CONFIG_FLASH_MAP=y diff --git a/app/boards/arm/nrfmicro/nrfmicro_11.dts b/app/boards/arm/nrfmicro/nrfmicro_11.dts index 95bd8adc..87c650e1 100644 --- a/app/boards/arm/nrfmicro/nrfmicro_11.dts +++ b/app/boards/arm/nrfmicro/nrfmicro_11.dts @@ -26,6 +26,11 @@ }; }; + ext-power { + compatible = "zmk,ext-power-generic"; + label = "EXT_POWER"; + control-gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>; + }; }; &gpio0 { diff --git a/app/boards/arm/nrfmicro/nrfmicro_11_flipped.dts b/app/boards/arm/nrfmicro/nrfmicro_11_flipped.dts index 85693a8b..ea15b819 100644 --- a/app/boards/arm/nrfmicro/nrfmicro_11_flipped.dts +++ b/app/boards/arm/nrfmicro/nrfmicro_11_flipped.dts @@ -26,6 +26,11 @@ }; }; + ext-power { + compatible = "zmk,ext-power-generic"; + label = "EXT_POWER"; + control-gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>; + }; }; &gpio0 { diff --git a/app/boards/arm/nrfmicro/nrfmicro_13.dts b/app/boards/arm/nrfmicro/nrfmicro_13.dts index 95bd8adc..ef439462 100644 --- a/app/boards/arm/nrfmicro/nrfmicro_13.dts +++ b/app/boards/arm/nrfmicro/nrfmicro_13.dts @@ -26,6 +26,11 @@ }; }; + ext-power { + compatible = "zmk,ext-power-generic"; + label = "EXT_POWER"; + control-gpios = <&gpio1 9 GPIO_ACTIVE_LOW>; + }; }; &gpio0 { diff --git a/app/boards/arm/nrfmicro/pinmux.c b/app/boards/arm/nrfmicro/pinmux.c index 4e330b65..30117d0f 100644 --- a/app/boards/arm/nrfmicro/pinmux.c +++ b/app/boards/arm/nrfmicro/pinmux.c @@ -14,25 +14,14 @@ static int pinmux_nrfmicro_init(struct device *port) { ARG_UNUSED(port); - struct device *p1 = device_get_binding("GPIO_1"); - #if CONFIG_BOARD_NRFMICRO_13 struct device *p0 = device_get_binding("GPIO_0"); - // enable EXT_VCC (use 0 for nRFMicro 1.3, use 1 for nRFMicro 1.1) - gpio_pin_configure(p1, 9, GPIO_OUTPUT); - gpio_pin_set(p1, 9, 0); - #if CONFIG_BOARD_NRFMICRO_CHARGER gpio_pin_configure(p0, 5, GPIO_OUTPUT); gpio_pin_set(p0, 5, 0); #else gpio_pin_configure(p0, 5, GPIO_INPUT); #endif - -#else - // enable EXT_VCC (use 0 for nRFMicro 1.3, use 1 for nRFMicro 1.1) - gpio_pin_configure(p1, 9, GPIO_OUTPUT); - gpio_pin_set(p1, 9, 1); #endif return 0; } diff --git a/app/boards/arm/planck/Kconfig.defconfig b/app/boards/arm/planck/Kconfig.defconfig index 6f5bf525..913c1c13 100644 --- a/app/boards/arm/planck/Kconfig.defconfig +++ b/app/boards/arm/planck/Kconfig.defconfig @@ -11,4 +11,7 @@ config ZMK_KEYBOARD_NAME config ZMK_USB default y +config ZMK_KSCAN_MATRIX_POLLING + default y + endif # BOARD_PLANCK_REV6 diff --git a/app/boards/shields/clueboard_california/Kconfig.defconfig b/app/boards/shields/clueboard_california/Kconfig.defconfig index 2408f9ff..e101ea76 100644 --- a/app/boards/shields/clueboard_california/Kconfig.defconfig +++ b/app/boards/shields/clueboard_california/Kconfig.defconfig @@ -8,7 +8,7 @@ config ZMK_KEYBOARD_NAME # across A & B controllers, and STM32F303CCT6 can't enable # interrutps for multiple controllers for the same "line" # for the external interrupts. -config ZMK_KSCAN_GPIO_POLLING +config ZMK_KSCAN_DIRECT_POLLING default y endif diff --git a/app/boards/shields/clueboard_california/clueboard_california.keymap b/app/boards/shields/clueboard_california/clueboard_california.keymap index 7a84b119..44a0b076 100644 --- a/app/boards/shields/clueboard_california/clueboard_california.keymap +++ b/app/boards/shields/clueboard_california/clueboard_california.keymap @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #include #include diff --git a/app/boards/shields/corne/corne.keymap b/app/boards/shields/corne/corne.keymap index 5f0f15f0..64d4a001 100644 --- a/app/boards/shields/corne/corne.keymap +++ b/app/boards/shields/corne/corne.keymap @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #include #include #include diff --git a/app/boards/shields/iris/iris.keymap b/app/boards/shields/iris/iris.keymap index 6042ad7b..8b06b1b7 100644 --- a/app/boards/shields/iris/iris.keymap +++ b/app/boards/shields/iris/iris.keymap @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Pete Johanson, Kurtis Lew + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/shields/kyria/kyria.keymap b/app/boards/shields/kyria/kyria.keymap index f689ef62..ac0d13f0 100644 --- a/app/boards/shields/kyria/kyria.keymap +++ b/app/boards/shields/kyria/kyria.keymap @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #include #include diff --git a/app/boards/shields/lily58/lily58.keymap b/app/boards/shields/lily58/lily58.keymap index 61c19f86..997a1248 100644 --- a/app/boards/shields/lily58/lily58.keymap +++ b/app/boards/shields/lily58/lily58.keymap @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #include #include #include diff --git a/app/boards/shields/m60/Kconfig.defconfig b/app/boards/shields/m60/Kconfig.defconfig new file mode 100644 index 00000000..e31d5a53 --- /dev/null +++ b/app/boards/shields/m60/Kconfig.defconfig @@ -0,0 +1,11 @@ +# +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT +# + +if SHIELD_M60 + +config ZMK_KEYBOARD_NAME + default "m60" + +endif diff --git a/app/boards/shields/m60/Kconfig.shield b/app/boards/shields/m60/Kconfig.shield new file mode 100644 index 00000000..47a28e24 --- /dev/null +++ b/app/boards/shields/m60/Kconfig.shield @@ -0,0 +1,7 @@ +# +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT +# + +config SHIELD_M60 + def_bool $(shields_list_contains,m60) diff --git a/app/boards/shields/m60/m60.conf b/app/boards/shields/m60/m60.conf new file mode 100644 index 00000000..e69de29b diff --git a/app/boards/shields/m60/m60.keymap b/app/boards/shields/m60/m60.keymap new file mode 100644 index 00000000..cbe356c2 --- /dev/null +++ b/app/boards/shields/m60/m60.keymap @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include +#include + +/ { + keymap0: keymap { + compatible = "zmk,keymap"; + + default_layer { +// ------------------------------------------------------------------------------------------ +// | ESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | BKSP | +// | TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | \ | +// | CAPS | A | S | D | F | G | H | J | K | L | ; | ' | ENTER | +// | SHIFT | Z | X | C | V | B | N | M | , | . | / | SHIFT | +// | CTL | WIN | ALT | SPACE | ALT | MO(1) | WIN | CTRL | +// ------------------------------------------------------------------------------------------ + 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 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 CLCK &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 LSFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT + &kp LCTL &kp LGUI &kp LALT &kp SPC &kp RALT &mo 1 &kp RGUI &kp RCTL + >; + }; + + fn_layer { + bindings = < +&kp GRAV &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &bootloader +&trans &bt BT_CLR &none &none &none &none &none &none &none &none &none &none &none &reset +&trans &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &kp LARW &kp DARW &kp UARW &kp RARW &none &none &trans +&trans &none &none &none &none &none &none &none &none &none &none &trans +&trans &trans &trans &trans &trans &trans &trans &trans + >; + }; + }; +}; diff --git a/app/boards/shields/m60/m60.overlay b/app/boards/shields/m60/m60.overlay new file mode 100644 index 00000000..babae2db --- /dev/null +++ b/app/boards/shields/m60/m60.overlay @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + + diode-direction = "col2row"; + row-gpios + = <&gpio0 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpio0 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpio0 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpio0 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpio1 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpio1 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpio0 12 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpio0 11 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + col-gpios + = <&gpio0 19 GPIO_ACTIVE_HIGH> + , <&gpio0 20 GPIO_ACTIVE_HIGH> + , <&gpio0 21 GPIO_ACTIVE_HIGH> + , <&gpio0 22 GPIO_ACTIVE_HIGH> + , <&gpio0 23 GPIO_ACTIVE_HIGH> + , <&gpio0 24 GPIO_ACTIVE_HIGH> + , <&gpio0 25 GPIO_ACTIVE_HIGH> + , <&gpio0 26 GPIO_ACTIVE_HIGH> + ; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <8>; + rows = <8>; +// | MX1 | MX2 | MX3 | MX4 | MX5 | MX6 | MX7 | MX8 | MX9 | MX10 | MX11 | MX12 | MX13 | MX14 | +// | MX15 | MX16 | MX17 | MX18 | MX19 | MX20 | MX21 | MX22 | MX23 | MX24 | MX25 | MX26 | MX27 | MX28 | +// | MX29 | MX30 | MX31 | MX32 | MX33 | MX34 | MX35 | MX36 | MX37 | MX38 | MX39 | MX40 | MX41 | +// | MX42 | MX43 | MX44 | MX45 | MX46 | MX47 | MX48 | MX49 | MX50 | MX51 | MX52 | MX53 | +// | MX54 | MX55 | MX56 | MX57 | MX58 | MX59 | MX60 | MX61 | + 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(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) +RC(3,3) RC(3,2) RC(3,1) RC(3,0) RC(2,7) RC(2,6) RC(2,5) RC(2,4) RC(2,3) RC(2,2) RC(2,1) RC(2,0) RC(1,7) RC(1,6) +RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,4) RC(4,5) RC(4,6) RC(4,7) RC(5,0) +RC(6,4) RC(6,3) RC(6,2) RC(6,1) RC(6,0) RC(5,7) RC(5,6) RC(5,5) RC(5,4) RC(5,3) RC(5,2) RC(5,1) +RC(6,5) RC(6,6) RC(6,7) RC(7,0) RC(7,1) RC(7,2) RC(7,3) RC(7,4) + >; + }; + + bt_unpair_combo: bt_unpair_combo { + compatible = "zmk,bt-unpair-combo"; + key-positions = <0 53>; + }; + +}; + diff --git a/app/boards/shields/m60/readme.md b/app/boards/shields/m60/readme.md new file mode 100644 index 00000000..e801c788 --- /dev/null +++ b/app/boards/shields/m60/readme.md @@ -0,0 +1,14 @@ +# [Makerdiary M60](https://wiki.makerdiary.com/m60) + +A 60% ANSI keyboard designed and manufactured by Makerdiary. +http://makerdiary.com + +## Features + +- Per key RGB LED. +- Uses makerdiary M.2 nRF52840 module +- Matrix wiring + +## Hardware Notes + +https://wiki.makerdiary.com/m60/developer_guide/hardware/ diff --git a/app/boards/shields/microdox/Kconfig.defconfig b/app/boards/shields/microdox/Kconfig.defconfig new file mode 100644 index 00000000..4840eceb --- /dev/null +++ b/app/boards/shields/microdox/Kconfig.defconfig @@ -0,0 +1,60 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +if SHIELD_MICRODOX_LEFT + +config ZMK_KEYBOARD_NAME + default "Microdox Left" + +endif + + +if SHIELD_MICRODOX_RIGHT + +config ZMK_KEYBOARD_NAME + default "Microdox Right" + +endif + +if SHIELD_MICRODOX_LEFT || SHIELD_MICRODOX_RIGHT + +config ZMK_SPLIT + default y + +if ZMK_DISPLAY + +config I2C + default y + +config SSD1306 + default y + +config SSD1306_REVERSE_MODE + default y + +endif # ZMK_DISPLAY + +if LVGL + +config LVGL_HOR_RES + default 128 + +config LVGL_VER_RES + default 32 + +config LVGL_VDB_SIZE + default 64 + +config LVGL_DPI + default 148 + +config LVGL_BITS_PER_PIXEL + default 1 + +choice LVGL_COLOR_DEPTH + default LVGL_COLOR_DEPTH_1 +endchoice + +endif # LVGL + +endif diff --git a/app/boards/shields/microdox/Kconfig.shield b/app/boards/shields/microdox/Kconfig.shield new file mode 100644 index 00000000..ac79eab6 --- /dev/null +++ b/app/boards/shields/microdox/Kconfig.shield @@ -0,0 +1,8 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +config SHIELD_MICRODOX_LEFT + def_bool $(shields_list_contains,microdox_left) + +config SHIELD_MICRODOX_RIGHT + def_bool $(shields_list_contains,microdox_right) diff --git a/app/boards/shields/microdox/boards/nice_nano.overlay b/app/boards/shields/microdox/boards/nice_nano.overlay new file mode 100644 index 00000000..58cd8613 --- /dev/null +++ b/app/boards/shields/microdox/boards/nice_nano.overlay @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ +&spi1 { + compatible = "nordic,nrf-spi"; + /* Cannot be used together with i2c0. */ + 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 = "SK6812mini"; + + /* SPI */ + reg = <0>; /* ignored, but necessary for SPI bindings */ + spi-max-frequency = <4000000>; + + /* WS2812 */ + chain-length = <6>; /* There are per-key RGB, but the first 6 are underglow */ + spi-one-frame = <0x70>; + spi-zero-frame = <0x40>; + }; +}; + +/ { + chosen { + zmk,underglow = &led_strip; + }; +}; diff --git a/app/boards/shields/microdox/microdox.conf b/app/boards/shields/microdox/microdox.conf new file mode 100644 index 00000000..b79385bd --- /dev/null +++ b/app/boards/shields/microdox/microdox.conf @@ -0,0 +1,6 @@ +# Uncomment the following lines to enable the Corne RGB Underglow +# ZMK_RGB_UNDERGLOW=y +# CONFIG_WS2812_STRIP=y + +# Uncomment the following line to enable the Corne OLED Display +# CONFIG_ZMK_DISPLAY=y diff --git a/app/boards/shields/microdox/microdox.dtsi b/app/boards/shields/microdox/microdox.dtsi new file mode 100644 index 00000000..55c67dd3 --- /dev/null +++ b/app/boards/shields/microdox/microdox.dtsi @@ -0,0 +1,66 @@ +/* + * 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 = <10>; + rows = <4>; +// | SW1 | SW2 | SW3 | SW4 | SW5 | | SW5 | SW4 | SW3 | SW2 | SW1 | +// | SW6 | SW7 | SW8 | SW9 | SW10 | | SW10 | SW9 | SW8 | SW7 | SW6 | +// | SW11 | SW12 | SW13 | SW14 | SW15 | | SW15 | SW14 | SW13 | SW12 | SW11 | +// | SW16 | SW17 | SW18 | | SW18 | SW17 | SW16 | + 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(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(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(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) + >; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + + diode-direction = "col2row"; + row-gpios + = <&pro_micro_d 16 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 10 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 9 (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>; + label = "DISPLAY"; + 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/app/boards/shields/microdox/microdox.keymap b/app/boards/shields/microdox/microdox.keymap new file mode 100644 index 00000000..5747771b --- /dev/null +++ b/app/boards/shields/microdox/microdox.keymap @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { +// ----------------------------------------------------------------------------------------- +// | Q | W | E | R | T | | Y | U | I | O | P | +// | A | S | D | F | G | | H | J | K | L | ; | +// | Z | X | C | V | B | | N | M | , | . | / | +// | GUI | NAV | SHFT | | SPC | SYM | ALT | + bindings = < + &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P + &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SCLN + &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH + &kp LGUI &mo 1 &kp LSFT &kp SPC &mo 2 &kp RALT + >; + }; + nav_layer { +// ----------------------------------------------------------------------------------------- +// |BTCLR| | ESC | ~ | | | TAB | HOME | UP | END | DEL | +// | BT1 | GUI | ALT | CTRL | NUM | | / | LEFT | DOWN | RGT | BKSP | +// | BT2 | | | | | | \ | ENT | | | | +// | | | | | | | | + bindings = < + &bt BT_CLR &trans &kp ESC &kp TILD &trans &kp TAB &kp HOME &kp UARW &kp END &kp DEL + &bt BT_SEL 0 &kp GUI &kp RALT &kp LCTL &mo 3 &kp FSLH &kp LARW &kp DARW &kp RARW &kp BKSP + &bt BT_SEL 1 &trans &trans &trans &trans &kp BSLH &kp RET &trans &trans &trans + &trans &trans &trans &trans &trans &trans + >; + }; + + sym_layer { +// ----------------------------------------------------------------------------------------- +// | ! | @ | # | $ | % | | ^ | & | * | ( | ) | +// | | | | | | | - | = | { | } | "|" | +// | | | | | | | _ | + | [ | ] | \ | +// | GUI | | SPC | | ENT | | ALT | + bindings = < + &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN + &trans &trans &trans &trans &trans &kp MINUS &kp EQL &kp LBKT &kp RBKT &kp PIPE + &trans &trans &trans &trans &trans &trans &trans &trans &trans &kp BSLH + &kp LGUI &trans &kp SPC &kp RET &trans &kp RALT + >; + }; + +// This layer is unreachable until "tri layer state" is sorted out. +// Leaving it here for completeness. + num_layer { +// ----------------------------------------------------------------------------------------- +// | | | | | | | A | 7 | 8 | 9 | D | +// | | | | | | | B | 4 | 5 | 6 | E | +// | | | | | | | C | 1 | 2 | 3 | F | +// | | | | | 0 | . | | + bindings = < + &trans &trans &trans &trans &trans &kp A &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp D + &trans &trans &trans &trans &trans &kp B &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp E + &trans &trans &trans &trans &trans &kp C &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp F + &trans &trans &trans &kp NUM_0 &kp DOT &trans + >; + }; + }; +}; + diff --git a/app/boards/shields/microdox/microdox_left.conf b/app/boards/shields/microdox/microdox_left.conf new file mode 100644 index 00000000..1e028a78 --- /dev/null +++ b/app/boards/shields/microdox/microdox_left.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/boards/shields/microdox/microdox_left.overlay b/app/boards/shields/microdox/microdox_left.overlay new file mode 100644 index 00000000..4d0378e5 --- /dev/null +++ b/app/boards/shields/microdox/microdox_left.overlay @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include "microdox.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> + ; +}; diff --git a/app/boards/shields/microdox/microdox_right.conf b/app/boards/shields/microdox/microdox_right.conf new file mode 100644 index 00000000..990cf7c0 --- /dev/null +++ b/app/boards/shields/microdox/microdox_right.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/microdox/microdox_right.overlay b/app/boards/shields/microdox/microdox_right.overlay new file mode 100644 index 00000000..c5622b25 --- /dev/null +++ b/app/boards/shields/microdox/microdox_right.overlay @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include "microdox.dtsi" + +&default_transform { + col-offset = <5>; +}; + +&kscan0 { + col-gpios + = <&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> + ; +}; diff --git a/app/boards/shields/romac/romac.keymap b/app/boards/shields/romac/romac.keymap index 97ea9c54..31e1ce82 100644 --- a/app/boards/shields/romac/romac.keymap +++ b/app/boards/shields/romac/romac.keymap @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Pete Johanson, Richard Jones + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/shields/sofle/sofle.keymap b/app/boards/shields/sofle/sofle.keymap index 1cbe742c..e2ebc1aa 100644 --- a/app/boards/shields/sofle/sofle.keymap +++ b/app/boards/shields/sofle/sofle.keymap @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #include #include #include diff --git a/app/boards/shields/splitreus62/splitreus62.keymap b/app/boards/shields/splitreus62/splitreus62.keymap index 920e61ad..07dd2ad6 100644 --- a/app/boards/shields/splitreus62/splitreus62.keymap +++ b/app/boards/shields/splitreus62/splitreus62.keymap @@ -1,9 +1,10 @@ /* - * Copyright (c) 2020 Derek Schmell + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ + #include #include diff --git a/app/drivers/zephyr/Kconfig b/app/drivers/zephyr/Kconfig index 0237846a..0534cab2 100644 --- a/app/drivers/zephyr/Kconfig +++ b/app/drivers/zephyr/Kconfig @@ -5,10 +5,14 @@ config ZMK_KSCAN_GPIO_DRIVER if ZMK_KSCAN_GPIO_DRIVER -config ZMK_KSCAN_GPIO_POLLING - bool "Poll for key event triggers instead of using interrupts" +config ZMK_KSCAN_MATRIX_POLLING + bool "Poll for key event triggers instead of using interrupts on matrix boards." default n +config ZMK_KSCAN_DIRECT_POLLING + bool "Poll for key event triggers instead of using interrupts on direct wired boards." + default n + endif config ZMK_KSCAN_INIT_PRIORITY diff --git a/app/drivers/zephyr/ec11.c b/app/drivers/zephyr/ec11.c index a4e96c24..00d00905 100644 --- a/app/drivers/zephyr/ec11.c +++ b/app/drivers/zephyr/ec11.c @@ -142,7 +142,7 @@ int ec11_init(struct device *dev) { .b_flags = DT_INST_GPIO_FLAGS(n, b_gpios), \ COND_CODE_0(DT_INST_NODE_HAS_PROP(n, resolution), (1), (DT_INST_PROP(n, resolution))), \ }; \ - DEVICE_AND_API_INIT(ec11, DT_INST_LABEL(n), ec11_init, &ec11_data_##n, &ec11_cfg_##n, \ + DEVICE_AND_API_INIT(ec11_##n, DT_INST_LABEL(n), ec11_init, &ec11_data_##n, &ec11_cfg_##n, \ POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY, &ec11_driver_api); DT_INST_FOREACH_STATUS_OKAY(EC11_INST) \ No newline at end of file diff --git a/app/drivers/zephyr/kscan_gpio_direct.c b/app/drivers/zephyr/kscan_gpio_direct.c index 1e5ab59e..4818c995 100644 --- a/app/drivers/zephyr/kscan_gpio_direct.c +++ b/app/drivers/zephyr/kscan_gpio_direct.c @@ -33,9 +33,9 @@ struct kscan_gpio_config { }; struct kscan_gpio_data { -#if defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) +#if defined(CONFIG_ZMK_KSCAN_DIRECT_POLLING) struct k_timer poll_timer; -#endif /* defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */ +#endif /* defined(CONFIG_ZMK_KSCAN_DIRECT_POLLING) */ kscan_callback_t callback; union work_reference work; struct device *dev; @@ -53,7 +53,7 @@ static const struct kscan_gpio_item_config *kscan_gpio_input_configs(struct devi return cfg->inputs; } -#if !defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) +#if !defined(CONFIG_ZMK_KSCAN_DIRECT_POLLING) struct kscan_gpio_irq_callback { union work_reference *work; @@ -101,7 +101,7 @@ static void kscan_gpio_irq_callback_handler(struct device *dev, struct gpio_call } } -#else /* !defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */ +#else /* !defined(CONFIG_ZMK_KSCAN_DIRECT_POLLING) */ static void kscan_gpio_timer_handler(struct k_timer *timer) { struct kscan_gpio_data *data = CONTAINER_OF(timer, struct kscan_gpio_data, poll_timer); @@ -120,7 +120,7 @@ static int kscan_gpio_direct_disable(struct device *dev) { return 0; } -#endif /* defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */ +#endif /* defined(CONFIG_ZMK_KSCAN_DIRECT_POLLING) */ static int kscan_gpio_direct_configure(struct device *dev, kscan_callback_t callback) { struct kscan_gpio_data *data = dev->driver_data; @@ -173,7 +173,7 @@ static const struct kscan_driver_api gpio_driver_api = { #define INST_INPUT_LEN(n) DT_INST_PROP_LEN(n, input_gpios) #define GPIO_INST_INIT(n) \ - COND_CODE_0(CONFIG_ZMK_KSCAN_GPIO_POLLING, \ + COND_CODE_0(IS_ENABLED(CONFIG_ZMK_KSCAN_DIRECT_POLLING), \ (static struct kscan_gpio_irq_callback irq_callbacks_##n[INST_INPUT_LEN(n)];), ()) \ static struct kscan_gpio_data kscan_gpio_data_##n = { \ .inputs = {[INST_INPUT_LEN(n) - 1] = NULL}}; \ @@ -195,7 +195,7 @@ static const struct kscan_driver_api gpio_driver_api = { return err; \ } \ COND_CODE_0( \ - CONFIG_ZMK_KSCAN_GPIO_POLLING, \ + IS_ENABLED(CONFIG_ZMK_KSCAN_DIRECT_POLLING), \ (irq_callbacks_##n[i].work = &data->work; \ irq_callbacks_##n[i].debounce_period = cfg->debounce_period; \ gpio_init_callback(&irq_callbacks_##n[i].callback, \ @@ -208,7 +208,7 @@ static const struct kscan_driver_api gpio_driver_api = { ()) \ } \ data->dev = dev; \ - COND_CODE_1(CONFIG_ZMK_KSCAN_GPIO_POLLING, \ + COND_CODE_1(IS_ENABLED(CONFIG_ZMK_KSCAN_DIRECT_POLLING), \ (k_timer_init(&data->poll_timer, kscan_gpio_timer_handler, NULL);), ()) \ if (cfg->debounce_period > 0) { \ k_delayed_work_init(&data->work.delayed, kscan_gpio_work_handler); \ @@ -227,4 +227,4 @@ static const struct kscan_driver_api gpio_driver_api = { DT_INST_FOREACH_STATUS_OKAY(GPIO_INST_INIT) -#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ \ No newline at end of file +#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ diff --git a/app/drivers/zephyr/kscan_gpio_matrix.c b/app/drivers/zephyr/kscan_gpio_matrix.c index 634f694c..a0b22e4a 100644 --- a/app/drivers/zephyr/kscan_gpio_matrix.c +++ b/app/drivers/zephyr/kscan_gpio_matrix.c @@ -31,6 +31,7 @@ struct kscan_gpio_item_config { #define _KSCAN_GPIO_ROW_CFG_INIT(idx, n) _KSCAN_GPIO_ITEM_CFG_INIT(n, row_gpios, idx) #define _KSCAN_GPIO_COL_CFG_INIT(idx, n) _KSCAN_GPIO_ITEM_CFG_INIT(n, col_gpios, idx) +#if !defined(CONFIG_ZMK_KSCAN_MATRIX_POLLING) static int kscan_gpio_config_interrupts(struct device **devices, const struct kscan_gpio_item_config *configs, size_t len, gpio_flags_t flags) { @@ -48,6 +49,8 @@ static int kscan_gpio_config_interrupts(struct device **devices, return 0; } +#endif + #define INST_MATRIX_ROWS(n) DT_INST_PROP_LEN(n, row_gpios) #define INST_MATRIX_COLS(n) DT_INST_PROP_LEN(n, col_gpios) #define INST_OUTPUT_LEN(n) \ @@ -61,6 +64,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, struct kscan_gpio_irq_callback_##n { \ struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) * work; \ struct gpio_callback callback; \ + struct device *dev; \ }; \ static struct kscan_gpio_irq_callback_##n irq_callbacks_##n[INST_INPUT_LEN(n)]; \ struct kscan_gpio_config_##n { \ @@ -69,6 +73,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, }; \ struct kscan_gpio_data_##n { \ kscan_callback_t callback; \ + COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (struct k_timer poll_timer;), ()) \ struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) work; \ bool matrix_state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)]; \ struct device *rows[INST_MATRIX_ROWS(n)]; \ @@ -96,21 +101,25 @@ static int kscan_gpio_config_interrupts(struct device **devices, return ( \ COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->rows), (cfg->cols))); \ } \ - static int kscan_gpio_enable_interrupts_##n(struct device *dev) { \ - return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ - kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ - GPIO_INT_DEBOUNCE | GPIO_INT_EDGE_BOTH); \ - } \ - static int kscan_gpio_disable_interrupts_##n(struct device *dev) { \ - return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ - kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ - GPIO_INT_DISABLE); \ - } \ + COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), \ + ( \ + static int kscan_gpio_enable_interrupts_##n(struct device *dev) { \ + return kscan_gpio_config_interrupts( \ + kscan_gpio_input_devices_##n(dev), kscan_gpio_input_configs_##n(dev), \ + INST_INPUT_LEN(n), GPIO_INT_LEVEL_ACTIVE); \ + } static int kscan_gpio_disable_interrupts_##n(struct device *dev) { \ + return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ + kscan_gpio_input_configs_##n(dev), \ + INST_INPUT_LEN(n), GPIO_INT_DISABLE); \ + })) \ static void kscan_gpio_set_output_state_##n(struct device *dev, int value) { \ + int err; \ for (int i = 0; i < INST_OUTPUT_LEN(n); i++) { \ struct device *in_dev = kscan_gpio_output_devices_##n(dev)[i]; \ const struct kscan_gpio_item_config *cfg = &kscan_gpio_output_configs_##n(dev)[i]; \ - gpio_pin_set(in_dev, cfg->pin, value); \ + if ((err = gpio_pin_set(in_dev, cfg->pin, value))) { \ + LOG_DBG("FAILED TO SET OUTPUT %d to %d", cfg->pin, err); \ + } \ } \ } \ static void kscan_gpio_set_matrix_state_##n( \ @@ -128,7 +137,6 @@ static int kscan_gpio_config_interrupts(struct device **devices, /* Disable our interrupts temporarily while we scan, to avoid */ \ /* re-entry while we iterate columns and set them active one by one */ \ /* to get pressed state for each matrix cell. */ \ - kscan_gpio_disable_interrupts_##n(dev); \ kscan_gpio_set_output_state_##n(dev, 0); \ for (int o = 0; o < INST_OUTPUT_LEN(n); o++) { \ struct device *out_dev = kscan_gpio_output_devices_##n(dev)[o]; \ @@ -143,10 +151,8 @@ static int kscan_gpio_config_interrupts(struct device **devices, } \ gpio_pin_set(out_dev, out_cfg->pin, 0); \ } \ - /* Set all our outputs as active again, then re-enable interrupts, */ \ - /* so we can trigger interrupts again for future press/release */ \ + /* Set all our outputs as active again. */ \ kscan_gpio_set_output_state_##n(dev, 1); \ - kscan_gpio_enable_interrupts_##n(dev); \ for (int r = 0; r < INST_MATRIX_ROWS(n); r++) { \ for (int c = 0; c < INST_MATRIX_COLS(n); c++) { \ bool pressed = read_state[r][c]; \ @@ -165,6 +171,9 @@ static int kscan_gpio_config_interrupts(struct device **devices, k_delayed_work_cancel(&data->work); \ k_delayed_work_submit(&data->work, K_MSEC(5)); \ })) \ + } else { \ + COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), \ + (kscan_gpio_enable_interrupts_##n(dev);)) \ } \ return 0; \ } \ @@ -172,16 +181,20 @@ static int kscan_gpio_config_interrupts(struct device **devices, struct kscan_gpio_data_##n *data = CONTAINER_OF(work, struct kscan_gpio_data_##n, work); \ kscan_gpio_read_##n(data->dev); \ } \ - static void kscan_gpio_irq_callback_handler_##n(struct device *dev, struct gpio_callback *cb, \ - gpio_port_pins_t pin) { \ - struct kscan_gpio_irq_callback_##n *data = \ - CONTAINER_OF(cb, struct kscan_gpio_irq_callback_##n, callback); \ - COND_CODE_0(DT_INST_PROP(n, debounce_period), ({ k_work_submit(data->work); }), ({ \ - k_delayed_work_cancel(data->work); \ - k_delayed_work_submit(data->work, \ - K_MSEC(DT_INST_PROP(n, debounce_period))); \ - })) \ - } \ + COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), \ + (static void kscan_gpio_irq_callback_handler_##n( \ + struct device *dev, struct gpio_callback *cb, gpio_port_pins_t pin) { \ + struct kscan_gpio_irq_callback_##n *data = \ + CONTAINER_OF(cb, struct kscan_gpio_irq_callback_##n, callback); \ + kscan_gpio_disable_interrupts_##n(data->dev); \ + COND_CODE_0(DT_INST_PROP(n, debounce_period), \ + ({ k_work_submit(data->work); }), ({ \ + k_delayed_work_cancel(data->work); \ + k_delayed_work_submit( \ + data->work, K_MSEC(DT_INST_PROP(n, debounce_period))); \ + })) \ + })) \ + \ static struct kscan_gpio_data_##n kscan_gpio_data_##n = { \ .rows = {[INST_MATRIX_ROWS(n) - 1] = NULL}, .cols = {[INST_MATRIX_COLS(n) - 1] = NULL}}; \ static int kscan_gpio_configure_##n(struct device *dev, kscan_callback_t callback) { \ @@ -190,15 +203,29 @@ static int kscan_gpio_config_interrupts(struct device **devices, return -EINVAL; \ } \ data->callback = callback; \ + LOG_DBG("Configured GPIO %d", n); \ return 0; \ }; \ static int kscan_gpio_enable_##n(struct device *dev) { \ - int err = kscan_gpio_enable_interrupts_##n(dev); \ - if (err) { \ - return err; \ - } \ - return kscan_gpio_read_##n(dev); \ + COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ + (struct kscan_gpio_data_##n *data = dev->driver_data; \ + k_timer_start(&data->poll_timer, K_MSEC(10), K_MSEC(10)); return 0;), \ + (int err = kscan_gpio_enable_interrupts_##n(dev); \ + if (err) { return err; } return kscan_gpio_read_##n(dev);)) \ + }; \ + static int kscan_gpio_disable_##n(struct device *dev) { \ + COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ + (struct kscan_gpio_data_##n *data = dev->driver_data; \ + k_timer_stop(&data->poll_timer); return 0;), \ + (return kscan_gpio_disable_interrupts_##n(dev);)) \ }; \ + COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ + (static void kscan_gpio_timer_handler(struct k_timer *timer) { \ + struct kscan_gpio_data_##n *data = \ + CONTAINER_OF(timer, struct kscan_gpio_data_##n, poll_timer); \ + k_work_submit(&data->work.work); \ + }), \ + ()) \ static int kscan_gpio_init_##n(struct device *dev) { \ struct kscan_gpio_data_##n *data = dev->driver_data; \ int err; \ @@ -214,8 +241,11 @@ static int kscan_gpio_config_interrupts(struct device **devices, if (err) { \ LOG_ERR("Unable to configure pin %d on %s for input", in_cfg->pin, in_cfg->label); \ return err; \ + } else { \ + LOG_DBG("Configured pin %d on %s for input", in_cfg->pin, in_cfg->label); \ } \ irq_callbacks_##n[i].work = &data->work; \ + irq_callbacks_##n[i].dev = dev; \ gpio_init_callback(&irq_callbacks_##n[i].callback, \ kscan_gpio_irq_callback_handler_##n, BIT(in_cfg->pin)); \ err = gpio_add_callback(input_devices[i], &irq_callbacks_##n[i].callback); \ @@ -241,6 +271,8 @@ static int kscan_gpio_config_interrupts(struct device **devices, } \ } \ data->dev = dev; \ + COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ + (k_timer_init(&data->poll_timer, kscan_gpio_timer_handler, NULL);), ()) \ (COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work_init), (k_delayed_work_init)))( \ &data->work, kscan_gpio_work_handler_##n); \ return 0; \ @@ -248,7 +280,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, static const struct kscan_driver_api gpio_driver_api_##n = { \ .config = kscan_gpio_configure_##n, \ .enable_callback = kscan_gpio_enable_##n, \ - .disable_callback = kscan_gpio_disable_interrupts_##n, \ + .disable_callback = kscan_gpio_disable_##n, \ }; \ static const struct kscan_gpio_config_##n kscan_gpio_config_##n = { \ .rows = {UTIL_LISTIFY(INST_MATRIX_ROWS(n), _KSCAN_GPIO_ROW_CFG_INIT, n)}, \ diff --git a/app/dts/bindings/behaviors/zmk,behavior-sensor-rotate-key-press.yaml b/app/dts/bindings/behaviors/zmk,behavior-sensor-rotate-key-press.yaml index bbf35373..6b339107 100644 --- a/app/dts/bindings/behaviors/zmk,behavior-sensor-rotate-key-press.yaml +++ b/app/dts/bindings/behaviors/zmk,behavior-sensor-rotate-key-press.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2020, Pete Johanson +# Copyright (c) 2020, The ZMK Contributors # SPDX-License-Identifier: MIT description: Sensor rotate key press/release behavior diff --git a/app/dts/bindings/zmk,ext-power-generic.yaml b/app/dts/bindings/zmk,ext-power-generic.yaml new file mode 100644 index 00000000..5a38a09a --- /dev/null +++ b/app/dts/bindings/zmk,ext-power-generic.yaml @@ -0,0 +1,20 @@ +# +# Copyright (c) 2020, The ZMK Contributors +# SPDX-License-Identifier: MIT +# + +description: | + Generic driver for controlling the external power output + by toggling the control-gpio pin status + (Only in supported hardware) + +compatible: "zmk,ext-power-generic" + +properties: + control-gpios: + type: phandle-array + required: true + label: + type: string + required: true + diff --git a/app/dts/bindings/zmk,keymap-sensors.yaml b/app/dts/bindings/zmk,keymap-sensors.yaml index c56361d1..86ae5c22 100644 --- a/app/dts/bindings/zmk,keymap-sensors.yaml +++ b/app/dts/bindings/zmk,keymap-sensors.yaml @@ -1,3 +1,8 @@ +# +# Copyright (c) 2020, The ZMK Contributors +# SPDX-License-Identifier: MIT +# + description: | Allows defining the collection of sensors bound in the keymap layers diff --git a/app/include/drivers/ext_power.h b/app/include/drivers/ext_power.h new file mode 100644 index 00000000..6c1923e8 --- /dev/null +++ b/app/include/drivers/ext_power.h @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#pragma once + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @cond INTERNAL_HIDDEN + * + * Behavior driver API definition and system call entry points. + * + * (Internal use only.) + */ + +typedef int (*ext_power_enable_t)(struct device *dev); +typedef int (*ext_power_disable_t)(struct device *dev); +typedef int (*ext_power_get_t)(struct device *dev); + +__subsystem struct ext_power_api { + ext_power_enable_t enable; + ext_power_disable_t disable; + ext_power_get_t get; +}; +/** + * @endcond + */ + +/** + * @brief Enable the external power output + * @param dev Pointer to the device structure for the driver instance. + * + * @retval 0 If successful. + * @retval Negative errno code if failure. + */ +__syscall int ext_power_enable(struct device *dev); + +static inline int z_impl_ext_power_enable(struct device *dev) { + const struct ext_power_api *api = (const struct ext_power_api *)dev->driver_api; + + if (api->enable == NULL) { + return -ENOTSUP; + } + + return api->enable(dev); +} + +/** + * @brief Disable the external power output + * @param dev Pointer to the device structure for the driver instance. + * + * @retval 0 If successful. + * @retval Negative errno code if failure. + */ +__syscall int ext_power_disable(struct device *dev); + +static inline int z_impl_ext_power_disable(struct device *dev) { + const struct ext_power_api *api = (const struct ext_power_api *)dev->driver_api; + + if (api->disable == NULL) { + return -ENOTSUP; + } + + return api->disable(dev); +} + +/** + * @brief Get the current status of the external power output + * @param dev Pointer to the device structure for the driver instance. + * + * @retval 0 If ext power is disabled. + * @retval 1 if ext power is enabled. + * @retval Negative errno code if failure. + */ +__syscall int ext_power_get(struct device *dev); + +static inline int z_impl_ext_power_get(struct device *dev) { + const struct ext_power_api *api = (const struct ext_power_api *)dev->driver_api; + + if (api->get == NULL) { + return -ENOTSUP; + } + + return api->get(dev); +} + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#include diff --git a/app/include/dt-bindings/zmk/bt.h b/app/include/dt-bindings/zmk/bt.h index 05fd65c8..a403d35d 100644 --- a/app/include/dt-bindings/zmk/bt.h +++ b/app/include/dt-bindings/zmk/bt.h @@ -18,4 +18,4 @@ defines these aliases up front. #define BT_CLR BT_CLR_CMD 0 #define BT_NXT BT_NXT_CMD 0 #define BT_PRV BT_PRV_CMD 0 -#define BT_SEL BT_SEL_CMD \ No newline at end of file +#define BT_SEL BT_SEL_CMD diff --git a/app/include/dt-bindings/zmk/keys.h b/app/include/dt-bindings/zmk/keys.h index d3dd6341..a3b22297 100644 --- a/app/include/dt-bindings/zmk/keys.h +++ b/app/include/dt-bindings/zmk/keys.h @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ #pragma once diff --git a/app/include/dt-bindings/zmk/kscan-mock.h b/app/include/dt-bindings/zmk/kscan-mock.h index d481899f..eff218b2 100644 --- a/app/include/dt-bindings/zmk/kscan-mock.h +++ b/app/include/dt-bindings/zmk/kscan-mock.h @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #pragma once #define ZMK_MOCK_IS_PRESS(v) ((v & (0x01 << 31)) != 0) diff --git a/app/include/dt-bindings/zmk/matrix-transform.h b/app/include/dt-bindings/zmk/matrix-transform.h index 4fd3e6c9..2989cb60 100644 --- a/app/include/dt-bindings/zmk/matrix-transform.h +++ b/app/include/dt-bindings/zmk/matrix-transform.h @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ #define KT_ROW(item) (item >> 8) #define KT_COL(item) (item & 0xFF) diff --git a/app/include/dt-bindings/zmk/rgb.h b/app/include/dt-bindings/zmk/rgb.h index c2efda88..eb721807 100644 --- a/app/include/dt-bindings/zmk/rgb.h +++ b/app/include/dt-bindings/zmk/rgb.h @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ #define RGB_TOG 0 #define RGB_HUI 1 diff --git a/app/include/zmk/split/bluetooth/service.h b/app/include/zmk/split/bluetooth/service.h index 954e0cdd..c2be512f 100644 --- a/app/include/zmk/split/bluetooth/service.h +++ b/app/include/zmk/split/bluetooth/service.h @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #pragma once int zmk_split_bt_position_pressed(u8_t position); diff --git a/app/include/zmk/split/bluetooth/uuid.h b/app/include/zmk/split/bluetooth/uuid.h index a8dfbf62..a31884d9 100644 --- a/app/include/zmk/split/bluetooth/uuid.h +++ b/app/include/zmk/split/bluetooth/uuid.h @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #pragma once #include diff --git a/app/include/zmk/usb_hid.h b/app/include/zmk/usb.h similarity index 73% rename from app/include/zmk/usb_hid.h rename to app/include/zmk/usb.h index 7ee26298..452fd54d 100644 --- a/app/include/zmk/usb_hid.h +++ b/app/include/zmk/usb.h @@ -12,6 +12,8 @@ #include #include -int zmk_usb_hid_init(); +enum usb_dc_status_code zmk_usb_get_status(); +#ifdef CONFIG_ZMK_USB int zmk_usb_hid_send_report(u8_t *report, size_t len); +#endif /* CONFIG_ZMK_USB */ \ No newline at end of file diff --git a/app/src/endpoints.c b/app/src/endpoints.c index ae785870..79d294ef 100644 --- a/app/src/endpoints.c +++ b/app/src/endpoints.c @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include diff --git a/app/src/ext_power_generic.c b/app/src/ext_power_generic.c new file mode 100644 index 00000000..48170304 --- /dev/null +++ b/app/src/ext_power_generic.c @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#define DT_DRV_COMPAT zmk_ext_power_generic + +#include +#include +#include +#include + +#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) + +#include +LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); + +struct ext_power_generic_config { + const char *label; + const u8_t pin; + const u8_t flags; +}; + +struct ext_power_generic_data { + struct device *gpio; + bool status; +}; + +static int ext_power_generic_enable(struct device *dev) { + struct ext_power_generic_data *data = dev->driver_data; + const struct ext_power_generic_config *config = dev->config_info; + + if (gpio_pin_set(data->gpio, config->pin, 1)) { + LOG_WRN("Failed to set ext-power control pin"); + return -EIO; + } + data->status = true; + return 0; +} + +static int ext_power_generic_disable(struct device *dev) { + struct ext_power_generic_data *data = dev->driver_data; + const struct ext_power_generic_config *config = dev->config_info; + + if (gpio_pin_set(data->gpio, config->pin, 0)) { + LOG_WRN("Failed to clear ext-power control pin"); + return -EIO; + } + data->status = false; + return 0; +} + +static int ext_power_generic_get(struct device *dev) { + struct ext_power_generic_data *data = dev->driver_data; + return data->status; +} + +static int ext_power_generic_init(struct device *dev) { + struct ext_power_generic_data *data = dev->driver_data; + const struct ext_power_generic_config *config = dev->config_info; + + data->gpio = device_get_binding(config->label); + if (data->gpio == NULL) { + LOG_ERR("Failed to get ext-power control device"); + return -EINVAL; + } + + if (gpio_pin_configure(data->gpio, config->pin, config->flags | GPIO_OUTPUT)) { + LOG_ERR("Failed to configure ext-power control pin"); + return -EIO; + } + + return 0; +} + +static const struct ext_power_generic_config config = { + .label = DT_INST_GPIO_LABEL(0, control_gpios), + .pin = DT_INST_GPIO_PIN(0, control_gpios), + .flags = DT_INST_GPIO_FLAGS(0, control_gpios)}; + +static struct ext_power_generic_data data = {.status = false}; + +static const struct ext_power_api api = {.enable = ext_power_generic_enable, + .disable = ext_power_generic_disable, + .get = ext_power_generic_get}; + +DEVICE_AND_API_INIT(ext_power_generic, DT_INST_LABEL(0), ext_power_generic_init, &data, &config, + APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &api); + +#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ diff --git a/app/src/kscan_composite.c b/app/src/kscan_composite.c index 02491407..f8e8d604 100644 --- a/app/src/kscan_composite.c +++ b/app/src/kscan_composite.c @@ -38,8 +38,7 @@ struct kscan_composite_data { }; static int kscan_composite_enable_callback(struct device *dev) { - for (int i = 0; i < sizeof(kscan_composite_children) / sizeof(kscan_composite_children[0]); - i++) { + for (int i = 0; i < ARRAY_SIZE(kscan_composite_children); i++) { const struct kscan_composite_child_config *cfg = &kscan_composite_children[i]; kscan_enable_callback(device_get_binding(cfg->label)); @@ -48,8 +47,7 @@ static int kscan_composite_enable_callback(struct device *dev) { } static int kscan_composite_disable_callback(struct device *dev) { - for (int i = 0; i < sizeof(kscan_composite_children) / sizeof(kscan_composite_children[0]); - i++) { + for (int i = 0; i < ARRAY_SIZE(kscan_composite_children); i++) { const struct kscan_composite_child_config *cfg = &kscan_composite_children[i]; kscan_disable_callback(device_get_binding(cfg->label)); @@ -63,8 +61,7 @@ static void kscan_composite_child_callback(struct device *child_dev, u32_t row, struct device *dev = device_get_binding(DT_INST_LABEL(0)); struct kscan_composite_data *data = dev->driver_data; - for (int i = 0; i < sizeof(kscan_composite_children) / sizeof(kscan_composite_children[0]); - i++) { + for (int i = 0; i < ARRAY_SIZE(kscan_composite_children); i++) { const struct kscan_composite_child_config *cfg = &kscan_composite_children[i]; if (device_get_binding(cfg->label) != child_dev) { @@ -82,8 +79,7 @@ static int kscan_composite_configure(struct device *dev, kscan_callback_t callba return -EINVAL; } - for (int i = 0; i < sizeof(kscan_composite_children) / sizeof(kscan_composite_children[0]); - i++) { + for (int i = 0; i < ARRAY_SIZE(kscan_composite_children); i++) { const struct kscan_composite_child_config *cfg = &kscan_composite_children[i]; kscan_config(device_get_binding(cfg->label), &kscan_composite_child_callback); diff --git a/app/src/main.c b/app/src/main.c index dca923e9..0551356d 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -15,16 +15,25 @@ LOG_MODULE_REGISTER(zmk, CONFIG_ZMK_LOG_LEVEL); #include #include #include +#include #define ZMK_KSCAN_DEV DT_LABEL(ZMK_MATRIX_NODE_ID) void main(void) { + struct device *ext_power; LOG_INF("Welcome to ZMK!\n"); if (zmk_kscan_init(ZMK_KSCAN_DEV) != 0) { return; } + // Enable the external VCC output + ext_power = device_get_binding("EXT_POWER"); + if (ext_power != NULL) { + const struct ext_power_api *ext_power_api = ext_power->driver_api; + ext_power_api->enable(ext_power); + } + #ifdef CONFIG_ZMK_DISPLAY zmk_display_init(); diff --git a/app/src/power.c b/app/src/power.c new file mode 100644 index 00000000..73b3f123 --- /dev/null +++ b/app/src/power.c @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include +#include + +#include + +LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); + +#include +#include +#include +#include + +static u32_t power_last_uptime; + +#define MAX_IDLE_MS CONFIG_ZMK_IDLE_SLEEP_TIMEOUT + +bool is_usb_power_present() { +#ifdef CONFIG_USB + enum usb_dc_status_code usb_status = zmk_usb_get_status(); + switch (usb_status) { + case USB_DC_DISCONNECTED: + case USB_DC_UNKNOWN: + return false; + default: + return true; + } +#else + return false; +#endif /* CONFIG_USB */ +} + +enum power_states sys_pm_policy_next_state(s32_t ticks) { +#ifdef CONFIG_SYS_POWER_DEEP_SLEEP_STATES +#ifdef CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_1 + s32_t current = k_uptime_get(); + if (power_last_uptime > 0 && !is_usb_power_present() && + current - power_last_uptime > MAX_IDLE_MS) { + return SYS_POWER_STATE_DEEP_SLEEP_1; + } +#endif /* CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_1 */ +#endif /* CONFIG_SYS_POWER_DEEP_SLEEP_STATES */ + + return SYS_POWER_STATE_ACTIVE; +} + +int power_event_listener(const struct zmk_event_header *eh) { + power_last_uptime = k_uptime_get(); + + return 0; +} + +int power_init() { + power_last_uptime = k_uptime_get(); + + return 0; +} + +ZMK_LISTENER(power, power_event_listener); +ZMK_SUBSCRIPTION(power, position_state_changed); +ZMK_SUBSCRIPTION(power, sensor_event); + +SYS_INIT(power_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); \ No newline at end of file diff --git a/app/src/usb_hid.c b/app/src/usb.c similarity index 77% rename from app/src/usb_hid.c rename to app/src/usb.c index 530ffea8..434b3d4d 100644 --- a/app/src/usb_hid.c +++ b/app/src/usb.c @@ -18,6 +18,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); static enum usb_dc_status_code usb_status = USB_DC_UNKNOWN; +#ifdef CONFIG_ZMK_USB + static struct device *hid_dev; static K_SEM_DEFINE(hid_sem, 1, 1); @@ -49,11 +51,16 @@ int zmk_usb_hid_send_report(const u8_t *report, size_t len) { } } -void usb_hid_status_cb(enum usb_dc_status_code status, const u8_t *params) { usb_status = status; }; +#endif /* CONFIG_ZMK_USB */ + +enum usb_dc_status_code zmk_usb_get_status() { return usb_status; } -static int zmk_usb_hid_init(struct device *_arg) { +void usb_status_cb(enum usb_dc_status_code status, const u8_t *params) { usb_status = status; }; + +static int zmk_usb_init(struct device *_arg) { int usb_enable_ret; +#ifdef CONFIG_ZMK_USB hid_dev = device_get_binding("HID_0"); if (hid_dev == NULL) { LOG_ERR("Unable to locate HID device"); @@ -64,7 +71,9 @@ static int zmk_usb_hid_init(struct device *_arg) { usb_hid_init(hid_dev); - usb_enable_ret = usb_enable(usb_hid_status_cb); +#endif /* CONFIG_ZMK_USB */ + + usb_enable_ret = usb_enable(usb_status_cb); if (usb_enable_ret != 0) { LOG_ERR("Unable to enable USB"); @@ -74,4 +83,4 @@ static int zmk_usb_hid_init(struct device *_arg) { return 0; } -SYS_INIT(zmk_usb_hid_init, APPLICATION, CONFIG_ZMK_USB_INIT_PRIORITY); +SYS_INIT(zmk_usb_init, APPLICATION, CONFIG_ZMK_USB_INIT_PRIORITY); diff --git a/docs/docs/assets/dev-setup/vscode_devcontainer.png b/docs/docs/assets/dev-setup/vscode_devcontainer.png new file mode 100644 index 00000000..e5c22b0a Binary files /dev/null and b/docs/docs/assets/dev-setup/vscode_devcontainer.png differ diff --git a/docs/docs/assets/troubleshooting/filetransfer/mac.png b/docs/docs/assets/troubleshooting/filetransfer/mac.png new file mode 100644 index 00000000..f28ca8d7 Binary files /dev/null and b/docs/docs/assets/troubleshooting/filetransfer/mac.png differ diff --git a/docs/docs/behavior/bluetooth.md b/docs/docs/behavior/bluetooth.md index f802a9a2..be0fb23c 100644 --- a/docs/docs/behavior/bluetooth.md +++ b/docs/docs/behavior/bluetooth.md @@ -24,7 +24,7 @@ Here is a table describing the command for each define: | Define | Action | | ------------ | ---------------------------------------------------------------------------------------------- | -| `BT_CLR_CMD` | Clear bond information between the keyboard and host for the selected profile [^1] | +| `BT_CLR_CMD` | Clear bond information between the keyboard and host for the selected profile. | | `BT_NXT_CMD` | Switch to the next profile, cycling through to the first one when the end is reached. | | `BT_PRV_CMD` | Switch to the previous profile, cycling through to the last one when the beginning is reached. | | `BT_SEL_CMD` | Select the 0-indexed profile by number. | @@ -66,7 +66,7 @@ The bluetooth behavior completes an bluetooth action given on press. 1. Behavior binding to select the previous profile: ``` - &bt BT_NXT + &bt BT_PRV ``` 1. Behavior binding to select the 2nd profile (passed parameters are [zero based](https://en.wikipedia.org/wiki/Zero-based_numbering)): diff --git a/docs/docs/bond-reset.md b/docs/docs/bond-reset.md index 1ba79ee0..504fd72a 100644 --- a/docs/docs/bond-reset.md +++ b/docs/docs/bond-reset.md @@ -1,7 +1,7 @@ --- id: bond-reset -title: Reset BLE Connections -sidebar_label: BLE Reset +title: Reset BLE Connections (DEPRECATED) +sidebar_label: BLE Reset (DEPRECATED) --- Known as a 'bond reset', each keyboard has a special key combination independent of the user defined key map which will diff --git a/docs/docs/dev-build.md b/docs/docs/dev-build.md index 816468e2..83ed8cb9 100644 --- a/docs/docs/dev-build.md +++ b/docs/docs/dev-build.md @@ -84,6 +84,19 @@ west build -d build/right -b nice_nano -- -DSHIELD=kyria_right ``` This produces `left` and `right` subfolders under the `build` directory and two separate .uf2 files. For future work on a specific half, use the `-d` parameter again to ensure you are building into the correct location. +### Building from `zmk-config` Folder + +Instead of building .uf2 files using the default keymap and config files, you can build directly from your [`zmk-config` folder](user-setup#github-repo) by adding +`-DZMK_CONFIG="C:/the/absolute/path/config"` to your `west build` command. **Notice that this path should point to the folder labelled `config` within your `zmk-config` folder.** + + +For instance, building kyria firmware from a user `myUser`'s `zmk-config` folder on Windows 10 may look something like this: + +``` +west build -b nice_nano -- -DSHIELD=kyria_left -DZMK_CONFIG="C:/Users/myUser/Documents/Github/zmk-config/config" +``` + + ## Flashing Once built, the previously supplied parameters will be remembered so you can run the following to flash your diff --git a/docs/docs/dev-clean-room.md b/docs/docs/dev-clean-room.md index c11171c8..2f301ec7 100644 --- a/docs/docs/dev-clean-room.md +++ b/docs/docs/dev-clean-room.md @@ -6,7 +6,7 @@ sidebar_label: Clean Room :::warning -Anyone wanting to contribute code to ZMK _must_ read this, and adhere to the steps outlines in order to not violate any licenses/copyright of other projects +Anyone wanting to contribute code to ZMK _MUST_ read this, and adhere to the steps outlines in order to not violate any licenses/copyright of other projects ::: @@ -22,8 +22,8 @@ or duplicating any of the GPL code found in those other projects, even though th Contributors to ZMK must adhere to the following standard. -- Implementations of features for ZMK _MUST_ not reuse any existing code from any projects not licensed with the MIT license. -- Contributors _MUST_ not study or refer to any GPL licensed source code while working on ZMK. +- Implementations of features for ZMK _MUST NOT_ reuse any existing code from any projects not licensed with the MIT license. +- Contributors _MUST NOT_ study or refer to any GPL licensed source code while working on ZMK. - Contributors _MAY_ read the documentation from other GPL licensed projects, to gain a broad understanding of the behavior of certain features in order to implement equivalent features for ZMK. - Contributors _MAY_ refer to the [QMK Configurator](https://config.qmk.fm/) to inspect existing layouts/keymaps for keyboards, and re-implement them for ZMK. diff --git a/docs/docs/dev-guide-new-shield.md b/docs/docs/dev-guide-new-shield.md index 01aad30c..1ba572c5 100644 --- a/docs/docs/dev-guide-new-shield.md +++ b/docs/docs/dev-guide-new-shield.md @@ -238,7 +238,6 @@ If building locally for split boards, you may need to add these lines to the spe In your device tree file you will need to add the following lines to define the encoder sensor: - ``` left_encoder: encoder_left { compatible = "alps,ec11"; @@ -248,6 +247,7 @@ left_encoder: encoder_left { resolution = <4>; }; ``` + Here you will have to replace PIN_A and PIN_B with the appropriate pins that your PCB utilizes for the encoder(s). For keyboards that use the Pro Micro or any of the Pro Micro replacements, Sparkfun's [Pro Micro Hookup Guide](https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/hardware-overview-pro-micro) has a pinout diagram that can be useful to determine the right pins. Reference either the blue numbers labeled "Arduino" (digital pins) or the green numbers labeled "Analog" (analog pins). For pins that are labeled as both digital and analog, refer to your specific board's .dtsi file to determine how you should refer to that pin. Add additional encoders as necessary by duplicating the above lines, replacing `left` with whatever you would like to call your encoder, and updating the pins. Note that support for peripheral (right) side sensors over BLE is still in progress. @@ -279,12 +279,15 @@ For split keyboards, make sure to add left hand encoders to the left .overlay fi -Add the following line to your keymap file to add default encoder behavior bindings: +Add the following line to each layer of your keymap file to add default encoder behavior bindings: ``` sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD>; ``` -Add additional bindings as necessary to match the default number of encoders on your board. See the [Encoders](/docs/feature/encoders) and [Keymap](/docs/feature/keymaps) feature documentation for more details. + +This should be placed after the regular key bindings but within the layer (see the [Default Keymap section](/docs/dev-guide-new-shield#default-keymap) above for an example of where). + +Add additional bindings as necessary to match the default number of encoders on your board. Details on the syntax can be found in the [Encoders](/docs/feature/encoders) and [Keymap](/docs/feature/keymaps) feature documentation. @@ -333,6 +336,7 @@ jobs: - board: proton_c shield: clueboard_california ``` + :::note Notice that both the left and right halves of a split board need to be added to the list of shields for proper error checking. :::note diff --git a/docs/docs/dev-setup.md b/docs/docs/dev-setup.md index 1d7d703b..114fe0b3 100644 --- a/docs/docs/dev-setup.md +++ b/docs/docs/dev-setup.md @@ -12,16 +12,17 @@ groupId="operating-systems" defaultValue="debian" values={[ {label: 'Debian/Ubuntu', value: 'debian'}, -{label: 'Raspberry OS', value: 'raspberryos'}, -{label: 'Fedora', value: 'fedora'}, {label: 'Windows', value: 'win'}, {label: 'macOS', value: 'mac'}, +{label: 'Raspberry OS', value: 'raspberryos'}, +{label: 'Fedora', value: 'fedora'}, +{label: 'VS Code & Docker', value: 'docker'}, ] }>{props.children}); ## Prerequisites -A unix-like environment with the following base packages installed: +ZMK requires the following base packages to first be installed: - Git - Python 3 @@ -34,6 +35,7 @@ A unix-like environment with the following base packages installed: + On Debian and Ubuntu, we'll use `apt` to install our base dependencies: First, if you haven't updated recently, or if this is a new install, @@ -74,7 +76,8 @@ or download and install CMake version 3.13.1 or newer manually. ::: -On Raspberry OS, we'll use apt to install our base dependencies: + +On Raspberry OS, we'll use `apt` to install our base dependencies: First, if you haven't updated recently, or if this is a new install, you should update to get the latest package information: @@ -176,6 +179,20 @@ Homebrew is required to install the system dependencies. If you haven't done so, brew install cmake ninja python3 ccache dtc git wget ``` + + + +This setup leverages the same [image which is used by the GitHub action](https://github.com/zmkfirmware/zephyr-west-action) for local development. Beyond the benefits of [dev/prod parity](https://12factor.net/dev-prod-parity), this approach is also the easiest to set up. No toolchain or dependencies are necessary when using Docker; the container image you'll be using already has the toolchain installed and set up to use. + + +1. Install [Docker Desktop](https://www.docker.com/products/docker-desktop) for your operating system. +2. Install [VS Code](https://code.visualstudio.com/) +3. Install the [Remote - Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) + +:::info +The docker container includes `west` and the compilation toolchain. If you're using docker and VS Code, you can skip right to [Source Code](#source-code). +::: + @@ -185,14 +202,40 @@ brew install cmake ninja python3 ccache dtc git wget `west` is the [Zephyr™ meta-tool](https://docs.zephyrproject.org/2.3.0/guides/west/index.html) used to configure and build Zephyr™ applications. -West can be installed by using the `pip` python package manager. +West can be installed by using the `pip` python package manager. The [Zephyr™ instructions](https://docs.zephyrproject.org/latest/guides/west/install.html#installing-west) are summarized here: + + + ```sh pip3 install --user -U west ``` -:::danger pip user packages -If you haven't done so yet, you may need to add the Python Pip user package directory to your `PATH` otherwise your computer will not be able to find the `west` command. + + + +In `cmd.exe` as **Administrator**: + +```sh +pip3 install -U west +``` + +:::note +**For Windows, do not use the `--user` argument** that Linux uses otherwise `west` will be installed in a different location and the below instructions for adding Python `pip` will no longer apply. +::: + +Once `west` is installed, close Command Prompt and open a new session as a **user** for the remainder of the instructions. + + + + +:::danger `pip` user packages +If you haven't done so yet, you may need to add the Python `pip` package directory to your `PATH` otherwise your computer will not be able to find the `west` command. ::: 1. See the [Environment Variables](#environment-variables) section on how to get to the Environment Variables page. -3. Click "Edit..." and then "New" to add the directory where your west.exe is located. By default this should be something like `C:\Python38\Scripts`. +2. Under "System variables" select the "Path" variable. Click "Edit..." and then "New" to add the directory where your `west.exe` is located. By default this should be `C:\Python##\Scripts` where ## is your Python version number. +3. Close Command Prompt and open a new session for the changes to take effect, or run `refreshenv`. @@ -279,7 +323,7 @@ The installation will prompt with several questions about installation location, #### GNU ARM Embedded -Since the Zephyr™ SDK is not available for Windows, we recommending following the steps to install the [GNU ARM Embedded](https://docs.zephyrproject.org/2.3.0/getting_started/toolchain_3rd_party_x_compilers.html#gnu-arm-embedded). +Since the Zephyr™ SDK is not available for Windows, we recommending following the [Zephyr documentation](https://docs.zephyrproject.org/2.3.0/getting_started/toolchain_3rd_party_x_compilers.html#gnu-arm-embedded) to install a GNU ARM Embedded build. Note the warnings regarding installing the toolchain into a path with spaces, and make sure to follow the steps to add the environment variables which are also summarized with screenshots in the [Environment Variables](#environment-variables) section below. @@ -308,7 +352,7 @@ The transient instructions must be run to build firmware using the current shell ### Source Code -Next, you'll need to clone the ZMK source repository if you haven't already: +Next, you'll need to clone the ZMK source repository if you haven't already. Navigate to the folder you would like to place your `zmk` directory in and run the following command: ``` git clone https://github.com/zmkfirmware/zmk.git @@ -320,12 +364,63 @@ Since ZMK is built as a Zephyr™ application, the next step is to use `west` to initialize and update your workspace. The ZMK Zephyr™ application is in the `app/` source directory: + #### Step into the repository + + + +```sh +cd zmk +``` + + + + +```sh +cd zmk +``` + + + + +```sh +cd zmk +``` + + + + ```sh cd zmk ``` + + + +```sh +cd zmk +``` + + + + + +Open the `zmk` checkout folder in VS Code. The repository includes a configuration for containerized development, so an alert will pop up: + +![VS Code Dev Container Configuration Alert](assets/dev-setup/vscode_devcontainer.png) + +Click `Reopen in Container` in order to reopen the VS Code with the running container. + +The first time you do this on your machine, it will pull the docker image down from the registry and build the container. Subsequent launches are much faster! + +:::caution +All subsequent steps must be performed from the VS Code terminal _inside_ the container. +::: + + + + #### Initialize West ```sh @@ -344,6 +439,17 @@ section again for links to how to do this west update ``` +:::tip +This step pulls down quite a bit of tooling. Go grab a cup of coffee, it can take 10-15 minutes even on a good internet connection! +::: + +:::info +If you're using Docker, you're done with setup! You must restart the container at this point. The easiest way to do so is to close the VS Code window, verify that the container has stopped in Docker Dashboard, and reopen the container with VS Code. + +Once your container is restarted, proceed to [Building and Flashing](./dev-build.md). +::: + + #### Export Zephyr™ Core ```sh @@ -358,12 +464,17 @@ pip3 install --user -r zephyr/scripts/requirements-base.txt ### Environment Variables -#### For GNU ARM Embedded on Windows + + -On Windows, you will have to set two environment variables for ZMK to build properly: `ZEPHYR_TOOLCHAIN_VARIANT` and `GNUARMEMB_TOOLCHAIN_PATH`. +#### For GNU ARM Embedded on Windows -
- Steps to Update Environment Variables +On Windows, only two environment variables need to be set for ZMK to build properly: `ZEPHYR_TOOLCHAIN_VARIANT` and `GNUARMEMB_TOOLCHAIN_PATH`. 1. Open Start Menu and type 'env' to find the 'Edit the system environment variables' option. Open it. @@ -381,11 +492,15 @@ On Windows, you will have to set two environment variables for ZMK to build prop ![Adding Zephyr toolchain variable](assets/env-var/zephyr_toolchain.png) -5. Create another variable with variable name 'GNUARMEMB_TOOLCHAIN_PATH' and value set to wherever you installed your toolchain. Click OK to save. +5. Create another variable with variable name 'GNUARMEMB_TOOLCHAIN_PATH' and value set to wherever you installed your toolchain. **Make sure this path does not contain any spaces.** If it does, rename the folder and update here. Click OK to save. ![Adding GNUARMEMB variable](assets/env-var/gnuarmemb.png) -
+6. Close Command Prompt and reopen, or run `refreshenv` to apply the changes. + +
+ + #### For Zephyr @@ -396,48 +511,10 @@ We suggest two main [options](https://docs.zephyrproject.org/2.3.0/guides/env_va To load the Zephyr environment properly for just one transient shell, run the following from your ZMK checkout directory: - - - -``` -source zephyr/zephyr-env.sh -``` - - - - - -``` -source zephyr/zephyr-env.sh -``` - - - - - -``` -source zephyr/zephyr-env.sh -``` - - - - - ``` source zephyr/zephyr-env.sh ``` - - - - -``` -source zephyr/zephyr-env.cmd -``` - - - - ##### All Shells To load the environment variables for your shell every time, @@ -469,3 +546,7 @@ cat ~/.zephyrrc >> ~/.zshrc
+ +
+ + diff --git a/docs/docs/feature/encoders.md b/docs/docs/feature/encoders.md index 38ff9d31..9caccc2f 100644 --- a/docs/docs/feature/encoders.md +++ b/docs/docs/feature/encoders.md @@ -41,4 +41,4 @@ Here, the left encoder is configured to control volume up and down while the rig ## Adding Encoder Support -See the [New Keyboard Shield](/docs/dev-guide-new-shield) documentation for how to add or modify additional encoders to your shield. +See the [New Keyboard Shield](/docs/dev-guide-new-shield#encoders) documentation for how to add or modify additional encoders to your shield. diff --git a/docs/docs/hardware.md b/docs/docs/hardware.md index 236aa972..faac57c6 100644 --- a/docs/docs/hardware.md +++ b/docs/docs/hardware.md @@ -16,7 +16,7 @@ That being said, there are currently only a few specific [boards](/docs/faq#what ## Boards -- [nice!nano](https://docs.nicekeyboards.com/#/nice!nano/) (`nice_nano`) +- [nice!nano](https://nicekeyboards.com/products/nice-nano-v1-0) (`nice_nano`) - [nrfMicro](https://github.com/joric/nrfmicro) (`nrfmicro_13`, `nrfmicro_11`, `nrfmicro_11_flipped`) - [BlueMicro840](https://store.jpconstantineau.com/#/group/bluemicro) (`bluemicro840_v1`) - [QMK Proton-C](https://qmk.fm/proton-c/) (`proton_c`) diff --git a/docs/docs/troubleshooting.md b/docs/docs/troubleshooting.md index deb89b64..36682e7f 100644 --- a/docs/docs/troubleshooting.md +++ b/docs/docs/troubleshooting.md @@ -19,6 +19,10 @@ Variations of the warnings shown below occur when flashing the `.uf2` | :-------------------------------------------------------------------------------: | | An example of the file transfer error on Linux | +| ![Example Error Screen](../docs/assets/troubleshooting/filetransfer/mac.png) | +| :-------------------------------------------------------------------------------: | +| An example of the file transfer error on MacOS | + ### CMake Error @@ -59,3 +63,20 @@ After opening the `.dts.pre.tmp:` and scrolling down to the | ![Healthy Keymap Temp](../docs/assets/troubleshooting/keymaps/healthyEDIT.png) | | :-------------------------------------------------------------------------------: | | A properly defined keymap with successful compilation. As shown in red, the corrected keycode (`&kp SPC`) references the proper Usage ID defined in the [USB HID Usage Tables](https://www.usb.org/document-library/hid-usage-tables-12)| + +### Split Keyboard Halves Unable to Pair + +Previously, pairing split keyboard halves involved a **BLE Reset** via a combination of held keys that removed all bluetooth profile information from the keyboard. +Since then, a much simpler procedure of performing a bluetooth reset for split keyboards has come about, without the need for any file modification: + +**New Procedure:** + +1. Log into Github and download the "settings clear" UF2 image from the [latest build in Github Actions](https://github.com/zmkfirmware/zmk/actions?query=workflow%3ABuild+branch%3Amain) +1. Put each half of the split keyboard into bootloader mode +1. Flash one of the halves of the split with the "settings clear" UF2 image from step 1. Immediately after flashing "settings clear" to the chosen half, immediately put it into bootloader mode +to avoid accidental bonding between the halves. +1. Repeat step 3 with the other half of the split keyboard +1. Flash the actual image for each half of the split keyboard (e.g `my_board_left.uf2` to the left half, `my_board_right.uf2` to the right half) + +After completing these steps, pair the halves of the split keyboard together by resetting them at the same time. Most commonly, this is done by grounding the reset pins +for each of your keyboard's microcontrollers or pressing the reset buttons at the same time. \ No newline at end of file diff --git a/docs/sidebars.js b/docs/sidebars.js index ace7fa17..93ce2264 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -6,7 +6,6 @@ module.exports = { "faq", "user-setup", "customization", - "bond-reset", "troubleshooting" ], Features: [ diff --git a/docs/static/setup.ps1 b/docs/static/setup.ps1 index 3946e66c..abdb6981 100644 --- a/docs/static/setup.ps1 +++ b/docs/static/setup.ps1 @@ -63,8 +63,8 @@ $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" +$options = "nice!nano", "QMK Proton-C", "BlueMicro840 (v1)", "makerdiary nRF52840 M.2" +$boards = "nice_nano", "proton_c", "bluemicro840_v1", "nrf52840_m2" Write-Host "$title" Write-Host "" @@ -78,9 +78,9 @@ 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" +$options = "Kyria", "Lily58", "Corne", "Splitreus62", "Sofle", "Iris", "RoMac", "makerdiary M60", "Microdox" +$names = "kyria", "lily58", "corne", "splitreus62", "sofle", "iris", "romac", "m60", "microdox" +$splits = "y", "y", "y", "y", "y", "y", "n", "n", "y" $choice = Get-Choice-From-Options -Options $options -Prompt $prompt $shield_title = $($options[$choice]) diff --git a/docs/static/setup.sh b/docs/static/setup.sh index 5bf36451..49ed3eb2 100644 --- a/docs/static/setup.sh +++ b/docs/static/setup.sh @@ -26,7 +26,7 @@ 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)") +options=("nice!nano" "QMK Proton-C" "BlueMicro840 (v1)" "makerdiary nRF52840 M.2") echo "$title" echo "" @@ -39,6 +39,7 @@ select opt in "${options[@]}" "Quit"; do 1 ) board="nice_nano"; break;; 2 ) board="proton_c"; break;; 3 ) board="bluemicro840_v1"; break;; + 3 ) board="nrf52840_m2"; break;; $(( ${#options[@]}+1 )) ) echo "Goodbye!"; exit 1;; *) echo "Invalid option. Try another one."; continue;; @@ -50,7 +51,7 @@ echo "" echo "Keyboard Shield Selection:" prompt="Pick an keyboard:" -options=("Kyria" "Lily58" "Corne" "Splitreus62" "Sofle" "Iris" "RoMac") +options=("Kyria" "Lily58" "Corne" "Splitreus62" "Sofle" "Iris" "RoMac" "makerdiary M60" "Microdox") PS3="$prompt " # TODO: Add support for "Other" and linking to docs on adding custom shields in user config repos. @@ -66,6 +67,8 @@ select opt in "${options[@]}" "Quit"; do 5 ) shield_title="Sofle" shield="sofle"; split="y"; break;; 6 ) shield_title="Iris" shield="iris"; split="y"; break;; 7 ) shield_title="RoMac" shield="romac"; split="n"; break;; + 8 ) shield_title="M60" shield="m60"; split="n"; break;; + 9 ) shield_title="Microdox" shield="microdox"; split="y"; break;; # Add link to docs on adding your own custom shield in your ZMK config! # $(( ${#options[@]}+1 )) ) echo "Other!"; break;;