From 40cd8da743b10aee61e0396138354d062cd0e23e Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Wed, 13 Apr 2022 03:20:35 +0000 Subject: [PATCH 01/36] fix(usb): Split HID from core USB, logging fix. * Split core USB init from USB HID init. * Tweak logging to avoid "log loop" causing spurious buffer messages on startup. --- app/CMakeLists.txt | 1 + app/Kconfig | 7 +++++ app/include/zmk/usb.h | 4 --- app/include/zmk/usb_hid.h | 9 ++++++ app/src/endpoints.c | 2 +- app/src/usb.c | 48 ----------------------------- app/src/usb_hid.c | 64 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 82 insertions(+), 53 deletions(-) create mode 100644 app/include/zmk/usb_hid.h create mode 100644 app/src/usb_hid.c diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index b760389f..1492be16 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -78,6 +78,7 @@ if (CONFIG_ZMK_SPLIT_BLE AND CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) target_sources(app PRIVATE src/split/bluetooth/central.c) endif() target_sources_ifdef(CONFIG_USB_DEVICE_STACK app PRIVATE src/usb.c) +target_sources_ifdef(CONFIG_ZMK_USB app PRIVATE src/usb_hid.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_ifdef(CONFIG_ZMK_BACKLIGHT app PRIVATE src/backlight.c) diff --git a/app/Kconfig b/app/Kconfig index 5551ed31..8b13d524 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -477,6 +477,10 @@ if ZMK_USB_LOGGING config ZMK_LOG_LEVEL default 4 +# We do this to avoid log loop where logging to USB generates more log messages. +config USB_CDC_ACM_LOG_LEVEL + default 1 + config USB_CDC_ACM_RINGBUF_SIZE default 1024 @@ -486,6 +490,9 @@ config LOG_BUFFER_SIZE config LOG_STRDUP_BUF_COUNT default 16 +config LOG_PROCESS_THREAD_STARTUP_DELAY_MS + default 1000 + #ZMK_USB_LOGGING endif diff --git a/app/include/zmk/usb.h b/app/include/zmk/usb.h index 62a7e3cb..786d9c73 100644 --- a/app/include/zmk/usb.h +++ b/app/include/zmk/usb.h @@ -23,7 +23,3 @@ enum zmk_usb_conn_state zmk_usb_get_conn_state(); static inline bool zmk_usb_is_powered() { return zmk_usb_get_conn_state() != ZMK_USB_CONN_NONE; } static inline bool zmk_usb_is_hid_ready() { return zmk_usb_get_conn_state() == ZMK_USB_CONN_HID; } - -#ifdef CONFIG_ZMK_USB -int zmk_usb_hid_send_report(const uint8_t *report, size_t len); -#endif /* CONFIG_ZMK_USB */ \ No newline at end of file diff --git a/app/include/zmk/usb_hid.h b/app/include/zmk/usb_hid.h new file mode 100644 index 00000000..1748835e --- /dev/null +++ b/app/include/zmk/usb_hid.h @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#pragma once + +int zmk_usb_hid_send_report(const uint8_t *report, size_t len); \ No newline at end of file diff --git a/app/src/endpoints.c b/app/src/endpoints.c index ebbb9fbc..33760010 100644 --- a/app/src/endpoints.c +++ b/app/src/endpoints.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/app/src/usb.c b/app/src/usb.c index 2f0fa439..8d2b62f1 100644 --- a/app/src/usb.c +++ b/app/src/usb.c @@ -26,41 +26,6 @@ static void raise_usb_status_changed_event(struct k_work *_work) { K_WORK_DEFINE(usb_status_notifier_work, raise_usb_status_changed_event); -#ifdef CONFIG_ZMK_USB - -static const struct device *hid_dev; - -static K_SEM_DEFINE(hid_sem, 1, 1); - -static void in_ready_cb(const struct device *dev) { k_sem_give(&hid_sem); } - -static const struct hid_ops ops = { - .int_in_ready = in_ready_cb, -}; - -int zmk_usb_hid_send_report(const uint8_t *report, size_t len) { - switch (usb_status) { - case USB_DC_SUSPEND: - return usb_wakeup_request(); - case USB_DC_ERROR: - case USB_DC_RESET: - case USB_DC_DISCONNECTED: - case USB_DC_UNKNOWN: - return -ENODEV; - default: - k_sem_take(&hid_sem, K_MSEC(30)); - int err = hid_int_ep_write(hid_dev, report, len, NULL); - - if (err) { - k_sem_give(&hid_sem); - } - - return err; - } -} - -#endif /* CONFIG_ZMK_USB */ - enum usb_dc_status_code zmk_usb_get_status() { return usb_status; } enum zmk_usb_conn_state zmk_usb_get_conn_state() { @@ -87,19 +52,6 @@ void usb_status_cb(enum usb_dc_status_code status, const uint8_t *params) { static int zmk_usb_init(const 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"); - return -EINVAL; - } - - usb_hid_register_device(hid_dev, zmk_hid_report_desc, sizeof(zmk_hid_report_desc), &ops); - - usb_hid_init(hid_dev); - -#endif /* CONFIG_ZMK_USB */ - usb_enable_ret = usb_enable(usb_status_cb); if (usb_enable_ret != 0) { diff --git a/app/src/usb_hid.c b/app/src/usb_hid.c new file mode 100644 index 00000000..4b90cf96 --- /dev/null +++ b/app/src/usb_hid.c @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include + +#include +#include + +#include +#include +#include +#include + +LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); + +static const struct device *hid_dev; + +static K_SEM_DEFINE(hid_sem, 1, 1); + +static void in_ready_cb(const struct device *dev) { k_sem_give(&hid_sem); } + +static const struct hid_ops ops = { + .int_in_ready = in_ready_cb, +}; + +int zmk_usb_hid_send_report(const uint8_t *report, size_t len) { + switch (zmk_usb_get_status()) { + case USB_DC_SUSPEND: + return usb_wakeup_request(); + case USB_DC_ERROR: + case USB_DC_RESET: + case USB_DC_DISCONNECTED: + case USB_DC_UNKNOWN: + return -ENODEV; + default: + k_sem_take(&hid_sem, K_MSEC(30)); + int err = hid_int_ep_write(hid_dev, report, len, NULL); + + if (err) { + k_sem_give(&hid_sem); + } + + return err; + } +} + +static int zmk_usb_hid_init(const struct device *_arg) { + hid_dev = device_get_binding("HID_0"); + if (hid_dev == NULL) { + LOG_ERR("Unable to locate HID device"); + return -EINVAL; + } + + usb_hid_register_device(hid_dev, zmk_hid_report_desc, sizeof(zmk_hid_report_desc), &ops); + usb_hid_init(hid_dev); + + return 0; +} + +SYS_INIT(zmk_usb_hid_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); From 0e54603ec66dc63b5a8d9c8f565df31cc745fe3c Mon Sep 17 00:00:00 2001 From: DoctorNefario <5243039+DoctorNefario@users.noreply.github.com> Date: Thu, 14 Apr 2022 23:55:04 +1000 Subject: [PATCH 02/36] fix(docs): Clarify backlight & underglow use cases This should help reduce confusion for newcomers. --- docs/docs/features/backlight.md | 6 +++++- docs/docs/features/underglow.md | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/docs/features/backlight.md b/docs/docs/features/backlight.md index ef1c0521..6632a0f0 100644 --- a/docs/docs/features/backlight.md +++ b/docs/docs/features/backlight.md @@ -6,7 +6,11 @@ sidebar_label: Backlight import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -Backlight is a feature used to control array of LEDs, usually placed through or under switches. Unlike [RGB Underglow](underglow.md), backlight currently allows only one color per LED, also LEDs are not addressable, so you can't control individual LEDs. +Backlight is a feature used to control an array of LEDs, usually placed through or under switches. + +:::info +Unlike [RGB Underglow](underglow.md), backlight can only control single color LEDs. Additionally, because backlight LEDs all receive the same power, it's not possible to dim individual LEDs. +::: ## Enabling Backlight diff --git a/docs/docs/features/underglow.md b/docs/docs/features/underglow.md index ac865826..58b3ef45 100644 --- a/docs/docs/features/underglow.md +++ b/docs/docs/features/underglow.md @@ -5,6 +5,10 @@ sidebar_label: RGB Underglow RGB underglow is a feature used to control "strips" of RGB LEDs. Most of the time this is called underglow and creates a glow underneath the board using a ring of LEDs around the edge, hence the name. However, this can be extended to be used to control anything from a single LED to a long string of LEDs anywhere on the keyboard. +:::info +RGB underglow can also be used for under-key lighting. If you have RGB LEDs on your keyboard, this is what you want. For PWM/single color LEDs, see [Backlight](backlight.md). +::: + ZMK supports all the RGB LEDs supported by Zephyr. Here's the current list supported: - WS2812-ish (WS2812B, WS2813, SK6812, or compatible) From ebc6275a72b8d9140a80ccd50332298da1299eed Mon Sep 17 00:00:00 2001 From: Herald Date: Thu, 14 Apr 2022 16:13:33 +0100 Subject: [PATCH 03/36] fix(docs): Document `ignore-modifiers` and `quick-release` for sticky keys (#1228) --- docs/docs/behaviors/sticky-key.md | 39 ++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/docs/docs/behaviors/sticky-key.md b/docs/docs/behaviors/sticky-key.md index e7085763..12541ed8 100644 --- a/docs/docs/behaviors/sticky-key.md +++ b/docs/docs/behaviors/sticky-key.md @@ -7,8 +7,6 @@ sidebar_label: Sticky Key A sticky key stays pressed until another key is pressed. It is often used for 'sticky shift'. By using a sticky shift, you don't have to hold the shift key to write a capital. -By default, sticky keys stay pressed for a second if you don't press any other key. You can configure this with the `release-after-ms` setting (see below). - ### Behavior Binding - Reference: `&sk` @@ -28,11 +26,25 @@ You can use any keycode that works for `&kp` as parameter to `&sk`: ### Configuration -You can configure a different `release-after-ms` in your keymap: +#### `release-after-ms` + +By default, sticky keys stay pressed for a second if you don't press any other key. You can configure this with the `release-after-ms` setting. + +#### `quick-release` + +Some typists may find that using a sticky shift key interspersed with rapid typing results in two or more capitalized letters instead of one. This happens as the sticky key is active until the next key is released, under which other keys may be pressed and will receive the modifier. You can enable the `quick-release` setting to instead deactivate the sticky key on the next key being pressed, as opposed to released. + +#### `ignore-modifiers` + +This setting is enabled by default. It ensures that if a sticky key modifier is pressed before a previously pressed sticky key is released, the modifiers will get combined so you can add more sticky keys or press a regular key to apply the modifiers. This is to accommodate _callum-style mods_ where you are prone to rolling sticky keys. If you want sticky key modifiers to only chain after release, you can disable this setting. + +#### Example ``` &sk { release-after-ms = <2000>; + quick-release; + /delete-property/ ignore-modifiers; }; / { @@ -42,6 +54,27 @@ You can configure a different `release-after-ms` in your keymap: }; ``` +This configuration would apply to all sticky keys. This may not be appropriate if using `quick-release` as you'll lose the ability to chain sticky key modifiers. A better approach for this use case would be to create a new behavior: + +``` +/ { + behaviors { + skq: sticky_key_quick_release { + compatible = "zmk,behavior-sticky-key"; + label = "STICKY_KEY_QUICK_RELEASE"; + #binding-cells = <1>; + bindings = <&kp>; + release-after-ms = <1000>; + quick-release; + }; + }; + + keymap { + ... + }; +}; +``` + ### Advanced usage Sticky keys can be combined; if you tap `&sk LCTRL` and then `&sk LSHIFT` and then `&kp A`, the output will be ctrl+shift+a. From c7a6836735d0a77d8327d4377ebacd0e25c5bb9e Mon Sep 17 00:00:00 2001 From: DoctorNefario <5243039+DoctorNefario@users.noreply.github.com> Date: Fri, 15 Apr 2022 02:29:09 +1000 Subject: [PATCH 04/36] fix(docs): Add `#include` to Underglow upgrade notes --- docs/blog/2022-04-02-zephyr-3-0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/blog/2022-04-02-zephyr-3-0.md b/docs/blog/2022-04-02-zephyr-3-0.md index 44a4fa72..103573c6 100644 --- a/docs/blog/2022-04-02-zephyr-3-0.md +++ b/docs/blog/2022-04-02-zephyr-3-0.md @@ -74,7 +74,7 @@ The following changes have [already been completed](https://github.com/zmkfirmwa ### RGB Underglow -Zephyr's WS2812 `led_strip` driver added a new required property. When adding [underglow](/docs/features/underglow#adding-rgb-underglow-to-a-board) to a board, you now must also add a `color-mapping` property, like: +Zephyr's WS2812 `led_strip` driver added a new required property. When adding [underglow](/docs/features/underglow#adding-rgb-underglow-to-a-board) to a board, you now must also add the additional include `#include ` at the top of your devicetree file, and add a `color-mapping` property like: ``` led_strip: ws2812@0 { From d08463e483a57ab83ff8be5bdc2f324e4184c331 Mon Sep 17 00:00:00 2001 From: Nick Winans Date: Fri, 15 Apr 2022 11:10:59 -0500 Subject: [PATCH 05/36] fix(ble): Restore manual connection params --- app/src/ble.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/ble.c b/app/src/ble.c index d9121583..ed823178 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -398,6 +398,11 @@ static void connected(struct bt_conn *conn, uint8_t err) { LOG_DBG("Connected %s", log_strdup(addr)); + err = bt_conn_le_param_update(conn, BT_LE_CONN_PARAM(0x0006, 0x000c, 30, 400)); + if (err) { + LOG_WRN("Failed to update LE parameters (err %d)", err); + } + #if IS_SPLIT_PERIPHERAL bt_conn_le_phy_update(conn, BT_CONN_LE_PHY_PARAM_2M); #endif From 388e345c28907dcf3a7e04b844e582e2dbc0c261 Mon Sep 17 00:00:00 2001 From: Joel Spadin Date: Sat, 17 Jul 2021 17:49:37 -0500 Subject: [PATCH 06/36] feat(battery)!: Add chosen node for battery battery.c now uses the zmk,battery chosen node to select a battery sensor. Using the node labeled "BATTERY" is maintained for backwards compatibility but is now deprecated. Custom boards should switch to using the chosen node. # Conflicts: # app/boards/arm/bluemicro840/bluemicro840_v1.dts # app/boards/arm/nice60/nice60.dts # app/boards/arm/nrfmicro/nrfmicro_13.dts # Conflicts: # app/boards/arm/bluemicro840/bluemicro840_v1.dts --- .../arm/bluemicro840/bluemicro840_v1.dts | 3 ++- app/boards/arm/bt60/bt60.dtsi | 3 ++- app/boards/arm/mikoto/mikoto_520.dts | 3 ++- app/boards/arm/nice60/nice60.dts | 3 ++- app/boards/arm/nice_nano/nice_nano.dts | 6 +++++- app/boards/arm/nice_nano/nice_nano_v2.dts | 6 +++++- app/boards/arm/nrfmicro/nrfmicro_13.dts | 3 ++- app/boards/arm/s40nc/s40nc.dts | 3 ++- app/boards/seeeduino_xiao_ble.overlay | 3 ++- app/src/battery.c | 19 ++++++++++++++++--- 10 files changed, 40 insertions(+), 12 deletions(-) diff --git a/app/boards/arm/bluemicro840/bluemicro840_v1.dts b/app/boards/arm/bluemicro840/bluemicro840_v1.dts index 7f2db85b..29bf0f8d 100644 --- a/app/boards/arm/bluemicro840/bluemicro840_v1.dts +++ b/app/boards/arm/bluemicro840/bluemicro840_v1.dts @@ -17,6 +17,7 @@ zephyr,sram = &sram0; zephyr,flash = &flash0; zephyr,console = &cdc_acm_uart; + zmk,battery = &vbatt; }; leds { @@ -34,7 +35,7 @@ control-gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>; }; - vbatt { + vbatt: vbatt { compatible = "zmk,battery-voltage-divider"; label = "BATTERY"; io-channels = <&adc 7>; diff --git a/app/boards/arm/bt60/bt60.dtsi b/app/boards/arm/bt60/bt60.dtsi index e684bc1d..3858ba46 100644 --- a/app/boards/arm/bt60/bt60.dtsi +++ b/app/boards/arm/bt60/bt60.dtsi @@ -17,6 +17,7 @@ zephyr,sram = &sram0; zephyr,flash = &flash0; zephyr,console = &cdc_acm_uart; + zmk,battery = &vbatt; zmk,kscan = &kscan0; zmk,matrix_transform = &default_transform; }; @@ -46,7 +47,7 @@ }; }; - vbatt { + vbatt: vbatt { compatible = "zmk,battery-voltage-divider"; label = "BATTERY"; io-channels = <&adc 2>; diff --git a/app/boards/arm/mikoto/mikoto_520.dts b/app/boards/arm/mikoto/mikoto_520.dts index 5ce17640..44321e79 100644 --- a/app/boards/arm/mikoto/mikoto_520.dts +++ b/app/boards/arm/mikoto/mikoto_520.dts @@ -17,6 +17,7 @@ zephyr,sram = &sram0; zephyr,flash = &flash0; zephyr,console = &cdc_acm_uart; + zmk,battery = &vbatt; }; leds { @@ -34,7 +35,7 @@ init-delay-ms = <50>; }; - vbatt { + vbatt: vbatt { compatible = "zmk,battery-voltage-divider"; label = "BATTERY"; io-channels = <&adc 2>; diff --git a/app/boards/arm/nice60/nice60.dts b/app/boards/arm/nice60/nice60.dts index ee38c9a5..bb058da8 100644 --- a/app/boards/arm/nice60/nice60.dts +++ b/app/boards/arm/nice60/nice60.dts @@ -19,6 +19,7 @@ zephyr,sram = &sram0; zephyr,flash = &flash0; zephyr,console = &cdc_acm_uart; + zmk,battery = &vbatt; zmk,kscan = &kscan0; zmk,matrix_transform = &default_transform; zmk,underglow = &led_strip; @@ -81,7 +82,7 @@ RC(4,0) RC(4,1) RC(4,2) RC(4,5) R control-gpios = <&gpio0 5 GPIO_ACTIVE_LOW>; }; - vbatt { + vbatt: vbatt { compatible = "zmk,battery-voltage-divider"; label = "BATTERY"; io-channels = <&adc 2>; diff --git a/app/boards/arm/nice_nano/nice_nano.dts b/app/boards/arm/nice_nano/nice_nano.dts index cce3dba6..e29df205 100644 --- a/app/boards/arm/nice_nano/nice_nano.dts +++ b/app/boards/arm/nice_nano/nice_nano.dts @@ -8,13 +8,17 @@ #include "nice_nano.dtsi" / { + chosen { + zmk,battery = &vbatt; + }; + ext-power { compatible = "zmk,ext-power-generic"; label = "EXT_POWER"; control-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>; }; - vbatt { + vbatt: vbatt { compatible = "zmk,battery-voltage-divider"; label = "BATTERY"; io-channels = <&adc 2>; diff --git a/app/boards/arm/nice_nano/nice_nano_v2.dts b/app/boards/arm/nice_nano/nice_nano_v2.dts index 8f72aad6..ed2b35f4 100644 --- a/app/boards/arm/nice_nano/nice_nano_v2.dts +++ b/app/boards/arm/nice_nano/nice_nano_v2.dts @@ -8,6 +8,10 @@ #include "nice_nano.dtsi" / { + chosen { + zmk,battery = &vbatt; + }; + ext-power { compatible = "zmk,ext-power-generic"; label = "EXT_POWER"; @@ -15,7 +19,7 @@ init-delay-ms = <50>; }; - vbatt { + vbatt: vbatt { compatible = "zmk,battery-nrf-vddh"; label = "BATTERY"; }; diff --git a/app/boards/arm/nrfmicro/nrfmicro_13.dts b/app/boards/arm/nrfmicro/nrfmicro_13.dts index d60417fd..a0f74170 100644 --- a/app/boards/arm/nrfmicro/nrfmicro_13.dts +++ b/app/boards/arm/nrfmicro/nrfmicro_13.dts @@ -17,6 +17,7 @@ zephyr,sram = &sram0; zephyr,flash = &flash0; zephyr,console = &cdc_acm_uart; + zmk,battery = &vbatt; }; leds { @@ -33,7 +34,7 @@ control-gpios = <&gpio1 9 GPIO_ACTIVE_LOW>; }; - vbatt { + vbatt: vbatt { compatible = "zmk,battery-voltage-divider"; label = "BATTERY"; io-channels = <&adc 2>; diff --git a/app/boards/arm/s40nc/s40nc.dts b/app/boards/arm/s40nc/s40nc.dts index 67a3c293..5b588b45 100644 --- a/app/boards/arm/s40nc/s40nc.dts +++ b/app/boards/arm/s40nc/s40nc.dts @@ -17,6 +17,7 @@ zephyr,sram = &sram0; zephyr,flash = &flash0; zephyr,console = &cdc_acm_uart; + zmk,battery = &vbatt; zmk,kscan = &kscan0; zmk,matrix_transform = &default_transform; }; @@ -69,7 +70,7 @@ }; }; - vbatt { + vbatt: vbatt { compatible = "zmk,battery-voltage-divider"; label = "BATTERY"; io-channels = <&adc 2>; diff --git a/app/boards/seeeduino_xiao_ble.overlay b/app/boards/seeeduino_xiao_ble.overlay index 7e0d4ff9..0f5df999 100644 --- a/app/boards/seeeduino_xiao_ble.overlay +++ b/app/boards/seeeduino_xiao_ble.overlay @@ -8,9 +8,10 @@ / { chosen { zephyr,console = &cdc_acm_uart; + zmk,battery = &vbatt; }; - vbatt { + vbatt: vbatt { compatible = "zmk,battery-voltage-divider"; label = "BATTERY"; io-channels = <&adc 7>; diff --git a/app/src/battery.c b/app/src/battery.c index c63008e6..4292dafe 100644 --- a/app/src/battery.c +++ b/app/src/battery.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -18,12 +19,16 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include #include -const struct device *battery; - static uint8_t last_state_of_charge = 0; uint8_t zmk_battery_state_of_charge() { return last_state_of_charge; } +#if DT_HAS_CHOSEN(zmk_battery) +static const struct device *const battery = DEVICE_DT_GET(DT_CHOSEN(zmk_battery)); +#else +static const struct device *battery; +#endif + static int zmk_battery_update(const struct device *battery) { struct sensor_value state_of_charge; @@ -75,10 +80,18 @@ static void zmk_battery_timer(struct k_timer *timer) { k_work_submit(&battery_wo K_TIMER_DEFINE(battery_timer, zmk_battery_timer, NULL); static int zmk_battery_init(const struct device *_arg) { +#if !DT_HAS_CHOSEN(zmk_battery) battery = device_get_binding("BATTERY"); if (battery == NULL) { - LOG_DBG("No battery device labelled BATTERY found."); + return -ENODEV; + } + + LOG_WRN("Finding battery device labeled BATTERY is deprecated. Use zmk,battery chosen node."); +#endif + + if (!device_is_ready(battery)) { + LOG_ERR("Battery device \"%s\" is not ready", battery->name); return -ENODEV; } From f91472fbe5e2577ac672231f4490db289b68dbce Mon Sep 17 00:00:00 2001 From: Joel Spadin Date: Fri, 15 Apr 2022 22:09:35 -0500 Subject: [PATCH 07/36] fix(battery): Warn if using deprecated battery label --- app/src/battery.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/battery.c b/app/src/battery.c index 4292dafe..51f96c12 100644 --- a/app/src/battery.c +++ b/app/src/battery.c @@ -26,6 +26,8 @@ uint8_t zmk_battery_state_of_charge() { return last_state_of_charge; } #if DT_HAS_CHOSEN(zmk_battery) static const struct device *const battery = DEVICE_DT_GET(DT_CHOSEN(zmk_battery)); #else +#warning \ + "Using a node labeled BATTERY for the battery sensor is deprecated. Set a zmk,battery chosen node instead. (Ignore this if you don't have a battery sensor.)" static const struct device *battery; #endif From b7b026f20c1c01758b1780a5928efc085e0c0ab9 Mon Sep 17 00:00:00 2001 From: Joel Spadin Date: Fri, 15 Apr 2022 23:17:38 -0500 Subject: [PATCH 08/36] feat(docs): Add battery sensor documentation --- docs/docs/features/battery.md | 38 +++++++++++++++++++++++++++++++++++ docs/sidebars.js | 1 + 2 files changed, 39 insertions(+) create mode 100644 docs/docs/features/battery.md diff --git a/docs/docs/features/battery.md b/docs/docs/features/battery.md new file mode 100644 index 00000000..0b4172c2 --- /dev/null +++ b/docs/docs/features/battery.md @@ -0,0 +1,38 @@ +--- +title: Battery Level +sidebar_label: Battery Level +--- + +If your keyboard has a battery sensor, ZMK will report its battery level to the connected bluetooth host and show it on the keyboard's display, if it has one. + +For split keyboards, only the battery level of the central (usually left) side is reported over bluetooth. + +:::note + +Windows may not properly ask the keyboard to notify it of changes in battery level, so the level shown may be out of date. + +::: + +## Adding a Battery Sensor to a Board + +To enable a battery sensor on a new board, add the driver for the sensor to your board's `.dts` file. ZMK provides two drivers for estimating the battery level using its voltage: + +- `zmk,battery-voltage-divider`: Reads the voltage on an analog input pin. +- `zmk,battery-nrf-vddh`: Reads the power supply voltage on a Nordic nRF52's VDDH pin. + +Zephyr also provides some drivers for fuel gauge ICs such as the TI bq274xx series and Maxim MAX17xxx series. If you use a battery sensor that does not have an existing driver, you will need to write a new driver that supports the `SENSOR_CHAN_GAUGE_STATE_OF_CHARGE` sensor channel and contribute it to Zephyr or ZMK. + +Once you have the sensor driver defined, add a `zmk,battery` property to the `chosen` node and set it to reference the sensor node. For example: + +``` +/ { + chosen { + zmk,battery = &vbatt; + }; + + vbatt: vbatt { + compatible = "zmk,battery-nrf-vddh"; + label = "VBATT"; + }; +} +``` diff --git a/docs/sidebars.js b/docs/sidebars.js index cbeceef7..ea66439b 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -17,6 +17,7 @@ module.exports = { "features/encoders", "features/underglow", "features/backlight", + "features/battery", "features/beta-testing", ], Behaviors: [ From 3e294375b63d5ec288ffc05d85c6b2e376500a73 Mon Sep 17 00:00:00 2001 From: Dom H Date: Mon, 18 Apr 2022 14:40:35 +0100 Subject: [PATCH 09/36] feat(docs): Provide current status of Displays --- docs/docs/features/displays.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/docs/features/displays.md b/docs/docs/features/displays.md index 2b3d001d..f18b3acd 100644 --- a/docs/docs/features/displays.md +++ b/docs/docs/features/displays.md @@ -1,6 +1,10 @@ --- -title: OLED Displays -sidebar_label: OLED Displays +title: Displays +sidebar_label: Displays --- -TODO: Documentation on OLED displays. +Displays in ZMK are currently a proof of concept and official support is coming soon. + +:::info +Although ZMK-powered keyboards _are_ capable of utilizing OLED and ePaper displays, the Displays feature is not yet considered production-ready due to an issue where the display remains blank after resuming from [external power cutoff](../behaviors/power#external-power-control). This issue can be tracked on GitHub at [zmkfirmware/zmk #674](https://github.com/zmkfirmware/zmk/issues/674). +::: From d0176f368585c5bbb0a6a5f69465eb083349eff0 Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Tue, 19 Apr 2022 01:28:22 +0000 Subject: [PATCH 10/36] fix(boards): Enable battery driver for XIAO BLE. --- app/boards/seeeduino_xiao_ble.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/app/boards/seeeduino_xiao_ble.conf b/app/boards/seeeduino_xiao_ble.conf index 92367028..22e6a9b5 100644 --- a/app/boards/seeeduino_xiao_ble.conf +++ b/app/boards/seeeduino_xiao_ble.conf @@ -3,6 +3,7 @@ CONFIG_CONSOLE=n CONFIG_SERIAL=n CONFIG_UART_CONSOLE=n CONFIG_UART_INTERRUPT_DRIVEN=n +CONFIG_ZMK_BATTERY_VOLTAGE_DIVIDER=y CONFIG_ZMK_USB=y CONFIG_ZMK_BLE=y From bbaa6af81b0f70e117264a087a04935b0268d047 Mon Sep 17 00:00:00 2001 From: elagil Date: Sun, 3 Apr 2022 18:53:37 +0200 Subject: [PATCH 11/36] feat(ci): introduce reusable user-config workflow --- .github/workflows/build-user-config.yml | 96 +++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 .github/workflows/build-user-config.yml diff --git a/.github/workflows/build-user-config.yml b/.github/workflows/build-user-config.yml new file mode 100644 index 00000000..ea889db0 --- /dev/null +++ b/.github/workflows/build-user-config.yml @@ -0,0 +1,96 @@ +name: Reusable user config build + +on: + workflow_call: + +jobs: + matrix: + runs-on: ubuntu-latest + name: Fetch Build Keyboards + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install yaml2json + run: python3 -m pip install remarshal + - id: set-matrix + name: Fetch Build Matrix + run: | + matrix=$(yaml2json build.yaml | jq -c .) + yaml2json build.yaml + echo "::set-output name=matrix::${matrix}" + build: + runs-on: ubuntu-latest + container: + image: zmkfirmware/zmk-build-arm:stable + needs: matrix + name: Build + strategy: + fail-fast: false + matrix: ${{fromJson(needs.matrix.outputs.matrix)}} + steps: + - name: Prepare variables + id: variables + run: | + if [ -n "${{ matrix.shield }}" ]; then + EXTRA_CMAKE_ARGS="-DSHIELD=${{ matrix.shield }}" + ARTIFACT_NAME="${{ matrix.shield }}-${{ matrix.board }}-zmk" + DISPLAY_NAME="${{ matrix.shield }} - ${{ matrix.board }}" + else + EXTRA_CMAKE_ARGS= + DISPLAY_NAME="${{ matrix.board }}" + ARTIFACT_NAME="${{ matrix.board }}-zmk" + fi + echo ::set-output name=extra-cmake-args::${EXTRA_CMAKE_ARGS} + echo ::set-output name=artifact-name::${ARTIFACT_NAME} + echo ::set-output name=display-name::${DISPLAY_NAME} + - name: Checkout + uses: actions/checkout@v2 + - name: Cache west modules + uses: actions/cache@v2 + env: + cache-name: cache-zephyr-modules + with: + path: | + modules/ + tools/ + zephyr/ + bootloader/ + zmk/ + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('manifest-dir/west.yml') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - name: West Init + run: west init -l config + - name: West Update + run: west update + - name: West Zephyr export + run: west zephyr-export + - name: West Build (${{ steps.variables.outputs.display-name }}) + run: | + west build -s zmk/app -b ${{ matrix.board }} -- -DZMK_CONFIG=${GITHUB_WORKSPACE}/config ${{ steps.variables.outputs.extra-cmake-args }} ${{ matrix.cmake-args }} + - name: ${{ steps.variables.outputs.display-name }} DTS File + if: ${{ always() }} + run: | + if [ -f "build/zephyr/${{ matrix.board }}.dts.pre.tmp" ]; then cat -n build/zephyr/${{ matrix.board }}.dts.pre.tmp; fi + if [ -f "build/zephyr/zephyr.dts" ]; then cat -n build/zephyr/zephyr.dts; fi + - name: ${{ steps.variables.outputs.display-name }} Kconfig file + run: cat build/zephyr/.config | grep -v "^#" | grep -v "^$" + - name: Rename artifacts + run: | + mkdir build/artifacts + if [ -f build/zephyr/zmk.uf2 ] + then + cp build/zephyr/zmk.uf2 "build/artifacts/${{ steps.variables.outputs.artifact-name }}.uf2" + elif [ -f build/zephyr/zmk.hex ] + then + cp build/zephyr/zmk.hex "build/artifacts/${{ steps.variables.outputs.artifact-name }}.hex" + fi + - name: Archive (${{ steps.variables.outputs.display-name }}) + uses: actions/upload-artifact@v2 + with: + name: firmware + path: build/artifacts From b1687eec2a1a8a4e3110e89fdfb553fbc5895fa9 Mon Sep 17 00:00:00 2001 From: Adrian Date: Sun, 3 Apr 2022 18:53:37 +0200 Subject: [PATCH 12/36] fix(ci): path to custom west.yml Co-authored-by: Joel Spadin --- .github/workflows/build-user-config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-user-config.yml b/.github/workflows/build-user-config.yml index ea889db0..de35ffb4 100644 --- a/.github/workflows/build-user-config.yml +++ b/.github/workflows/build-user-config.yml @@ -58,7 +58,7 @@ jobs: zephyr/ bootloader/ zmk/ - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('manifest-dir/west.yml') }} + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('config/west.yml') }} restore-keys: | ${{ runner.os }}-build-${{ env.cache-name }}- ${{ runner.os }}-build- From 2c4ca7390b5904b0dbd5f88d321ba5bdccddf607 Mon Sep 17 00:00:00 2001 From: elagil Date: Sun, 3 Apr 2022 18:53:37 +0200 Subject: [PATCH 13/36] feat(ci): Use input variables for configuring user build --- .github/workflows/build-user-config.yml | 28 +++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-user-config.yml b/.github/workflows/build-user-config.yml index de35ffb4..7da9a546 100644 --- a/.github/workflows/build-user-config.yml +++ b/.github/workflows/build-user-config.yml @@ -2,6 +2,22 @@ name: Reusable user config build on: workflow_call: + inputs: + build_matrix_path: + description: 'Path to the build matrix file' + default: 'build.yaml' + required: false + type: string + config_path: + description: 'Path to the config directory' + default: 'config' + required: false + type: string + fallback_binary: + description: 'Fallback binary format, if no *.uf2 file was built' + default: 'bin' + required: false + type: string jobs: matrix: @@ -17,8 +33,8 @@ jobs: - id: set-matrix name: Fetch Build Matrix run: | - matrix=$(yaml2json build.yaml | jq -c .) - yaml2json build.yaml + matrix=$(yaml2json ${{ inputs.build_matrix_path }} | jq -c .) + yaml2json ${{ inputs.build_matrix_path }} echo "::set-output name=matrix::${matrix}" build: runs-on: ubuntu-latest @@ -64,14 +80,14 @@ jobs: ${{ runner.os }}-build- ${{ runner.os }}- - name: West Init - run: west init -l config + run: west init -l ${{ inputs.config_path }} - name: West Update run: west update - name: West Zephyr export run: west zephyr-export - name: West Build (${{ steps.variables.outputs.display-name }}) run: | - west build -s zmk/app -b ${{ matrix.board }} -- -DZMK_CONFIG=${GITHUB_WORKSPACE}/config ${{ steps.variables.outputs.extra-cmake-args }} ${{ matrix.cmake-args }} + west build -s zmk/app -b ${{ matrix.board }} -- -DZMK_CONFIG=${GITHUB_WORKSPACE}/${{ inputs.config_path }} ${{ steps.variables.outputs.extra-cmake-args }} ${{ matrix.cmake-args }} - name: ${{ steps.variables.outputs.display-name }} DTS File if: ${{ always() }} run: | @@ -85,9 +101,9 @@ jobs: if [ -f build/zephyr/zmk.uf2 ] then cp build/zephyr/zmk.uf2 "build/artifacts/${{ steps.variables.outputs.artifact-name }}.uf2" - elif [ -f build/zephyr/zmk.hex ] + elif [ -f build/zephyr/zmk.${{ inputs.fallback_binary }} ] then - cp build/zephyr/zmk.hex "build/artifacts/${{ steps.variables.outputs.artifact-name }}.hex" + cp build/zephyr/zmk.${{ inputs.fallback_binary }} "build/artifacts/${{ steps.variables.outputs.artifact-name }}.${{ inputs.fallback_binary }}" fi - name: Archive (${{ steps.variables.outputs.display-name }}) uses: actions/upload-artifact@v2 From 0f70f4005497381062e7edd5fc9f09e3b2e1fb0b Mon Sep 17 00:00:00 2001 From: elagil Date: Sun, 3 Apr 2022 18:53:37 +0200 Subject: [PATCH 14/36] style(ci): add empty lines for readability --- .github/workflows/build-user-config.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/build-user-config.yml b/.github/workflows/build-user-config.yml index 7da9a546..3b9912f9 100644 --- a/.github/workflows/build-user-config.yml +++ b/.github/workflows/build-user-config.yml @@ -28,14 +28,17 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + - name: Install yaml2json run: python3 -m pip install remarshal + - id: set-matrix name: Fetch Build Matrix run: | matrix=$(yaml2json ${{ inputs.build_matrix_path }} | jq -c .) yaml2json ${{ inputs.build_matrix_path }} echo "::set-output name=matrix::${matrix}" + build: runs-on: ubuntu-latest container: @@ -61,8 +64,10 @@ jobs: echo ::set-output name=extra-cmake-args::${EXTRA_CMAKE_ARGS} echo ::set-output name=artifact-name::${ARTIFACT_NAME} echo ::set-output name=display-name::${DISPLAY_NAME} + - name: Checkout uses: actions/checkout@v2 + - name: Cache west modules uses: actions/cache@v2 env: @@ -79,12 +84,16 @@ jobs: ${{ runner.os }}-build-${{ env.cache-name }}- ${{ runner.os }}-build- ${{ runner.os }}- + - name: West Init run: west init -l ${{ inputs.config_path }} + - name: West Update run: west update + - name: West Zephyr export run: west zephyr-export + - name: West Build (${{ steps.variables.outputs.display-name }}) run: | west build -s zmk/app -b ${{ matrix.board }} -- -DZMK_CONFIG=${GITHUB_WORKSPACE}/${{ inputs.config_path }} ${{ steps.variables.outputs.extra-cmake-args }} ${{ matrix.cmake-args }} @@ -93,8 +102,10 @@ jobs: run: | if [ -f "build/zephyr/${{ matrix.board }}.dts.pre.tmp" ]; then cat -n build/zephyr/${{ matrix.board }}.dts.pre.tmp; fi if [ -f "build/zephyr/zephyr.dts" ]; then cat -n build/zephyr/zephyr.dts; fi + - name: ${{ steps.variables.outputs.display-name }} Kconfig file run: cat build/zephyr/.config | grep -v "^#" | grep -v "^$" + - name: Rename artifacts run: | mkdir build/artifacts @@ -105,6 +116,7 @@ jobs: then cp build/zephyr/zmk.${{ inputs.fallback_binary }} "build/artifacts/${{ steps.variables.outputs.artifact-name }}.${{ inputs.fallback_binary }}" fi + - name: Archive (${{ steps.variables.outputs.display-name }}) uses: actions/upload-artifact@v2 with: From e676c79929a50c1c51bb7a7dc1c2b11043a49c17 Mon Sep 17 00:00:00 2001 From: elagil Date: Sun, 3 Apr 2022 18:53:37 +0200 Subject: [PATCH 15/36] fix(ci): generalize path to west.yml --- .github/workflows/build-user-config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-user-config.yml b/.github/workflows/build-user-config.yml index 3b9912f9..78d324ed 100644 --- a/.github/workflows/build-user-config.yml +++ b/.github/workflows/build-user-config.yml @@ -79,7 +79,7 @@ jobs: zephyr/ bootloader/ zmk/ - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('config/west.yml') }} + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('${{ inputs.config_path }}/west.yml') }} restore-keys: | ${{ runner.os }}-build-${{ env.cache-name }}- ${{ runner.os }}-build- From b7771fbdd299e9dbfa606c8c3b1551c5acd401e6 Mon Sep 17 00:00:00 2001 From: elagil Date: Sun, 3 Apr 2022 18:57:35 +0200 Subject: [PATCH 16/36] ci: updated for Zephyr 3.0, cache invalidation --- .github/workflows/build-user-config.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-user-config.yml b/.github/workflows/build-user-config.yml index 78d324ed..0f22bd99 100644 --- a/.github/workflows/build-user-config.yml +++ b/.github/workflows/build-user-config.yml @@ -64,14 +64,15 @@ jobs: echo ::set-output name=extra-cmake-args::${EXTRA_CMAKE_ARGS} echo ::set-output name=artifact-name::${ARTIFACT_NAME} echo ::set-output name=display-name::${DISPLAY_NAME} + echo ::set-output name=zephyr-version::${ZEPHYR_VERSION} - name: Checkout uses: actions/checkout@v2 - name: Cache west modules - uses: actions/cache@v2 + uses: actions/cache@v3.0.1 env: - cache-name: cache-zephyr-modules + cache-name: cache-zephyr-${{ steps.variables.outputs.zephyr-version }}-modules with: path: | modules/ @@ -97,12 +98,7 @@ jobs: - name: West Build (${{ steps.variables.outputs.display-name }}) run: | west build -s zmk/app -b ${{ matrix.board }} -- -DZMK_CONFIG=${GITHUB_WORKSPACE}/${{ inputs.config_path }} ${{ steps.variables.outputs.extra-cmake-args }} ${{ matrix.cmake-args }} - - name: ${{ steps.variables.outputs.display-name }} DTS File - if: ${{ always() }} - run: | - if [ -f "build/zephyr/${{ matrix.board }}.dts.pre.tmp" ]; then cat -n build/zephyr/${{ matrix.board }}.dts.pre.tmp; fi - if [ -f "build/zephyr/zephyr.dts" ]; then cat -n build/zephyr/zephyr.dts; fi - + - name: ${{ steps.variables.outputs.display-name }} Kconfig file run: cat build/zephyr/.config | grep -v "^#" | grep -v "^$" From 142d5187342e37b524b969f3e87b131478f1ac2b Mon Sep 17 00:00:00 2001 From: Adrian Date: Tue, 5 Apr 2022 08:28:45 +0200 Subject: [PATCH 17/36] ci: make cache hash independent of input parameter --- .github/workflows/build-user-config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-user-config.yml b/.github/workflows/build-user-config.yml index 0f22bd99..226a53c1 100644 --- a/.github/workflows/build-user-config.yml +++ b/.github/workflows/build-user-config.yml @@ -80,7 +80,7 @@ jobs: zephyr/ bootloader/ zmk/ - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('${{ inputs.config_path }}/west.yml') }} + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/west.yml', '**/build.yaml') }} restore-keys: | ${{ runner.os }}-build-${{ env.cache-name }}- ${{ runner.os }}-build- From 3ff8014cf299d682f7e76296c0c7e8e53c041a87 Mon Sep 17 00:00:00 2001 From: Adrian Date: Fri, 8 Apr 2022 18:44:12 +0200 Subject: [PATCH 18/36] ci: sort build configuration output Co-authored-by: Albert Y <76888457+filterpaper@users.noreply.github.com> --- .github/workflows/build-user-config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-user-config.yml b/.github/workflows/build-user-config.yml index 226a53c1..cb462b1a 100644 --- a/.github/workflows/build-user-config.yml +++ b/.github/workflows/build-user-config.yml @@ -100,7 +100,7 @@ jobs: west build -s zmk/app -b ${{ matrix.board }} -- -DZMK_CONFIG=${GITHUB_WORKSPACE}/${{ inputs.config_path }} ${{ steps.variables.outputs.extra-cmake-args }} ${{ matrix.cmake-args }} - name: ${{ steps.variables.outputs.display-name }} Kconfig file - run: cat build/zephyr/.config | grep -v "^#" | grep -v "^$" + run: cat build/zephyr/.config | grep -v "^#" | grep -v "^$" | sort - name: Rename artifacts run: | From 6308ab942661656e9ca06787ebb0918df6ffd268 Mon Sep 17 00:00:00 2001 From: Dom H Date: Mon, 18 Apr 2022 17:44:43 +0100 Subject: [PATCH 19/36] fix(docs): Ensure relative links always resolve Linking to the document _file path_ rather than the document _URL_ ensures that the link resolves regardless of trailing slash config. More information is at https://docusaurus.io/docs/docs-markdown-features --- docs/docs/features/displays.md | 2 +- docs/docs/intro.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/features/displays.md b/docs/docs/features/displays.md index f18b3acd..283bf880 100644 --- a/docs/docs/features/displays.md +++ b/docs/docs/features/displays.md @@ -6,5 +6,5 @@ sidebar_label: Displays Displays in ZMK are currently a proof of concept and official support is coming soon. :::info -Although ZMK-powered keyboards _are_ capable of utilizing OLED and ePaper displays, the Displays feature is not yet considered production-ready due to an issue where the display remains blank after resuming from [external power cutoff](../behaviors/power#external-power-control). This issue can be tracked on GitHub at [zmkfirmware/zmk #674](https://github.com/zmkfirmware/zmk/issues/674). +Although ZMK-powered keyboards _are_ capable of utilizing OLED and ePaper displays, the Displays feature is not yet considered production-ready due to an issue where the display remains blank after resuming from [external power cutoff](../behaviors/power.md#external-power-control). This issue can be tracked on GitHub at [zmkfirmware/zmk #674](https://github.com/zmkfirmware/zmk/issues/674). ::: diff --git a/docs/docs/intro.md b/docs/docs/intro.md index 91b4e21b..142dcafc 100644 --- a/docs/docs/intro.md +++ b/docs/docs/intro.md @@ -32,7 +32,7 @@ ZMK is currently missing some features found in other popular firmware. This tab | [Backlight](features/backlight.md) | ✅ | ✅ | ✅ | | One Shot Keys | ✅ | ✅ | ✅ | | [Combo Keys](features/combos.md) | ✅ | | ✅ | -| [Macros](behaviors/macros) | ✅ | ✅ | ✅ | +| [Macros](behaviors/macros.md) | ✅ | ✅ | ✅ | | Mouse Keys | 🚧 | ✅ | ✅ | | Low Active Power Usage | ✅ | | | | Low Power Sleep States | ✅ | ✅ | | From 56d5f4153c22213dd032452ad846272a5ed12246 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Apr 2022 03:35:40 +0000 Subject: [PATCH 20/36] chore(deps): bump async from 2.6.3 to 2.6.4 in /docs Bumps [async](https://github.com/caolan/async) from 2.6.3 to 2.6.4. - [Release notes](https://github.com/caolan/async/releases) - [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md) - [Commits](https://github.com/caolan/async/compare/v2.6.3...v2.6.4) --- updated-dependencies: - dependency-name: async dependency-type: indirect ... Signed-off-by: dependabot[bot] --- docs/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/package-lock.json b/docs/package-lock.json index c72f901b..18a272ca 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -5858,9 +5858,9 @@ "dev": true }, "async": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", - "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", "requires": { "lodash": "^4.17.14" } From e13ea3fbfb46c41a188185faaa8451b9f430fe8e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Apr 2022 05:09:13 +0000 Subject: [PATCH 21/36] chore(deps): bump @fortawesome/react-fontawesome in /docs Bumps [@fortawesome/react-fontawesome](https://github.com/FortAwesome/react-fontawesome) from 0.1.16 to 0.1.18. - [Release notes](https://github.com/FortAwesome/react-fontawesome/releases) - [Changelog](https://github.com/FortAwesome/react-fontawesome/blob/master/CHANGELOG.md) - [Commits](https://github.com/FortAwesome/react-fontawesome/compare/0.1.16...0.1.18) --- updated-dependencies: - dependency-name: "@fortawesome/react-fontawesome" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- docs/package-lock.json | 20 ++++++++++++++++---- docs/package.json | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/package-lock.json b/docs/package-lock.json index 18a272ca..c87e0aba 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -4825,11 +4825,23 @@ } }, "@fortawesome/react-fontawesome": { - "version": "0.1.16", - "resolved": "https://registry.npmjs.org/@fortawesome/react-fontawesome/-/react-fontawesome-0.1.16.tgz", - "integrity": "sha512-aLmzDwC9rEOAJv2UJdMns89VZR5Ry4IHu5dQQh24Z/lWKEm44lfQr1UNalZlkUaQN8d155tNh+CS7ntntj1VMA==", + "version": "0.1.18", + "resolved": "https://registry.npmjs.org/@fortawesome/react-fontawesome/-/react-fontawesome-0.1.18.tgz", + "integrity": "sha512-RwLIB4TZw0M9gvy5u+TusAA0afbwM4JQIimNH/j3ygd6aIvYPQLqXMhC9ErY26J23rDPyDZldIfPq/HpTTJ/tQ==", "requires": { - "prop-types": "^15.7.2" + "prop-types": "^15.8.1" + }, + "dependencies": { + "prop-types": { + "version": "15.8.1", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", + "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", + "requires": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.13.1" + } + } } }, "@hapi/hoek": { diff --git a/docs/package.json b/docs/package.json index 755482b6..978795a8 100644 --- a/docs/package.json +++ b/docs/package.json @@ -19,7 +19,7 @@ "@docusaurus/preset-classic": "^2.0.0-beta.18", "@fortawesome/fontawesome-svg-core": "^1.2.32", "@fortawesome/free-solid-svg-icons": "^5.15.3", - "@fortawesome/react-fontawesome": "^0.1.16", + "@fortawesome/react-fontawesome": "^0.1.18", "@mdx-js/react": "^1.6.22", "classnames": "^2.2.6", "js-yaml": "^4.1.0", From 158ac2720724123b91e6534c95710804cc49243e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Apr 2022 10:03:28 +0000 Subject: [PATCH 22/36] chore(deps-dev): bump eslint-plugin-mdx from 1.13.0 to 1.17.0 in /docs Bumps [eslint-plugin-mdx](https://github.com/mdx-js/eslint-mdx) from 1.13.0 to 1.17.0. - [Release notes](https://github.com/mdx-js/eslint-mdx/releases) - [Changelog](https://github.com/mdx-js/eslint-mdx/blob/master/CHANGELOG.md) - [Commits](https://github.com/mdx-js/eslint-mdx/compare/v1.13.0...v1.17.0) --- updated-dependencies: - dependency-name: eslint-plugin-mdx dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- docs/package-lock.json | 96 +++++++++++++++++------------------------- docs/package.json | 2 +- 2 files changed, 40 insertions(+), 58 deletions(-) diff --git a/docs/package-lock.json b/docs/package-lock.json index c87e0aba..d09c5888 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -7581,21 +7581,29 @@ "dev": true }, "eslint-mdx": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/eslint-mdx/-/eslint-mdx-1.13.0.tgz", - "integrity": "sha512-Yqc5mnh2JMEm9yTp6NUnfOg1wXGLibCqQTjvb5+EQH4LtQEmWG0DtqWUXWHRy0gmy/3lBdN9Zkc5KGwAizaTrQ==", + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/eslint-mdx/-/eslint-mdx-1.17.0.tgz", + "integrity": "sha512-O8+JRfwCzpoR2P6zUI1GDAAM/bsuzcoBS1ArvpQrgQO/E2Km0vBmM15ukiJxZ+YUh5d+qDlrqha0fZB50MojJQ==", "dev": true, "requires": { + "cosmiconfig": "^7.0.1", "remark-mdx": "^1.6.22", "remark-parse": "^8.0.3", - "tslib": "^2.2.0", - "unified": "^9.2.1" + "remark-stringify": "^8.1.1", + "tslib": "^2.3.1", + "unified": "^9.2.2" }, "dependencies": { + "tslib": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", + "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==", + "dev": true + }, "unified": { - "version": "9.2.1", - "resolved": "https://registry.npmjs.org/unified/-/unified-9.2.1.tgz", - "integrity": "sha512-juWjuI8Z4xFg8pJbnEZ41b5xjGUWGHqXALmBZ3FC3WX0PIx1CZBIIJ6mXbYMcf6Yw4Fi0rFUTA1cdz/BglbOhA==", + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/unified/-/unified-9.2.2.tgz", + "integrity": "sha512-Sg7j110mtefBD+qunSLO1lqOEKdrwBFBrR6Qd8f4uwkhWNlbkaqwHse6e7QvD3AP/MNoJdEDLaf8OxYyoWgorQ==", "dev": true, "requires": { "bail": "^1.0.0", @@ -7609,58 +7617,32 @@ } }, "eslint-plugin-markdown": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-markdown/-/eslint-plugin-markdown-2.2.0.tgz", - "integrity": "sha512-Ctuc7aP1tU92qnFwVO1wDLEzf1jqMxwRkcSTw7gjbvnEqfh5CKUcTXM0sxg8CB2KDXrqpTuMZPgJ1XE9Olr7KA==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-markdown/-/eslint-plugin-markdown-2.2.1.tgz", + "integrity": "sha512-FgWp4iyYvTFxPwfbxofTvXxgzPsDuSKHQy2S+a8Ve6savbujey+lgrFFbXQA0HPygISpRYWYBjooPzhYSF81iA==", "dev": true, "requires": { "mdast-util-from-markdown": "^0.8.5" } }, "eslint-plugin-mdx": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-mdx/-/eslint-plugin-mdx-1.13.0.tgz", - "integrity": "sha512-oZ/R9OmSx1gZs52CO58HTHlJXRKoZtF6ZMaWP+sOcSGMFxoddoPr9PDgpP52ab5TWu5yVl5guR9D+GMfzkR2Uw==", + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-mdx/-/eslint-plugin-mdx-1.17.0.tgz", + "integrity": "sha512-Kicizy+fbfsB2UxTDXP92qTtFqITApu4v4DRQUfXMoPwBHeQRvZnaEtXu2S9aia51GYRYsMSqUvoPPih/5oB+g==", "dev": true, "requires": { - "cosmiconfig": "^7.0.0", - "eslint-mdx": "^1.13.0", - "eslint-plugin-markdown": "^2.1.0", - "remark-mdx": "^1.6.22", - "remark-parse": "^8.0.3", - "remark-stringify": "^8.1.1", - "synckit": "^0.1.5", - "tslib": "^2.2.0", - "unified": "^9.2.1", + "eslint-mdx": "^1.17.0", + "eslint-plugin-markdown": "^2.2.1", + "synckit": "^0.4.1", + "tslib": "^2.3.1", "vfile": "^4.2.1" }, "dependencies": { - "cosmiconfig": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.0.tgz", - "integrity": "sha512-pondGvTuVYDk++upghXJabWzL6Kxu6f26ljFw64Swq9v6sQPUL3EUlVDV56diOjpCayKihL6hVe8exIACU4XcA==", - "dev": true, - "requires": { - "@types/parse-json": "^4.0.0", - "import-fresh": "^3.2.1", - "parse-json": "^5.0.0", - "path-type": "^4.0.0", - "yaml": "^1.10.0" - } - }, - "unified": { - "version": "9.2.1", - "resolved": "https://registry.npmjs.org/unified/-/unified-9.2.1.tgz", - "integrity": "sha512-juWjuI8Z4xFg8pJbnEZ41b5xjGUWGHqXALmBZ3FC3WX0PIx1CZBIIJ6mXbYMcf6Yw4Fi0rFUTA1cdz/BglbOhA==", - "dev": true, - "requires": { - "bail": "^1.0.0", - "extend": "^3.0.0", - "is-buffer": "^2.0.0", - "is-plain-obj": "^2.0.0", - "trough": "^1.0.0", - "vfile": "^4.0.0" - } + "tslib": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", + "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==", + "dev": true } } }, @@ -12827,19 +12809,19 @@ } }, "synckit": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.1.5.tgz", - "integrity": "sha512-s9rDbMJAF5SDEwBGH/DvbN/fb5N1Xu1boL4Uv66idbCbtosNX3ikUsFvGhROmPXsvlMYMcT5ksmkU5RSnkFi9Q==", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.4.1.tgz", + "integrity": "sha512-ngUh0+s+DOqEc0sGnrLaeNjbXp0CWHjSGFBqPlQmQ+oN/OfoDoYDBXPh+b4qs1M5QTk5nuQ3AmVz9+2xiY/ldw==", "dev": true, "requires": { - "tslib": "^2.2.0", + "tslib": "^2.3.1", "uuid": "^8.3.2" }, "dependencies": { - "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "tslib": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", + "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==", "dev": true } } diff --git a/docs/package.json b/docs/package.json index 978795a8..f8ef6dfe 100644 --- a/docs/package.json +++ b/docs/package.json @@ -52,7 +52,7 @@ "@types/react-router-dom": "^5.1.7", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", - "eslint-plugin-mdx": "^1.13.0", + "eslint-plugin-mdx": "^1.17.0", "eslint-plugin-react": "^7.28.0", "json-schema-to-typescript": "^10.1.5", "mustache": "^4.2.0", From c8c273d83b6806e53116748b8e5a216ed52ca1a1 Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Sun, 17 Apr 2022 14:30:22 +0000 Subject: [PATCH 23/36] feat(docs): Add TOC to supported hardware page. --- docs/docs/hardware.mdx | 42 +++++++- docs/src/components/hardware-list.tsx | 133 ++++++++------------------ docs/src/components/hardware-utils.ts | 70 ++++++++++++++ docs/tsconfig.json | 2 +- 4 files changed, 151 insertions(+), 96 deletions(-) create mode 100644 docs/src/components/hardware-utils.ts diff --git a/docs/docs/hardware.mdx b/docs/docs/hardware.mdx index 76a0a3cb..d2b6aa9d 100644 --- a/docs/docs/hardware.mdx +++ b/docs/docs/hardware.mdx @@ -6,12 +6,48 @@ sidebar_label: Supported Hardware import HardwareList from "@site/src/components/hardware-list"; import Metadata from "@site/src/data/hardware-metadata.json"; +import Heading from "@theme/Heading"; + +import { groupedMetadata } from "@site/src/components/hardware-utils"; + +export const toc = [ + { + value: "Onboard Controller Keyboards", + id: "onboard", + level: 2, + }, + { + value: "Composite Keyboards", + id: "composite", + level: 2, + }, + ...Object.values(groupedMetadata(Metadata).interconnects).map( + ({ interconnect }) => ({ + value: `${interconnect.name} Interconnect`, + id: interconnect.id, + level: 3, + }) + ), + { + value: "Other Hardware", + id: "other-hardware", + level: 2, + }, + { + value: "Contributing", + id: "contributing", + level: 2, + }, +]; + With the solid technical foundation of Zephyr™ RTOS, ZMK can support a wide diversity of hardware targets. That being said, there are currently only a few specific [boards](/docs/faq#what-is-a-board)/[shields](faq.md#what-is-a-shield) that have been implemented and tested by the ZMK contributors. -## Other Hardware + + Other Hardware + In addition to the basic keyboard functionality, there is some initial support for additional keyboard hardware: @@ -22,6 +58,8 @@ In addition to the basic keyboard functionality, there is some initial support f Until detailed documentation is available, feel free to ask questions about how these are supported in the [Discord server](https://zmk.dev/community/discord/invite). -## Contributing + + Contributing + If you'd like to add support for a new keyboard shield, head over to the [New Keyboard Shield](development/new-shield.md) documentation. diff --git a/docs/src/components/hardware-list.tsx b/docs/src/components/hardware-list.tsx index e611f5cf..54034ada 100644 --- a/docs/src/components/hardware-list.tsx +++ b/docs/src/components/hardware-list.tsx @@ -1,11 +1,9 @@ import React from "react"; -import { - Board, - HardwareMetadata, - Interconnect, - Shield, -} from "../hardware-metadata"; +import Heading from "@theme/Heading"; + +import { HardwareMetadata } from "../hardware-metadata"; +import { groupedMetadata, InterconnectDetails } from "./hardware-utils"; interface HardwareListProps { items: HardwareMetadata[]; @@ -53,12 +51,6 @@ function HardwareLineItem({ item }: { item: HardwareMetadata }) { ); } -interface InterconnectDetails { - interconnect?: Interconnect; - boards: Board[]; - shields: Shield[]; -} - function mapInterconnect({ interconnect, boards, @@ -70,15 +62,17 @@ function mapInterconnect({ return (
-

{interconnect.name} Interconnect

+ + {interconnect.name} Interconnect + {interconnect.description &&

{interconnect.description}

} -
Boards
+ Boards
    {boards.map((s) => ( ))}
-
Shields
+ Shields