Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docs) Adds a feature page about dongles #2401

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e5c19a1
Adds initial draft version of splits and dongle
RasmusKoit Aug 3, 2024
89d47f1
Adds a mermaid diagram explaining the connection. Add explanation abo…
RasmusKoit Aug 3, 2024
8c95330
adds tailend of a warning
RasmusKoit Aug 3, 2024
26f3c7c
Adds link to further explain reset behavior on splits kbs
RasmusKoit Aug 3, 2024
f5ff4e3
Tests commenting out documentation
RasmusKoit Aug 3, 2024
8ca4971
Adds a section about building the firmware
RasmusKoit Aug 3, 2024
6e622eb
Fixes a typo in reset link
RasmusKoit Aug 3, 2024
877d654
adds clarifing comments about microcontrollers setup
RasmusKoit Aug 4, 2024
997fc9f
removes svg, adds png
RasmusKoit Aug 4, 2024
439c045
Improves benefits/disadvantages section.
RasmusKoit Aug 4, 2024
21bb47d
Removes section for dongle.conf
RasmusKoit Aug 4, 2024
afe4002
rename from splits to dongle
RasmusKoit Aug 5, 2024
cf74b62
squash after rebase
RasmusKoit Aug 10, 2024
4da4704
adds a line for split keyboards
RasmusKoit Aug 10, 2024
c791f9f
Update docs/docs/features/dongle.mdx
RasmusKoit Aug 11, 2024
d3e821e
removes unused picture
RasmusKoit Aug 11, 2024
a27a553
Update docs/docs/features/dongle.mdx
RasmusKoit Aug 11, 2024
9a94cc7
Merge branch 'dongle-doc' of github.com:RasmusKoit/zmk into dongle-doc
RasmusKoit Aug 11, 2024
e85a34b
Update docs/docs/features/dongle.mdx
RasmusKoit Aug 11, 2024
7fea1a7
Update docs/docs/features/dongle.mdx
RasmusKoit Aug 11, 2024
aa89b74
rephrase from us to you
RasmusKoit Aug 11, 2024
61b0203
Update docs/docs/features/dongle.mdx
RasmusKoit Aug 18, 2024
f06f261
Update docs/docs/features/dongle.mdx
RasmusKoit Aug 18, 2024
d72ae98
Update docs/docs/features/dongle.mdx
RasmusKoit Aug 18, 2024
c64642f
Update docs/docs/features/dongle.mdx
RasmusKoit Aug 18, 2024
900ff1f
Update docs/docs/features/dongle.mdx
RasmusKoit Aug 18, 2024
83e6241
Update docs/docs/features/dongle.mdx
RasmusKoit Aug 18, 2024
344936e
Update docs/docs/features/dongle.mdx
RasmusKoit Aug 18, 2024
0eb3770
Update dongle configuration for split keyboard support.
RasmusKoit Aug 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
208 changes: 208 additions & 0 deletions docs/docs/features/dongle.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
---
title: Keyboard Dongle
sidebar_label: Keyboard Dongle
---

import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

:::warning
This implementation is experimental and subject to change.

