From 1addfb97695a7600fc88c29b1d351ea0ec390650 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Sun, 24 Jan 2021 01:05:30 -0500 Subject: [PATCH 1/4] feat(blog): Add SOTF #4 --- docs/blog/2021-01-27-zmk-sotf-4.md | 194 +++++++++++++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 docs/blog/2021-01-27-zmk-sotf-4.md diff --git a/docs/blog/2021-01-27-zmk-sotf-4.md b/docs/blog/2021-01-27-zmk-sotf-4.md new file mode 100644 index 00000000..bbbabdcb --- /dev/null +++ b/docs/blog/2021-01-27-zmk-sotf-4.md @@ -0,0 +1,194 @@ +--- +title: "ZMK State Of The Firmware #4" +author: Pete Johanson +author_title: Project Creator +author_url: https://gitlab.com/petejohanson +author_image_url: https://www.gravatar.com/avatar/2001ceff7e9dc753cf96fcb2e6f41110 +tags: [SOTF, keyboards, firmware, oss, ble] +--- + +Welcome to the fourth ZMK "State Of The Firmware" (SOTF)! + +This update will cover all the major activity since [SOTF #3](/blog/2020/11/09/zmk-sotf-3). + +## Recent Activity + +Here's a summary of the various major changes since last time, broken down by theme: + +### Keymaps/Behaviors + +Since last time, there have been several new powerful keymap features and behaviors added, including one of the most asked for features, combos! + +#### Combos + +The initial [combos](/docs/behaviors/combos) work has landed! The amazing [okke-formsma] has once again delivered another powerful feature for ZMK. Combos are "position based", and are configured in a new toplevel node next to they `keymap` node in user's keymap files. + +An example, that would send the `ESC` keycode when pressing both the first and second positions on your keyboard: + +``` +/ { + combos { + compatible = "zmk,combos"; + combo_esc { + timeout-ms = <50>; + key-positions = <0 1>; + bindings = <&kp ESC>; + }; + }; +}; +``` + +:::note +Combos currently are "global", and not scoped to a given active layer. There is future planned work to allow enabling a certain combo for only certain active layers. +::: + +#### Sticky Keys (One-Shot Mods/Layers) Behavior + +[okke-formsma] also contributed the initial "sticky keys" behavior, which can be used for functionality sometimes called "one shot mods" or "one shot layers". In your keymap, this would like like: + +``` +&sk LEFT_CONTROL +``` + +for a sticky key/modifier, or: + +``` +&sl NAV +``` + +for a sticky layer. + +#### `&to` Layer Behavior + +[mcrosson] contributed the new [`&to`](/docs/behaviors/layers#to-layer) layer related behavior. This can be used to completely replace the active layer with a new one. + +This is most frequently used when using multiple core base layers with different layouts, e.g. QWERTY and DVORAK, to switch between them. + +#### Grave Escape Behavior + +[okke-formsma] added an implementation of the "Grave Escape" behavior, developing a more generic "mod-morph" behavior to do so. Adding + +``` +&gresc +``` + +to your keymap will send `ESC` when pressed on its own, but will send `` ` `` when pressed with a GUI or Shift modifier held. + +#### RGB Underglow Color Selection + +[mcrosson] updated the [RGB Underglow behavior](/docs/behaviors/lighting#rgb-underglow) to allow [binding an explicit color selection](/docs/behaviors/lighting#examples) to a key position. + +#### Keymap Upgrader + +[joelspadin] completed the [Keymap Upgrader](/docs/codes/keymap-upgrader) which can be used to update your keymap to using the latest supported codes, and move away from the old deprecated codes. + +If you've made keymap customizations, please make sure to run your keymaps through the upgrader, since the old deprecated codes will be removed in a future version of ZMK. + +### Displays + +There has been lots of work to get display support complete enough for use by end users. Although not quite ready for prime time, it is incredibly close, and we are looking forward to having the last few items completed and the feature documented! + +#### Idle Blanking + +[petejohanson] added idle blanking for displays, which ensures they will go blank, and into low power mode, after a short period of inactivity from the user. This ensures we avoid burn-in for OLEDs, and helps improve battery life. + +#### Battery and Output Widgets + +[petejohanson] implemented the first two complete, dynamic "widgets" for the displays for ZMK, adding a small battery indicator, which includes charging status, and a small output indicator, showing the currently active output (USB or BLE). When using BLE, the indicator also shows the active profile slot, as well as if the profile slot is open, awaiting connection from the paired host, or is actively connected to the host for that profile slot. + +#### Highest Layer Display + +[mcrosson] has contributed the next display widget, showing the highest active layer in the keymap. [petejohanson] then added a small follow up to allow layers in keymaps to add a `label` property to each layer, e.g. `label = "Nav";` and have that label be displayed in the widget instead of the numeric layer number. + +#### WPM + +New contributor [allymparker](https://github.com/allymparker) added our fourth widget, a words-per-minute display! This widget work also included creating the core state logic for tracking the WPM. + +For now, this widget is only working on the central side of split keyboards. + +### Miscellaneous + +#### Zephyr 2.4 + +[innovaker] is at it again with some crucial core fixes, helping prepare and test the upgrade of ZMK to Zephyr 2.4. The updated Zephyr release brings with it some key BLE stability fixes, as well as various other core improvements that improve ZMK. This was a huge undertaking! + +#### BLE Deadlock Fixes + +[petejohanson] was heads down diagnosing and fixing a deadlock issue on BLE that was frustrating and plaguing many users. After finally pinpointing the underlying root cause, he developed a fix and roped in many testers on Discord to help stress test things before merging. + +#### Central/Peripheral Selection + +Previously overriding the selection of left as central, and right as peripheral for wireless splits required making local edits to the configuration files, and maintaining them in a ZMK fork. + +[petejohanson] updated [the config files](https://github.com/zmkfirmware/zmk/pull/510) to allow users to override this in their `_left.conf`/`_right.conf` files in their user repos. + +#### Improved Docker Containers + +As part of the Zephyr 2.4. prep work, [innovaker], along with lots of testing and input from [mcrosson], developed a brand new pair of [Docker images](https://github.com/zmkfirmware/zmk-docker) which is now published to Docker Hub as [zmkfirmware/zmk-build-arm](https://hub.docker.com/repository/docker/zmkfirmware/zmk-build-arm) and [zmkfirmware/zmk-dev-arm](https://hub.docker.com/repository/docker/zmkfirmware/zmk-build-arm). + +The previously blogged VSCode + Docker integration, as well as our GH Action build automation was all moved over to the new images. + +#### Settings Debounce + +[nicell] contributed settings debounce work, to help avoid unnecessary extra writes to flash when making various changes that should be saved, +such as the active BLE profile, external VCC on/off, etc. + +## New Shields + +- Jorne & Jian in [#331](https://github.com/zmkfirmware/zmk/pull/331) - [krikun98](https://github.com/krikun98) +- tidbit in [#424](https://github.com/zmkfirmware/zmk/pull/424) - [mcrosson](https://github.com/mcrosson) +- Helix in [#429](https://github.com/zmkfirmware/zmk/pull/429) - [KingCoinless](https://github.com/KingCoinless) +- BFO-9000 in [#472](https://github.com/zmkfirmware/zmk/pull/472) - [pbz](https://github.com/pbz) +- CRBN in [#493](https://github.com/zmkfirmware/zmk/pull/483) - [ReFil](https://github.com/ReFil) +- Eek in [#529](https://github.com/zmkfirmware/zmk/pull/529) - [MangoIV](https://github.com/MangoIV) + +## New Boards + +- BDN9 Rev2 in [#557](https://github.com/zmkfirmware/zmk/pull/557) - [petejohanson] + +## Sponsorship + +Since it's inception, quite a few users have inquired whether they could sponsor any of the contributors involved in ZMK. Although we are not intending to directly fund any individual contributors for their work on ZMK, there _is_ good that can come from folks sponsoring ZMK. + +You can see the full discussion on [#497](https://github.com/zmkfirmware/zmk/issues/497), but some items that are being considered with sponsorship funds: + +- Hiring a designer to complete the logo/mascot work. +- Creating stickers to send as thank-yous to first time contributors. +- Hosting costs for GitHub Pro. +- Other hosting costs, e.g. Docker Hub. + +For anyone looking to contribute, you can find the [ZMK Firmware project](https://opencollective.com/zmkfirmware) is now set up on [Open Collective](https://opencollective.com). + +## Coming Soon! + +Some items listed in the last coming soon section are still under active development. + +- A power profiler page for the website, to help users estimate their battery life for a given keyboard - [Nicell] +- Behavior "locality", allowing improved split usage for things like `&reset`, and controlling external power and RGB underglow for both sides - [petejohanson] +- More modular approach to external boards/shields, custom code, user keymaps, etc. +- More shields and boards + +## Statistics + +Some statistics of interest for ZMK: + +- GitHub (lifetime stats) + - 389 Closed PRs + - 199 Stars + - 163 Forks +- Discord Chat + - 702 total registered +- Website (last 30 days) + - 11.5K page views + - 1K new users + +## Thanks! + +Thanks again to the numerous contributors, testers, and users who have made working on ZMK such a pleasure! + +[okke-formsma]: https://github.com/okke-formsma +[mcrosson]: https://github.com/mcrosson +[nicell]: https://github.com/Nicell +[petejohanson]: https://github.com/petejohanson +[innovaker]: https://github.com/innovaker +[joelspadin]: https://github.com/joelspadin From a89d8a6ea425e28856e762bd4db50a6a40ef58e8 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Wed, 27 Jan 2021 22:49:57 -0500 Subject: [PATCH 2/4] fix(blog): Updated link to combos docs. --- docs/blog/2021-01-27-zmk-sotf-4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/blog/2021-01-27-zmk-sotf-4.md b/docs/blog/2021-01-27-zmk-sotf-4.md index bbbabdcb..d902b62d 100644 --- a/docs/blog/2021-01-27-zmk-sotf-4.md +++ b/docs/blog/2021-01-27-zmk-sotf-4.md @@ -21,7 +21,7 @@ Since last time, there have been several new powerful keymap features and behavi #### Combos -The initial [combos](/docs/behaviors/combos) work has landed! The amazing [okke-formsma] has once again delivered another powerful feature for ZMK. Combos are "position based", and are configured in a new toplevel node next to they `keymap` node in user's keymap files. +The initial [combos](/docs/features/combos) work has landed! The amazing [okke-formsma] has once again delivered another powerful feature for ZMK. Combos are "position based", and are configured in a new toplevel node next to they `keymap` node in user's keymap files. An example, that would send the `ESC` keycode when pressing both the first and second positions on your keyboard: From c925cf02dd1999c0e968ead7652956e5e1925875 Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Sat, 12 Dec 2020 21:35:52 +0100 Subject: [PATCH 3/4] feature(sticky_keys): add quick-release when quick-release is enabled, the sticky key is released immediately after another key is pressed --- app/dts/behaviors/sticky_key.dtsi | 1 + .../behaviors/zmk,behavior-sticky-key.yaml | 2 + app/src/behaviors/behavior_sticky_key.c | 6 ++- .../2-sl-dn-up-kcdn-kcup/events.patterns | 1 + .../keycode_events.snapshot | 8 +++ .../2-sl-dn-up-kcdn-kcup/native_posix.keymap | 52 +++++++++++++++++++ .../8-lsk-osk-combination/events.patterns | 2 +- .../keycode_events.snapshot | 8 +-- .../8-lsk-osk-combination/native_posix.keymap | 4 +- 9 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 app/tests/sticky-keys/2-sl-dn-up-kcdn-kcup/events.patterns create mode 100644 app/tests/sticky-keys/2-sl-dn-up-kcdn-kcup/keycode_events.snapshot create mode 100644 app/tests/sticky-keys/2-sl-dn-up-kcdn-kcup/native_posix.keymap diff --git a/app/dts/behaviors/sticky_key.dtsi b/app/dts/behaviors/sticky_key.dtsi index 1e66a1ed..f1c1cdd5 100644 --- a/app/dts/behaviors/sticky_key.dtsi +++ b/app/dts/behaviors/sticky_key.dtsi @@ -19,6 +19,7 @@ #binding-cells = <1>; release-after-ms = <1000>; bindings = <&mo>; + quick-release; }; }; diff --git a/app/dts/bindings/behaviors/zmk,behavior-sticky-key.yaml b/app/dts/bindings/behaviors/zmk,behavior-sticky-key.yaml index df9c423c..1c2ab7f3 100644 --- a/app/dts/bindings/behaviors/zmk,behavior-sticky-key.yaml +++ b/app/dts/bindings/behaviors/zmk,behavior-sticky-key.yaml @@ -13,3 +13,5 @@ properties: required: true release-after-ms: type: int + quick-release: + type: boolean diff --git a/app/src/behaviors/behavior_sticky_key.c b/app/src/behaviors/behavior_sticky_key.c index fe05e067..aa9fe9ac 100644 --- a/app/src/behaviors/behavior_sticky_key.c +++ b/app/src/behaviors/behavior_sticky_key.c @@ -29,6 +29,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); struct behavior_sticky_key_config { uint32_t release_after_ms; + bool quick_release; struct zmk_behavior_binding behavior; }; @@ -209,10 +210,12 @@ static int sticky_key_keycode_state_changed_listener(const zmk_event_t *eh) { } if (sticky_key->timer_started) { stop_timer(sticky_key); + if (sticky_key->config->quick_release) { + release_sticky_key_behavior(sticky_key, ev->timestamp); + } } sticky_key->modified_key_usage_page = ev->usage_page; sticky_key->modified_key_keycode = ev->keycode; - } else { // key up if (sticky_key->timer_started && sticky_key->modified_key_usage_page == ev->usage_page && @@ -269,6 +272,7 @@ static struct behavior_sticky_key_data behavior_sticky_key_data; #define KP_INST(n) \ static struct behavior_sticky_key_config behavior_sticky_key_config_##n = { \ .behavior = _TRANSFORM_ENTRY(0, n).release_after_ms = DT_INST_PROP(n, release_after_ms), \ + .quick_release = DT_INST_PROP(n, quick_release), \ }; \ DEVICE_AND_API_INIT(behavior_sticky_key_##n, DT_INST_LABEL(n), behavior_sticky_key_init, \ &behavior_sticky_key_data, &behavior_sticky_key_config_##n, APPLICATION, \ diff --git a/app/tests/sticky-keys/2-sl-dn-up-kcdn-kcup/events.patterns b/app/tests/sticky-keys/2-sl-dn-up-kcdn-kcup/events.patterns new file mode 100644 index 00000000..833100f6 --- /dev/null +++ b/app/tests/sticky-keys/2-sl-dn-up-kcdn-kcup/events.patterns @@ -0,0 +1 @@ +s/.*hid_listener_keycode_//p \ No newline at end of file diff --git a/app/tests/sticky-keys/2-sl-dn-up-kcdn-kcup/keycode_events.snapshot b/app/tests/sticky-keys/2-sl-dn-up-kcdn-kcup/keycode_events.snapshot new file mode 100644 index 00000000..7e745b51 --- /dev/null +++ b/app/tests/sticky-keys/2-sl-dn-up-kcdn-kcup/keycode_events.snapshot @@ -0,0 +1,8 @@ +pressed: usage_page 0x07 keycode 0x1b implicit_mods 0x00 explicit_mods 0x00 +pressed: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00 +released: usage_page 0x07 keycode 0x1b implicit_mods 0x00 explicit_mods 0x00 +released: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00 +pressed: usage_page 0x07 keycode 0x1b implicit_mods 0x00 explicit_mods 0x00 +pressed: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00 +released: usage_page 0x07 keycode 0x1b implicit_mods 0x00 explicit_mods 0x00 +released: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00 diff --git a/app/tests/sticky-keys/2-sl-dn-up-kcdn-kcup/native_posix.keymap b/app/tests/sticky-keys/2-sl-dn-up-kcdn-kcup/native_posix.keymap new file mode 100644 index 00000000..4470fb21 --- /dev/null +++ b/app/tests/sticky-keys/2-sl-dn-up-kcdn-kcup/native_posix.keymap @@ -0,0 +1,52 @@ +#include +#include +#include + +/* + sticky layers should quick-release. + Thus, the second keypress should be on the default layer, not on the lower_layer. +*/ + +/ { + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &sk E &sl 1 + &kp A &kp B>; + }; + + lower_layer { + bindings = < + &sk LEFT_CONTROL &kp X + &kp Y &kp Z>; + }; + }; +}; + +&kscan { + events = < + /* press sl 1 */ + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_RELEASE(0,1,10) + /* press X */ + ZMK_MOCK_PRESS(0,1,10) + /* press A */ + ZMK_MOCK_PRESS(1,0,10) + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(1,0,10) + + /* repeat test to check if cleanup is done correctly */ + /* press sl 1 */ + ZMK_MOCK_PRESS(0,1,10) + ZMK_MOCK_RELEASE(0,1,10) + /* press X */ + ZMK_MOCK_PRESS(0,1,10) + /* press Y */ + ZMK_MOCK_PRESS(1,0,10) + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(1,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/sticky-keys/8-lsk-osk-combination/events.patterns b/app/tests/sticky-keys/8-lsk-osk-combination/events.patterns index 833100f6..b1342af4 100644 --- a/app/tests/sticky-keys/8-lsk-osk-combination/events.patterns +++ b/app/tests/sticky-keys/8-lsk-osk-combination/events.patterns @@ -1 +1 @@ -s/.*hid_listener_keycode_//p \ No newline at end of file +s/.*hid_listener_keycode_//p diff --git a/app/tests/sticky-keys/8-lsk-osk-combination/keycode_events.snapshot b/app/tests/sticky-keys/8-lsk-osk-combination/keycode_events.snapshot index 8eb8a352..374035fc 100644 --- a/app/tests/sticky-keys/8-lsk-osk-combination/keycode_events.snapshot +++ b/app/tests/sticky-keys/8-lsk-osk-combination/keycode_events.snapshot @@ -1,8 +1,8 @@ pressed: usage_page 0x07 keycode 0xe0 implicit_mods 0x00 explicit_mods 0x00 -pressed: usage_page 0x07 keycode 0x1c implicit_mods 0x00 explicit_mods 0x00 +pressed: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00 released: usage_page 0x07 keycode 0xe0 implicit_mods 0x00 explicit_mods 0x00 -released: usage_page 0x07 keycode 0x1c implicit_mods 0x00 explicit_mods 0x00 +released: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00 pressed: usage_page 0x07 keycode 0xe0 implicit_mods 0x00 explicit_mods 0x00 -pressed: usage_page 0x07 keycode 0x1c implicit_mods 0x00 explicit_mods 0x00 +pressed: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00 released: usage_page 0x07 keycode 0xe0 implicit_mods 0x00 explicit_mods 0x00 -released: usage_page 0x07 keycode 0x1c implicit_mods 0x00 explicit_mods 0x00 +released: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00 diff --git a/app/tests/sticky-keys/8-lsk-osk-combination/native_posix.keymap b/app/tests/sticky-keys/8-lsk-osk-combination/native_posix.keymap index beedd44e..bdcccf33 100644 --- a/app/tests/sticky-keys/8-lsk-osk-combination/native_posix.keymap +++ b/app/tests/sticky-keys/8-lsk-osk-combination/native_posix.keymap @@ -29,7 +29,7 @@ /* tap sk LEFT_CONTROL */ ZMK_MOCK_PRESS(0,0,10) ZMK_MOCK_RELEASE(0,0,10) - /* tap Y */ + /* tap A */ ZMK_MOCK_PRESS(1,0,10) ZMK_MOCK_RELEASE(1,0,10) @@ -40,7 +40,7 @@ /* tap sk */ ZMK_MOCK_PRESS(0,0,10) ZMK_MOCK_RELEASE(0,0,10) - /* tap Y */ + /* tap A */ ZMK_MOCK_PRESS(1,0,10) ZMK_MOCK_RELEASE(1,0,10) >; From 64a85b7a3f947a46abb21ec3c4a85c29c38a19fb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Jan 2021 07:14:15 +0000 Subject: [PATCH 4/4] chore(deps): bump DoozyX/clang-format-lint-action from v0.9 to v0.11 Bumps [DoozyX/clang-format-lint-action](https://github.com/DoozyX/clang-format-lint-action) from v0.9 to v0.11. - [Release notes](https://github.com/DoozyX/clang-format-lint-action/releases) - [Commits](https://github.com/DoozyX/clang-format-lint-action/compare/v0.9...84b814a54950e27ac65a62069802df099405ef77) Signed-off-by: dependabot[bot] --- .github/workflows/clang-format-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clang-format-lint.yml b/.github/workflows/clang-format-lint.yml index 8bd42753..b6d515c1 100644 --- a/.github/workflows/clang-format-lint.yml +++ b/.github/workflows/clang-format-lint.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: DoozyX/clang-format-lint-action@v0.9 + - uses: DoozyX/clang-format-lint-action@v0.11 with: source: "./app" extensions: "h,c"