Skip to content

Commit

Permalink
add: dongle mode
Browse files Browse the repository at this point in the history
Add configuration to use the keyboard with a dongle. The benefit of this approach is not requiring bluetooth from the host device and a longer battery life for both keyboard halves.
  • Loading branch information
zeljkobekcic authored Jul 13, 2024
2 parents 6780fcb + cc93a9d commit e7c7cad
Show file tree
Hide file tree
Showing 25 changed files with 426 additions and 1,248 deletions.
Binary file added .DS_Store
Binary file not shown.
25 changes: 0 additions & 25 deletions .github/workflows/doc.yml

This file was deleted.

5 changes: 0 additions & 5 deletions .vscode/settings.json

This file was deleted.

12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
# Temper ZMK Config

This is my personal ZMK config for the [temper](https://github.com/raeedcho/temper).
This is my personal ZMK config for the [temper](https://github.com/raeedcho/temper). This repository contains zmk configuration for the Temper keyboard using two microcontrollers and additionally on configuration using a dongle which is connected to your computer via cable.

## How to build locally

Additional requirements: `yq`, `jq`

Change the paths in the environment variables in the `.build.sh`, then run it.

```shell
./build.sh
```

![Temper Keymap](keymap_img/temper.svg)
This will create a directory called `output` and in there are all the `.uf2` files

## Extra notes on the dongle part

1. Flash all three microcontrollers with the reset firmware which has been build. All three with the same `.uf2` firmware. More information about this step can be found in the official documentation of ZMK <https://zmk.dev/docs/troubleshooting/connection-issues#acquiring-a-reset-uf2>.
2. Flash all microcontrollers with their respective firmware
3. Turn off bluetooth, plug in the dongle and everything should be working out of the box.
31 changes: 15 additions & 16 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
ZMK_APP_PATH="$HOME/Projects/Private/zmk/app"
ZMK_CONFIG_PATH="$HOME/Projects/Private/temper-zmk-config/config"
ZMK_EXTRA_MODULES_PATH="$HOME/Projects/Private/temper-zmk-config"
OUTPUT_DIRECTORY="$HOME/Projects/Private/temper-zmk-config/outputs/"
ZMK_CONFIG_ROOT_PATH="$HOME/Projects/Private/temper-zmk-config"
OUTPUT_DIRECTORY="$ZMK_CONFIG_ROOT_PATH/outputs/"

rm -rf "$OUTPUT_DIRECTORY"
mkdir -p "$OUTPUT_DIRECTORY"

cd "$ZMK_APP_PATH"
source ../.venv/bin/activate
(
cd "$ZMK_APP_PATH"
source ../.venv/bin/activate

# format to json lines then read ech json object per loop iterationn
yq -o=json -I=0 '.include[]' "$ZMK_EXTRA_MODULES_PATH/build.yaml" | while read line; do
board=$(echo $line | jq -r '.board')
shield=$(echo $line | jq -r '.shield')
# format to json lines then read ech json object per loop iterationn
yq -o=json -I=0 '.include[]' "$ZMK_CONFIG_ROOT_PATH/build.yaml" | while read -r line; do
board=$(echo "$line" | jq -r '.board')
shield=$(echo "$line" | jq -r '.shield')

west build -d "build/$shield-$board" -b $board --pristine -- -DZMK_CONFIG="$ZMK_CONFIG_PATH" -DSHIELD=$shield # -DZMK_EXTRA_MODULES="$ZMK_EXTRA_MODULES_PATH"
cp "build/$shield-$board/zephyr/zmk.uf2" "$OUTPUT_DIRECTORY/$shield-$board.uf2"
done
west build -d "build/$shield-$board" -b "$board" --pristine -- -DZMK_CONFIG="$ZMK_CONFIG_ROOT_PATH/config" -DSHIELD="$shield"
cp "build/$shield-$board/zephyr/zmk.uf2" "$OUTPUT_DIRECTORY/$shield-$board.uf2"
done

deactivate
deactivate

rm -rf build

cd -
rm -rf build
)
9 changes: 9 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,12 @@ include:
shield: temper_left
- board: nice_nano_v2
shield: temper_right
- board: nice_nano_v2
shield: temper_dongle_left
- board: nice_nano_v2
shield: temper_dongle_right
- board: nice_nano_v2
shield: temper_dongle_dongle
- board: nice_nano_v2
shield: settings_reset

16 changes: 16 additions & 0 deletions config/boards/shields/temper-dongle/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
if SHIELD_TEMPER_DONGLE

config ZMK_KEYBOARD_NAME
default "Temper Dongle"

config ZMK_SPLIT_ROLE_CENTRAL
default y

endif

if SHIELD_TEMPER_LEFT || SHIELD_TEMPER_RIGHT || SHIELD_TEMPER_DONGLE

config ZMK_SPLIT
default y

endif
11 changes: 11 additions & 0 deletions config/boards/shields/temper-dongle/Kconfig.shield
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (c) 2020 Pete Johanson
# SPDX-License-Identifier: MIT

config SHIELD_TEMPER_LEFT
def_bool $(shields_list_contains,temper_dongle_left)

config SHIELD_TEMPER_RIGHT
def_bool $(shields_list_contains,temper_dongle_right)

config SHIELD_TEMPER_DONGLE
def_bool $(shields_list_contains,temper_dongle_dongle)
47 changes: 47 additions & 0 deletions config/boards/shields/temper-dongle/boards/nice_nano.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include <dt-bindings/led/led.h>

&pinctrl {
spi3_default: spi3_default {
group1 {
psels = <NRF_PSEL(SPIM_MOSI, 0, 6)>;
};
};

spi3_sleep: spi3_sleep {
group1 {
psels = <NRF_PSEL(SPIM_MOSI, 0, 6)>;
low-power-enable;
};
};
};

&spi3 {
compatible = "nordic,nrf-spim";
status = "okay";

pinctrl-0 = <&spi3_default>;
pinctrl-1 = <&spi3_sleep>;
pinctrl-names = "default", "sleep";

led_strip: ws2812@0 {
compatible = "worldsemi,ws2812-spi";
label = "WS2812";

/* SPI */
reg = <0>; /* ignored, but necessary for SPI bindings */
spi-max-frequency = <4000000>;

/* WS2812 */
chain-length = <10>; /* arbitrary; change at will */
spi-one-frame = <0x70>;
spi-zero-frame = <0x40>;

color-mapping = <LED_COLOR_ID_GREEN LED_COLOR_ID_RED LED_COLOR_ID_BLUE>;
};
};

/ {
chosen {
zmk,underglow = &led_strip;
};
};
47 changes: 47 additions & 0 deletions config/boards/shields/temper-dongle/boards/nice_nano_v2.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include <dt-bindings/led/led.h>

&pinctrl {
spi3_default: spi3_default {
group1 {
psels = <NRF_PSEL(SPIM_MOSI, 0, 6)>;
};
};

spi3_sleep: spi3_sleep {
group1 {
psels = <NRF_PSEL(SPIM_MOSI, 0, 6)>;
low-power-enable;
};
};
};

&spi3 {
compatible = "nordic,nrf-spim";
status = "okay";

pinctrl-0 = <&spi3_default>;
pinctrl-1 = <&spi3_sleep>;
pinctrl-names = "default", "sleep";

led_strip: ws2812@0 {
compatible = "worldsemi,ws2812-spi";
label = "WS2812";

/* SPI */
reg = <0>; /* ignored, but necessary for SPI bindings */
spi-max-frequency = <4000000>;

/* WS2812 */
chain-length = <10>; /* arbitrary; change at will */
spi-one-frame = <0x70>;
spi-zero-frame = <0x40>;

color-mapping = <LED_COLOR_ID_GREEN LED_COLOR_ID_RED LED_COLOR_ID_BLUE>;
};
};

/ {
chosen {
zmk,underglow = &led_strip;
};
};
1 change: 1 addition & 0 deletions config/boards/shields/temper-dongle/temper.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_BT_CTLR_TX_PWR_PLUS_8=y
46 changes: 46 additions & 0 deletions config/boards/shields/temper-dongle/temper.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2020 Pete Johanson
*
* SPDX-License-Identifier: MIT
*/

#include <dt-bindings/zmk/matrix_transform.h>

/ {
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 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
;

};

// TODO: per-key RGB node(s)?
};
Loading

0 comments on commit e7c7cad

Please sign in to comment.