Skip to content

Commit

Permalink
Initial shield
Browse files Browse the repository at this point in the history
Change caps word to shell launch

add a README and update BT config

test new values for track ball

test new values for track ball

adjust automouse timeout

shift around some keys

Test Hyper

Working Meh & Hyper

add tap-preferred flavor to keymap home row

add tap-preferred to number keys

update thumb button

Update num keys and thumb key

Change scrolling speed

add <> to numbers in keymap

try adjusting mouse keys scroll speed

try adjusting mouse keys scroll speed with numbers in <>

try adjusting mouse keys scroll speed with numbers in <>

remove scroll numbers

add layer one to the mouse scroll layers

test ac scrolling

change cpi values

change cpi values

add trackball snipe layer

adjust cpi to use dividor

add slow mouse layer for sniping

remove dividor on snipe and attach it to layer 8

make top thumb key only layer 8 and move middle click to another slot

add mouse keys and L8 toggle to L8

adjust the speed of the trackball down

adjust the speed of the trackball down

adjust the speed of the trackball down

added layer 1 back into the scroll layers

change all right meta buttons to left meta

update symbols layer

combine the build jobs for qwerty and colemak dh

combine the build jobs for qwerty and colemak dh and add back in build conditions

combine the build jobs for qwerty and colemak dh

combine the build jobs for qwerty and colemak dh

combine the build jobs for qwerty and colemak dh

combine the build jobs for qwerty and colemak dh

combine the build jobs for qwerty and colemak dh

combine the build jobs for qwerty and colemak dh

combine the build jobs for qwerty and colemak dh

combine the build jobs for qwerty and colemak dh

combine the build jobs for qwerty and colemak dh

combine the build jobs for qwerty and colemak dh

combine the build jobs for qwerty and colemak dh

combine the build jobs for qwerty and colemak dh

combine the build jobs for qwerty and colemak dh

combine the build jobs for qwerty and colemak dh

adjusted the path to the keymap files

added the board and shield to the matrix variables

added the board and shield to the matrix variables

combine the build jobs for qwerty and colemak dh

add board back into the matrix

add board back into the matrix

add board back into the matrix

add board back into the matrix

add board back into the matrix

add colemak hd and qwerty to the same build

add colemak hd and qwerty to the same build

add colemak hd and qwerty to the same build

add colemak hd and qwerty to the same build

add colemak hd and qwerty to the same build

add colemak hd and qwerty to the same build

add colemak hd and qwerty to the same build

add colemak hd and qwerty to the same build

add colemak hd and qwerty to the same build

try just two boards

try just default keymap

change build.yaml

change build.yaml

change build.yaml

change build.yaml

change build.yaml

change build.yaml

change build.yaml

change build.yaml

change build.yaml

change build.yaml

separate the artifacts by layout

separate the artifacts by layout

separate the artifacts by layout

working with separate artifacts
  • Loading branch information
280Zo committed Aug 3, 2024
1 parent 9cb5d14 commit 8491237
Show file tree
Hide file tree
Showing 19 changed files with 836 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ on: [push, pull_request, workflow_dispatch]

jobs:
build:
uses: zmkfirmware/zmk/.github/workflows/build-user-config.yml@main
uses: ./.github/workflows/user_config_build.yaml
# uses: zmkfirmware/zmk/.github/workflows/build-user-config.yml@main
191 changes: 191 additions & 0 deletions .github/workflows/user_config_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
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
keymap_path:
description: "Path to the keymap directory"
default: "config/boards/shields/charybdis-mini-wireless/keymaps"
required: false
type: string
fallback_binary:
description: "Fallback binary format, if no *.uf2 file was built"
default: "bin"
required: false
type: string

