Skip to content

Commit

Permalink
sync: sync with upstream repo
Browse files Browse the repository at this point in the history
Try syncing with the upstream repo to see if this helps at all with the
firmware and the two halves failing to connect 90% of the time.
  • Loading branch information
nilium committed Dec 18, 2023
1 parent 583c966 commit 7e93958
Show file tree
Hide file tree
Showing 21 changed files with 420 additions and 299 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get version data
id: get_info
run: |
timestamp=$(date +"%Y%m%d%H%M")
commit=$(echo "${{ github.sha }}" | cut -c1-7)
file_prefix=$timestamp-$commit
branch_name=$(echo "${{ github.ref }}" | awk -F'/' '{print $3}' | cut -c1-4)
echo "file_prefix=$file_prefix" >> $GITHUB_OUTPUT
bin/get_version.sh $branch_name $commit
- name: Cache west modules
uses: actions/cache@v3
env:
Expand All @@ -36,17 +45,17 @@ jobs:
- name: West Build (left)
run: west build -s zmk/app -d build/left -b adv360_left -- -DZMK_CONFIG="${GITHUB_WORKSPACE}/config"
- name: Adv360 Left Kconfig file
run: cat build/left/zephyr/.config | grep -v "^#" | grep -v "^$"
run: grep -vE '(^#|^$)' build/left/zephyr/.config
- name: West Build (right)
run: west build -s zmk/app -d build/right -b adv360_right -- -DZMK_CONFIG="${GITHUB_WORKSPACE}/config"
- name: Adv360 Right Kconfig file
run: cat build/right/zephyr/.config | grep -v "^#" | grep -v "^$"
run: grep -vE '(^#|^$)' build/right/zephyr/.config
- name: Rename zmk.uf2
run: cp build/left/zephyr/zmk.uf2 left.uf2 && cp build/right/zephyr/zmk.uf2 right.uf2
run: cp build/left/zephyr/zmk.uf2 ${{ steps.get_info.outputs.file_prefix }}-left.uf2 && cp build/right/zephyr/zmk.uf2 ${{ steps.get_info.outputs.file_prefix }}-right.uf2
- name: Archive (Adv360)
uses: actions/upload-artifact@v3
with:
name: firmware
path: |
left.uf2
right.uf2
${{ steps.get_info.outputs.file_prefix }}-left.uf2
${{ steps.get_info.outputs.file_prefix }}-right.uf2
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
DOCKER := $(shell { command -v podman || command -v docker; })
TIMESTAMP := $(shell date -u +"%Y%m%d%H%M%S")
TIMESTAMP := $(shell date -u +"%Y%m%d%H%M")
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null)
detected_OS := $(shell uname) # Classify UNIX OS
ifeq ($(strip $(detected_OS)),Darwin) #We only care if it's OS X
SELINUX1 :=
SELINUX2 :=
else
SELINUX1 := :z
SELINUX2 := ,z
endif

.PHONY: all clean

all:
$(shell bin/get_version.sh >> /dev/null)
$(DOCKER) build --tag zmk --file Dockerfile .
$(DOCKER) run --rm -it --name zmk \
-v $(PWD)/firmware:/app/firmware \
-v $(PWD)/config:/app/config:ro \
-v $(PWD)/firmware:/app/firmware$(SELINUX1) \
-v $(PWD)/config:/app/config:ro$(SELINUX2) \
-e TIMESTAMP=$(TIMESTAMP) \
-e COMMIT=$(COMMIT) \
zmk

clean:
Expand Down
9 changes: 5 additions & 4 deletions bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
set -eu

PWD=$(pwd)
TIMESTAMP="${TIMESTAMP:-$(date -u +"%Y%m%d%H%M%S")}"
TIMESTAMP="${TIMESTAMP:-$(date -u +"%Y%m%d%H%M")}"
COMMIT="${COMMIT:-$(echo xxxxxx)}"

# West Build (left)
west build -s zmk/app -d build/left -b adv360_left -- -DZMK_CONFIG="${PWD}/config"
# Adv360 Left Kconfig file
cat build/left/zephyr/.config | grep -v "^#" | grep -v "^$"
grep -vE '(^#|^$)' build/left/zephyr/.config
# West Build (right)
west build -s zmk/app -d build/right -b adv360_right -- -DZMK_CONFIG="${PWD}/config"
# Adv360 Right Kconfig file
cat build/right/zephyr/.config | grep -v "^#" | grep -v "^$"
grep -vE '(^#|^$)' build/right/zephyr/.config
# Rename zmk.uf2
cp build/left/zephyr/zmk.uf2 ./firmware/${TIMESTAMP}-left.uf2 && cp build/right/zephyr/zmk.uf2 ./firmware/${TIMESTAMP}-right.uf2
cp build/left/zephyr/zmk.uf2 "./firmware/${TIMESTAMP}-${COMMIT}-left.uf2" && cp build/right/zephyr/zmk.uf2 "./firmware/${TIMESTAMP}-${COMMIT}-right.uf2"
57 changes: 57 additions & 0 deletions bin/get_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env bash