The information below is for [shield+board](../faq.md#why-boards-and-shields-why-not-just-keyboard) configuration, [board](../faq.md#what-is-a-board) builds is not documented.
:::

A bluetooth dongle can be added to any keyboard running ZMK. The result is a [split keyboard](./split-keyboards.md) with the dongle as "central". There are a number of advantages to adding a dongle, but also some disadvantages:

Benefits:

- The "central" dongle results in increased battery life for the keyboard/former "central", as it is now a peripheral.
- It is easier to connect to the host device.

Disadvantages:

- An extra microcontroller is needed.
- The keyboard becomes unusable without the dongle.

:::note
Depending on how the dongle is used, there are some additional [latency considerations](./split-keyboards.md#latency-considerations) to keep in mind.
:::
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a product liability perspective, I'd say "in some situations, ..." as poor Bluetooth connectivity can push latency even higher. Is it worth calling out one of the more common scenarios?



## Editing a Keyboard Definition to Support a Dongle

You will modify the [files defining your keyboard](../config/index.md#shield-folder) to support a dongle.
The recommended approach to doing so (found below) allows you to easily enable a dongle, but it is disabled by default.
This is done to ensure that backwards compatibility is maintained for users who do not wish to use a dongle.

### Shield Configuration Files


Start by adding the dongle body to the shield configuration.

```kconfig title="Kconfig.shield"
config SHIELD_MY_KEYBOARD_DONGLE
def_bool $(shields_list_contains,my_keyboard_dongle)
```

### Shield Defconfig Files

Next, add the dongle configuration to your keyboard's `Kconfig.defconfig`.

<Tabs
defaultValue="unibody"
values={[
{label: 'Unibody Keyboard', value: 'unibody'},
{label: 'Split Keyboard', value: 'split'},
]}
>
<TabItem value="unibody">

```kconfig title="Kconfig.defconfig"
if SHIELD_MY_KEYBOARD_DONGLE

config ZMK_KEYBOARD_NAME
default "My Board"

config ZMK_SPLIT_ROLE_CENTRAL
default y

config ZMK_SPLIT
default y

# Prevent the dongle from going to sleep
config ZMK_SLEEP
default n

Copy link

@jeffsf jeffsf Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, this [power increase] is optional and unrelated to using a dongle. I agree it may be helpful and perhaps merits a text reference to documentation of BT_CTLR_TX_PWR_PLUS_8 such as https://zmk.dev/docs/troubleshooting/connection-issues

# Increase the transmit power of the dongle
config BT_CLTR_TX_PWR_PLUS_8
default y

endif

if SHIELD_MY_KEYBOARD
config ZMK_KEYBOARD_NAME
default "My Board"

endif
```

</TabItem>
<TabItem value="split">

Add the following to your `Kconfig.defconfig` file.

```kconfig title="Kconfig.defconfig"
if SHIELD_MY_KEYBOARD_DONGLE || SHIELD_MY_KEYBOARD_LEFT || SHIELD_MY_KEYBOARD_RIGHT

config ZMK_SPLIT
default y

endif

if SHIELD_MY_KEYBOARD_DONGLE

config ZMK_KEYBOARD_NAME
default "My Keyboard"

config ZMK_SPLIT_ROLE_CENTRAL
default y

config ZMK_SPLIT_BLE_CENTRAL_PERIPHERALS
default 2

# Increase the transmit power of the dongle
config BT_CLTR_TX_PWR_PLUS_8
default y

endif
```

Modify the `Kconfig.defconfig` file to include the following:

```kconfig title="Kconfig.defconfig"

if SHIELD_MY_KEYBOARD_LEFT

# Setting this to y will make the left half the central
# We want it to be the central when dongle is not used
config ZMK_SPLIT_ROLE_CENTRAL
default y

# Check if the left half is the central
if ZMK_SPLIT_ROLE_CENTRAL
config ZMK_KEYBOARD_NAME
default "My Keyboard"

endif # ZMK_SPLIT_ROLE_CENTRAL

endif # SHIELD_MY_KEYBOARD_LEFT
```

</TabItem>
</Tabs>

### Dongle Overlay File

Replace the `kscan` with `kscan-mock` in the dongle overlay.

:::warning
Matrix transform must be included here or in the `my_keyboard.dtsi` file.
:::

```dts title="my_keyboard_dongle.overlay"
// import the default shield configuration
#include "my_keyboard.dtsi"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the common shield configuration is imported and different boards are used for the dongle than for the shields, then this can lead to problems if board-specific aliases (e.g. &pro_micro, &xiao_d) are used.
I therefore had to delete unused nodes with these aliases (e.g. /delete-node/ &kscan0;), but perhaps there is a nicer solution.


&kscan {
compatible = "zmk,kscan-mock";

columns = <0>;
rows = <0>;
events = <0>;
}

```


## Enabling the Dongle

Now it is possible to enable the dongle in the user configuration.

For a split keyboard, change this

```kconfig title="config/my_keyboard_left.conf"
# Disable central role to use dongle
CONFIG_ZMK_SPLIT_ROLE_CENTRAL=n
```

For a unibody keyboard, change this

```kconfig title="config/my_keyboard.conf"
# Enable split functionality, this will put the unibody keyboard in peripheral mode
CONFIG_ZMK_SPLIT=y
```


## Building the firmware

Add the appropriate lines to your `build.yml` file to build the firmware for your dongle, in addition to the other parts of your keyboard.

```yaml
include:
# -----------------------------------------
# Your other keyboard parts here
# -----------------------------------------
- board: nice_nano_v2
shield: my_keyboard_dongle
- board: nice_nano_v2
shield: settings_reset
```

:::note
Any microcontroller with BLE support can be used as a dongle.
:::

:::warning
Before flashing your new firmware, flash the `settings_reset` [UF2 firmware](../troubleshooting/connection-issues.mdx#acquiring-a-reset-uf2) on all devices.
:::
1 change: 1 addition & 0 deletions docs/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module.exports = {
"features/backlight",
"features/battery",
"features/soft-off",
"features/dongle",
],
},
{
Expand Down
Loading