jobs:
matrix:
runs-on: ubuntu-latest
name: Fetch Build Keyboards
outputs:
build_matrix: ${{ env.build_matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install yaml2json
run: python3 -m pip install remarshal

- name: Fetch Build Matrix
run: |
echo "build_matrix=$(yaml2json '${{ inputs.build_matrix_path }}' | jq -c .)" >> $GITHUB_ENV
yaml2json "${{ inputs.build_matrix_path }}" | jq
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.build_matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Create build directory
run: |
echo "build_dir=$(mktemp -d)" >> $GITHUB_ENV
- name: Prepare variables
shell: sh -x {0}
env:
board: ${{ matrix.board }}
shield: ${{ matrix.shield }}
keymap: ${{ matrix.keymap }}
artifact_name: ${{ matrix.artifact-name }}
snippet: ${{ matrix.snippet }}
run: |
if [ -e zephyr/module.yml ]; then
export zmk_load_arg=" -DZMK_EXTRA_MODULES='${GITHUB_WORKSPACE}'"
new_tmp_dir="${TMPDIR:-/tmp}/zmk-config"
mkdir -p "${new_tmp_dir}"
echo "base_dir=${new_tmp_dir}" >> $GITHUB_ENV
else
echo "base_dir=${GITHUB_WORKSPACE}" >> $GITHUB_ENV
fi
if [ -n "${snippet}" ]; then
extra_west_args="-S \"${snippet}\""
fi
echo "zephyr_version=${ZEPHYR_VERSION}" >> $GITHUB_ENV
echo "extra_west_args=${extra_west_args}" >> $GITHUB_ENV
echo "extra_cmake_args=${shield:+-DSHIELD=\"$shield\"}${zmk_load_arg}" >> $GITHUB_ENV
echo "display_name=${shield:+$shield - }${board} - ${keymap}" >> $GITHUB_ENV
echo "artifact_name=${artifact_name:-${shield:+$shield-}${board}-zmk-${keymap}}" >> $GITHUB_ENV
- name: Copy config files to isolated temporary directory
run: |
if [ "${{ env.base_dir }}" != "${GITHUB_WORKSPACE}" ]; then
mkdir "${{ env.base_dir }}/${{ inputs.config_path }}"
cp -R ${{ inputs.config_path }}/* "${{ env.base_dir }}/${{ inputs.config_path }}/"
cp -R ${{ inputs.keymap_path }}/${{ matrix.keymap }}.keymap \
"${{ env.base_dir }}/${{ inputs.config_path }}/charybdis.keymap"
fi
- name: Cache west modules
uses: actions/cache@v4
continue-on-error: true
env:
cache_name: cache-zephyr-${{ env.zephyr_version }}-modules
with:
path: |
${{ env.base_dir }}/modules/
${{ env.base_dir }}/tools/
${{ env.base_dir }}/zephyr/
${{ env.base_dir }}/bootloader/
${{ env.base_dir }}/zmk/
key: ${{ runner.os }}-build-${{ env.cache_name }}-${{ hashFiles('**/west.yml', '**/build.yaml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache_name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: West Init
working-directory: ${{ env.base_dir }}
run: west init -l "${{ env.base_dir }}/${{ inputs.config_path }}"

- name: West Update
working-directory: ${{ env.base_dir }}
run: west update

- name: West Zephyr export
working-directory: ${{ env.base_dir }}
run: west zephyr-export

- name: West Build (${{ env.display_name }})
working-directory: ${{ env.base_dir }}
shell: sh -x {0}
run: west build -s zmk/app -d "${{ env.build_dir }}" -b "${{ matrix.board }}" ${{ env.extra_west_args }} -- -DZMK_CONFIG=${{ env.base_dir }}/${{ inputs.config_path }} ${{ env.extra_cmake_args }} ${{ matrix.cmake-args }}

- name: ${{ env.display_name }} Kconfig file
run: |
if [ -f "${{ env.build_dir }}/zephyr/.config" ]
then
grep -v -e "^#" -e "^$" "${{ env.build_dir }}/zephyr/.config" | sort
else
echo "No Kconfig output"
fi
if: ${{ !cancelled() }}

- name: ${{ env.display_name }} Devicetree file
run: |
if [ -f "${{ env.build_dir }}/zephyr/zephyr.dts" ]
then
cat "${{ env.build_dir }}/zephyr/zephyr.dts"
elif [ -f "${{ env.build_dir }}/zephyr/zephyr.dts.pre" ]
then
cat -s "${{ env.build_dir }}/zephyr/zephyr.dts.pre"
else
echo "No Devicetree output"
fi
if: ${{ !cancelled() }}

- name: Rename artifacts
shell: sh -x {0}
run: |
mkdir "${{ env.build_dir }}/artifacts"
if [ -f "${{ env.build_dir }}/zephyr/zmk.uf2" ]
then
cp "${{ env.build_dir }}/zephyr/zmk.uf2" "${{ env.build_dir }}/artifacts/${{ env.artifact_name }}.uf2"
elif [ -f "${{ env.build_dir }}/zephyr/zmk.${{ inputs.fallback_binary }}" ]
then
cp "${{ env.build_dir }}/zephyr/zmk.${{ inputs.fallback_binary }}" "${{ env.build_dir }}/artifacts/${{ env.artifact_name }}.${{ inputs.fallback_binary }}"
fi
- name: Archive (${{ env.display_name }})
uses: actions/upload-artifact@v4
with:
name: artifact-${{ env.artifact_name }}
path: ${{ env.build_dir }}/artifacts

merge:
runs-on: ubuntu-latest
needs: build
name: Merge Output Artifacts
steps:
- name: Merge QWERTY Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: "qwerty-firmware"
pattern: artifact-charybdis_QWERTY*
delete-merged: true
- name: Merge Colemak DH Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: "colemak-dh-firmware"
pattern: artifact-charybdis_colemak*
delete-merged: true
75 changes: 75 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Intro

This repository outlines most of the steps needed to build/modify the ZMK firmware for a Wireless Charybdis keyboard.

## Pre Built Firmware

If you'd like to skip all the configuration steps and use something prebuilt, the firmware files for qwerty and colemak dh can be found in the Actions tab of this repo. There are a few things to note about how I've chosen to configure things.

- The main branch builds the firmware with the colemak dh layout, and the layouts/qwerty branch builds the qwerty firmware.
- The keyboard name is Charybdis. This is what will show up when you connect to it with bluetooth.
- ZMK has terms for each side of a split keyboard. Central is the half that sends keyboard outputs over USB or advertises to other devices over bluetooth. Peripheral is the half that will only send keystrokes to the central once they are paired and connected through bluetooth. I have chosen the right side as central because it fits my desk layout better.
- To add support for the PMW3610 sensor, [inorichi's driver](https://github.com/inorichi/zmk-pmw3610-driver?tab=readme-ov-file) is included in the firmware.
- Looking at different options to include support for mouse keys (move and scroll), there are several repos out there. [krikun98](https://github.com/krikun98/zmk/tree/mouse-pr) has one that looked promising, but ultimately I settled on [petejohanson's work](https://github.com/petejohanson/zmk/blob/feat/pointers-move-scroll/docs/docs/behaviors/mouse-emulation.md). This will be included in the prebuilt firmware until ZMK merges it.

## Update Key Mappings

Before adding/updating a keymap, you need to select a behavior, then choose a parameter code. This process is more clearly outlined on ZMK's [Keymaps & Behaviors](https://zmk.dev/docs/features/keymaps) page.
- Behaviors are all documented on the [Behaviors Overview](https://zmk.dev/docs/behaviors)
- Codes are all documented on the [keycodes](https://zmk.dev/docs/codes) page

There are a few options available to update the keymaps with the chosen behavior and code.

### Edit Code Directly

You can edit the charybdis.keymap file directly to match any configuration you want by using the behavior and codes from above.

### Use a GUI

Using a GUI to generate the keymap file content is the easiest option. There are multiple mappers out there that will generate keymap files for ZMK. The two I found most helpful are tammingaj's [Keymapper](https://www.keymapper.dev/code) and nickcoutsos' [keymap editor](https://nickcoutsos.github.io/keymap-editor/). I chose to use the latter for my project.

If you'd like to use the keymap editor, follow the steps below.

- Fork this repo
- Open a new tab to the [keymap editor](https://nickcoutsos.github.io/keymap-editor)
- Give it permission to your fork
- Select the branch you'd like to modify
- Update the keys to match what you'd like to use on your keyboard
- Save
- Wait for the pipeline to run
- Download and flash the new firmware

## Building Your Own Firmware

ZMK provide a comprehensive guide to follow when creating a [New Keyboard Shield](https://zmk.dev/docs/development/new-shield). I'll touch on some of the points here, but their docs should be what you reference when you're building your own firmware.

### File Locations

The file locations for setting up the repo to build the firmware matters. The formats and locations of the files can be found on ZMK's [Configuration Overview](https://zmk.dev/docs/config). One thing to note about this repo is that the keymap and json files are in the config directory to work with a GUI keymapper. Also, the matrix-transform is included as part of the charbdis.dtsi file.

### Mapping GPIO Pins to Keys

To set up some of the configuration files it requires a knowledge of which keys connect to which pins on the MCU (see the [Shield Overlays](https://zmk.dev/docs/development/new-shield#shield-overlays) section), and how the rows and columns are wired.

To get this information, look at the PCB kcad files and follow the traces from key pads, to row and column through holes, to MCU through holes. Once you have that information you can update the shield.dtsi, shield_left.overlay, and shield_right.overlay files.

### Changing the Central and Peripheral Assignments

Follow the ZMK documentation to change the [Kconfig.deconfig](https://zmk.dev/docs/development/new-shield#kconfigdefconfig).

### Changing the Keyboard Name

Follow the ZMK [Kconfig.defconfig](https://zmk.dev/docs/development/new-shield#kconfigdefconfig) section to update the keyboard name. Make sure to read about the danger in exceeding the 16 character limit.

## Creating Graphical Key Maps

There are a lot of resources available to create key map images. Keymap Editor and KeyMapper mentioned in the Update Keymappings section have this ability, but they are not very customizable.

[Keymap Drawer](https://keymap-drawer.streamlit.app/) has more options and is able to process ZMK keymaps, but I ultimately settled on the [Keyboard Layout Editor](http://www.keyboard-layout-editor.com/#/).

## Upcoming Features

ZMK is actively being developed and there are a few features I'll be adding to my builds as soon as they are released.

- Mouse Pointer & Scrolling - [PR in review](https://github.com/zmkfirmware/zmk/pull/2027)
- Layer Locks - [Layer locks will become standard soon.](https://github.com/zmkfirmware/zmk/pull/1984)
16 changes: 14 additions & 2 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
---
include:
- board: nice_nano_v2
shield: kyria_rev3_left
shield: charybdis_left
keymap: charybdis_colemak_dh
artifact-name: charybdis_colemak_left
- board: nice_nano_v2
shield: kyria_rev3_right
shield: charybdis_right
keymap: charybdis_colemak_dh
artifact-name: charybdis_colemak_right
- board: nice_nano_v2
shield: charybdis_left
keymap: charybdis_qwerty
artifact-name: charybdis_QWERTY_left
- board: nice_nano_v2
shield: charybdis_right
keymap: charybdis_qwerty
artifact-name: charybdis_QWERTY_right
16 changes: 16 additions & 0 deletions config/boards/shields/charybdis-mini-wireless/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
if SHIELD_CHARYBDIS_RIGHT

config ZMK_KEYBOARD_NAME
default "Charybdis"

config ZMK_SPLIT_BLE_ROLE_CENTRAL
default y

endif

if SHIELD_CHARYBDIS_LEFT || SHIELD_CHARYBDIS_RIGHT

config ZMK_SPLIT
default y

endif
5 changes: 5 additions & 0 deletions config/boards/shields/charybdis-mini-wireless/Kconfig.shield
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
config SHIELD_CHARYBDIS_LEFT
def_bool $(shields_list_contains,charybdis_left)

config SHIELD_CHARYBDIS_RIGHT
def_bool $(shields_list_contains,charybdis_right)
File renamed without changes.
37 changes: 37 additions & 0 deletions config/boards/shields/charybdis-mini-wireless/charybdis.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <dt-bindings/zmk/matrix_transform.h>

/ {
chosen {
zmk,kscan = &kscan0;
zmk,matrix_transform = &default_transform;
};

vbatt: vbatt {
compatible = "zmk,battery-nrf-vddh";
};

default_transform: keymap_transform_0 {
compatible = "zmk,matrix-transform";
columns = <12>;
rows = <4>;

map = <
RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,11) RC(0,10) RC(0,9) RC(0,8) RC(0,7) RC(0,6)
RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,11) RC(1,10) RC(1,9) RC(1,8) RC(1,7) RC(1,6)
RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,11) RC(2,10) RC(2,9) RC(2,8) RC(2,7) RC(2,6)
RC(3,3) RC(3,4) RC(3,1) RC(3,7) RC(3,9)
>;
};

kscan0: kscan {
compatible = "zmk,kscan-gpio-matrix";
wakeup-source;
diode-direction = "row2col";
row-gpios
= <&pro_micro 18 GPIO_ACTIVE_HIGH>
, <&pro_micro 5 GPIO_ACTIVE_HIGH>
, <&pro_micro 4 GPIO_ACTIVE_HIGH>
, <&pro_micro 9 GPIO_ACTIVE_HIGH>
;
};
};
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "charybdis.dtsi"

&kscan0 {
col-gpios
= <&pro_micro 19 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 20 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 10 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
;
};
23 changes: 23 additions & 0 deletions config/boards/shields/charybdis-mini-wireless/charybdis_right.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# https://zmk.dev/docs/config/power#kconfig-2
CONFIG_ZMK_EXT_POWER=y

# https://github.com/inorichi/zmk-pmw3610-driver?tab=readme-ov-file
CONFIG_SPI=y
CONFIG_INPUT=y
CONFIG_ZMK_MOUSE=y
CONFIG_PMW3610=y

# https://github.com/inorichi/zmk-pmw3610-driver/blob/main/Kconfig
CONFIG_PMW3610_SMART_ALGORITHM=y
CONFIG_PMW3610_CPI=1600
CONFIG_PMW3610_CPI_DIVIDOR=3
CONFIG_PMW3610_SNIPE_CPI=200
CONFIG_PMW3610_SNIPE_CPI_DIVIDOR=1
CONFIG_PMW3610_SCROLL_TICK=20
CONFIG_PMW3610_POLLING_RATE_125_SW=y
CONFIG_PMW3610_REST1_SAMPLE_TIME_MS=20
CONFIG_PMW3610_RUN_DOWNSHIFT_TIME_MS=2000
CONFIG_PMW3610_ORIENTATION_90=y
CONFIG_PMW3610_INVERT_X=y
CONFIG_PMW3610_INVERT_SCROLL_Y=n
CONFIG_PMW3610_AUTOMOUSE_TIMEOUT_MS=400
Loading

0 comments on commit 8491237

Please sign in to comment.