# Get the date, first 4 chars of branch name and short commit hash
date=$(date -u +"%Y%m%d")
branch=${1:-$(git rev-parse --abbrev-ref HEAD | cut -c1-4)}
commit=${2:-$(git rev-parse --short HEAD)}

# Function to transform characters to ZMK key behaviours
transform_char() {
local char=$1
if [[ $char =~ [A-Za-z] ]]; then
echo "<&kp ${char^^}>, "
elif [[ $char =~ [0-9] ]]; then
echo "<&kp N${char}>, "
elif [ "$char" = "." ]; then
echo "<&kp DOT>, "
fi
}

# Iterate over the date and format characters
formatted_date=""
for ((i = 0; i < ${#date}; i++)); do
formatted_date+=$(transform_char "${date:$i:1}")
done

# Insert separator between date and branch
formatted_date+="<&kp MINUS>, "

# Iterate over the branch and format characters
formatted_branch=""
for ((i = 0; i < ${#branch}; i++)); do
formatted_branch+=$(transform_char "${branch:$i:1}")
done

# Insert separator between branch and commit hash
formatted_branch+="<&kp MINUS>, "

# Iterate over the commit hash and format characters
formatted_commit=""
for ((i = 0; i < ${#commit}; i++)); do
formatted_commit+=$(transform_char "${commit:$i:1}")
done

# Combine the formatted string, add trailing carriage return
formatted_result="$formatted_date$formatted_branch$formatted_commit"
formatted_result+="<&kp RET>"

echo $formatted_result
# Create new macro to define version, overwrite previous one

echo '#define VERSION_MACRO' > "config/version.dtsi"
echo 'macro_ver: macro_ver {' >> "config/version.dtsi"
echo 'compatible = "zmk,behavior-macro";' >> "config/version.dtsi"
echo 'label = "macro_ver";' >> "config/version.dtsi"
echo '#binding-cells = <0>;' >> "config/version.dtsi"
echo "bindings = $formatted_result;" >> "config/version.dtsi"
echo '};' >> "config/version.dtsi"
23 changes: 16 additions & 7 deletions config/adv360.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
/ {
behaviors {
#include "macros.dtsi"
#include "version.dtsi"
#ifndef VERSION_MACRO
macro_ver: macro_ver {
compatible = "zmk,behavior-macro";
label = "macro_version";
#binding-cells = <0>;
bindings = <&kp RET>;
};
#endif

hm: homerow_mods {
compatible = "zmk,behavior-hold-tap";
Expand Down Expand Up @@ -73,8 +82,8 @@
bindings = <
&kp EQUAL &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &tog 1 &mo 3 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp MINUS
&kp TAB &kp Q &kp W &kp E &kp R &kp T &none &none &kp Y &kp U &kp I &kp O &kp P &kp BSLH
&mt RIGHT_CONTROL ESC &kp A &kp S &kp D &kp F &kp G &none &kp LEFT_COMMAND &kp LALT &kp RIGHT_CONTROL &kp RIGHT_COMMAND &none &h_left &j_down &k_up &l_right &kp SEMI &kp SQT
&kp LSHFT &kp Z &kp X &kp C &kp V &kp B &none &none &kp HOME &none &none &kp PG_UP &none &none &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp RSHFT
&kp ESC &kp A &kp S &kp D &kp F &kp G &none &kp LEFT_COMMAND &kp LALT &kp RIGHT_CONTROL &kp RIGHT_COMMAND &none &h_left &j_down &k_up &l_right &kp SEMI &kp SQT
&kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp HOME &kp PG_UP &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp RSHFT
&mo 2 &kp GRAVE &mo 1 &kp LEFT &kp RIGHT &bspc_del &kp LEFT_CONTROL &kp END &kp PG_DN &kp ENTER &kp SPACE &kp DOWN &kp UP &kp LBKT &kp RBKT &mo 2
>;
};
Expand All @@ -84,7 +93,7 @@
&kp EQUAL &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &trans &trans &kp N6 &kp KP_NUM &kp KP_EQUAL &kp KP_DIVIDE &kp KP_MULTIPLY &kp MINUS
&kp TAB &kp Q &kp C_VOLUME_DOWN &kp C_MUTE &kp C_VOLUME_UP &kp T &trans &trans &kp Y &kp KP_N7 &kp KP_N8 &kp KP_N9 &kp KP_MINUS &kp BSLH
&kp CAPSLOCK &kp A &kp C_PREV &kp C_PP &kp C_NEXT &kp G &trans &kp LEFT_COMMAND &kp LALT &kp RIGHT_CONTROL &kp RIGHT_COMMAND &trans &kp H &kp KP_N4 &kp KP_N5 &kp KP_N6 &kp KP_PLUS &kp SQT
&kp LSHFT &kp Z &kp X &kp C &kp V &kp B &none &none &kp HOME &none &none &kp PG_UP &none &none &kp N &kp KP_N1 &kp KP_N2 &kp KP_N3 &kp KP_ENTER &kp RSHFT
&kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp HOME &kp PG_UP &kp N &kp KP_N1 &kp KP_N2 &kp KP_N3 &kp KP_ENTER &kp RSHFT
&tog 4 &kp GRAVE &kp INSERT &kp DOWN &kp UP &trans &kp LEFT_CONTROL &kp END &kp PG_DN &kp ENTER &kp KP_N0 &trans &trans &kp KP_DOT &kp RBKT &mo 2
>;
};
Expand All @@ -94,7 +103,7 @@
&kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &tog 1 &mo 3 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12
&trans &trans &trans &trans &trans &trans &none &none &trans &trans &trans &trans &trans &trans
&trans &trans &trans &trans &trans &trans &none &trans &trans &trans &trans &none &kp LEFT &kp DOWN &kp UP &kp RIGHT &trans &trans
&trans &trans &trans &trans &trans &trans &none &none &trans &none &none &trans &none &none &trans &trans &trans &trans &trans &trans
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
>;
};
Expand All @@ -104,7 +113,7 @@
&none &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &none &trans &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &none
&none &none &none &none &none &none &bootloader &bootloader &none &none &none &none &none &none
&none &none &none &none &none &none &rgb_ug RGB_MEFS_CMD 5 &bt BT_CLR &bt BT_CLR &bt BT_CLR &bt BT_CLR &rgb_ug RGB_MEFS_CMD 5 &none &none &none &none &none &none
&none &none &none &none &none &none &none &none &none &none &none &none &none &none &none &none &none &none &none &none
&none &none &none &none &macro_ver &none &none &none &none &none &none &none &none &none
&none &none &none &bl BL_INC &bl BL_DEC &rgb_ug RGB_TOG &bl BL_TOG &none &none &bl BL_TOG &rgb_ug RGB_TOG &bl BL_INC &bl BL_DEC &none &none &none
>;
};
Expand All @@ -113,8 +122,8 @@
bindings = <
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&trans &trans &trans &trans &trans &trans &none &none &trans &none &none &trans &none &none &trans &trans &trans &trans &trans &trans
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&trans &trans &trans &trans &trans &kp LEFT_CONTROL &kp SPACE &trans &trans &trans &trans &trans &trans &trans &trans &trans
>;
};
Expand Down
8 changes: 4 additions & 4 deletions config/boards/arm/adv360/Kconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: MIT

config BOARD_ENABLE_DCDC
bool "Enable DCDC mode"
select SOC_DCDC_NRF52X
default y
depends on BOARD_ADV360_LEFT || BOARD_ADV360_RIGHT
bool "Enable DCDC mode"
select SOC_DCDC_NRF52X
default y
depends on BOARD_ADV360_LEFT || BOARD_ADV360_RIGHT
10 changes: 5 additions & 5 deletions config/boards/arm/adv360/Kconfig.board
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#
# Copyright (c) 2021 Polarity Works
# Copyright (c) 2022 The ZMK Contributors
# SPDX-License-Identifier: MIT
#

config BOARD_ADV360_LEFT
bool "adv360_left"
depends on SOC_NRF52840_QIAA
bool "adv360_left"
depends on SOC_NRF52840_QIAA

config BOARD_ADV360_RIGHT
bool "adv360_right"
depends on SOC_NRF52840_QIAA
bool "adv360_right"
depends on SOC_NRF52840_QIAA
30 changes: 16 additions & 14 deletions config/boards/arm/adv360/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -1,59 +1,61 @@
#
# Copyright (c) 2021 Polarity Works
# Copyright (c) 2022 The ZMK Contributors
# SPDX-License-Identifier: MIT
#

if BOARD_ADV360_LEFT

config ZMK_KEYBOARD_NAME
default "Adv360 Pro"
config ZMK_KEYBOARD_NAME
default "Adv360 Pro"

config ZMK_SPLIT_ROLE_CENTRAL
default y
endif # BOARD_ADV360_LEFT

if BOARD_ADV360_RIGHT

config ZMK_KEYBOARD_NAME
default "Adv360 Pro rt"
config ZMK_KEYBOARD_NAME
default "Adv360 Pro rt"

endif # BOARD_ADV360_RIGHT


if BOARD_ADV360_LEFT || BOARD_ADV360_RIGHT

config BOARD
default "adv360"
default "adv360"

config ZMK_SPLIT
default y
default y

config SPI
bool
default y

config BT_CTLR
default BT
default BT

config ZMK_BLE
default y
default y

config ZMK_USB
default y
default y

if USB

config USB_NRFX
default y
default y

config USB_DEVICE_STACK
default y
default y

endif # USB

config ZMK_BATTERY_VOLTAGE_DIVIDER
default y
default y

config SPI
default y
default y



Expand Down
Loading

0 comments on commit 7e93958

Please sign in to comment.