Skip to content

Commit

Permalink
add zmk studio support
Browse files Browse the repository at this point in the history
  • Loading branch information
tokyo2006 committed Dec 11, 2024
1 parent 76bdacf commit 6cd2fc3
Show file tree
Hide file tree
Showing 35 changed files with 229 additions and 1,538 deletions.
20 changes: 2 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,9 @@ name: Build ZMK firmware
on:
workflow_dispatch:
push:
paths:
- "config/**"
paths-ignore:
- "keymap-drawer/**"

jobs:
build:
uses: zmkfirmware/zmk/.github/workflows/build-user-config.yml@main
draw:
uses: caksoylar/keymap-drawer/.github/workflows/draw-zmk.yml@main
permissions:
contents: write
with:
commit_message: "[Draw] ${{ github.event.head_commit.message }}"
amend_commit: false
install_branch: "main"
keymap_patterns: "config/*.keymap"
json_path: "config"
config_path: "keymap_drawer.config.yaml" # config file, ignored if not exists
output_folder: "keymap-drawer"
destination: "both"
parse_args: "" # map of extra args to pass to `keymap parse`, e.g. "corne:'-l Def Lwr Rse' cradio:''"
draw_args: "" # map of extra args to pass to `keymap draw`, e.g. "corne:'-k corne_rotated' cradio:'-k paroxysm'"

18 changes: 18 additions & 0 deletions .github/workflows/draw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Draw Keymap
on:
workflow_dispatch:
push:
paths:
- "config/**"
- .github/workflows/draw.yml
- keymap_drawer.config.yaml

jobs:
draw:
uses: caksoylar/keymap-drawer/.github/workflows/draw-zmk.yml@main
permissions:
contents: write
with:
commit_message: "[Draw] ${{ github.event.head_commit.message }}"
destination: "commit"
fail_on_error: ${{ fromJSON(true) }}
9 changes: 7 additions & 2 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ include:
- board: nice_nano_v2
shield: settings_reset
- board: corne_left
shield: nice_view_adapter nice_view
shield: nice_view
artifact-name: corne_left_nice_view
- board: corne_right
shield: nice_view_adapter nice_view_custom
shield: nice_view_custom
artifact-name: corne_right_nice_view
- board: corne_left
shield: nice_view
snippet: studio-rpc-usb-uart
cmake-args: -DCONFIG_ZMK_STUDIO=y -DCONFIG_ZMK_STUDIO_LOCKING=n
artifact-name: eyelash_corne_studio_left
42 changes: 21 additions & 21 deletions config/boards/arm/corne/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ endif # BOARD_CORNE_LEFT

if BOARD_CORNE_LEFT || BOARD_CORNE_RIGHT

config BOARD_ENABLE_DCDC
bool "Enable DCDC mode"
select SOC_DCDC_NRF52X
default y

config BOARD_ENABLE_DCDC_HV
bool "Enable High Voltage DCDC converter"
default y
select SOC_DCDC_NRF52X_HV
depends on (BOARD_CORNE_LEFT || BOARD_CORNE_RIGHT)

config BOARD
default "corne"

Expand All @@ -35,36 +46,25 @@ config USB_DEVICE_STACK

endif # USB

if ZMK_DISPLAY
if USB

config I2C
config USB_NRFX
default y

config SSD1306
config USB_DEVICE_STACK
default y

choice ZMK_DISPLAY_WORK_QUEUE
default ZMK_DISPLAY_WORK_QUEUE_DEDICATED
endchoice

endif

if SSD1306

config LV_Z_VDB_SIZE
default 64
endif # USB

config LV_DPI_DEF
default 148
if ZMK_BACKLIGHT

config LV_Z_BITS_PER_PIXEL
default 1
config PWM
default y

choice LV_COLOR_DEPTH
default LV_COLOR_DEPTH_1
endchoice
config LED_PWM
default y

endif
endif # ZMK_BACKLIGHT

endif # BOARD_CORNE_LEFT || BOARD_CORNE_RIGHT

61 changes: 61 additions & 0 deletions config/boards/arm/corne/corne-layouts.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include <physical_layouts.dtsi>

/ {
corne_layout: corne_layout {
compatible = "zmk,physical-layout";
display-name = "Layout";

transform = <&default_transform>;

keys // w h x y rot rx ry
= <&key_physical_attrs 100 100 0 88 0 0 0>
, <&key_physical_attrs 100 100 100 88 0 0 0>
, <&key_physical_attrs 100 100 200 50 0 0 0>
, <&key_physical_attrs 100 100 300 38 0 0 0>
, <&key_physical_attrs 100 100 400 50 0 0 0>
, <&key_physical_attrs 100 100 500 75 0 0 0>
, <&key_physical_attrs 100 100 775 0 0 0 0>
, <&key_physical_attrs 100 100 1050 75 0 0 0>
, <&key_physical_attrs 100 100 1150 50 0 0 0>
, <&key_physical_attrs 100 100 1250 38 0 0 0>
, <&key_physical_attrs 100 100 1350 50 0 0 0>
, <&key_physical_attrs 100 100 1450 88 0 0 0>
, <&key_physical_attrs 100 100 1550 88 0 0 0>
, <&key_physical_attrs 100 100 0 188 0 0 0>
, <&key_physical_attrs 100 100 100 188 0 0 0>
, <&key_physical_attrs 100 100 200 150 0 0 0>
, <&key_physical_attrs 100 100 300 138 0 0 0>
, <&key_physical_attrs 100 100 400 150 0 0 0>
, <&key_physical_attrs 100 100 500 175 0 0 0>
, <&key_physical_attrs 100 100 775 200 0 0 0>
, <&key_physical_attrs 100 100 1050 175 0 0 0>
, <&key_physical_attrs 100 100 1150 150 0 0 0>
, <&key_physical_attrs 100 100 1250 138 0 0 0>
, <&key_physical_attrs 100 100 1350 150 0 0 0>
, <&key_physical_attrs 100 100 1450 188 0 0 0>
, <&key_physical_attrs 100 100 1550 188 0 0 0>
, <&key_physical_attrs 100 100 0 288 0 0 0>
, <&key_physical_attrs 100 100 100 288 0 0 0>
, <&key_physical_attrs 100 100 200 250 0 0 0>
, <&key_physical_attrs 100 100 300 238 0 0 0>
, <&key_physical_attrs 100 100 400 250 0 0 0>
, <&key_physical_attrs 100 100 500 275 0 0 0>
, <&key_physical_attrs 100 100 675 100 0 0 0>
, <&key_physical_attrs 100 100 1050 275 0 0 0>
, <&key_physical_attrs 100 100 1150 250 0 0 0>
, <&key_physical_attrs 100 100 1250 238 0 0 0>
, <&key_physical_attrs 100 100 1350 250 0 0 0>
, <&key_physical_attrs 100 100 1450 288 0 0 0>
, <&key_physical_attrs 100 100 1550 288 0 0 0>
, <&key_physical_attrs 100 100 650 325 0 0 0>
, <&key_physical_attrs 100 100 400 400 0 0 0>
, <&key_physical_attrs 100 100 550 400 3000 500 400>
, <&key_physical_attrs 100 150 675 350 3000 500 400>
, <&key_physical_attrs 100 100 875 100 0 0 0>
, <&key_physical_attrs 100 150 875 350 (-3000) 1150 400>
, <&key_physical_attrs 100 100 1000 400 (-3000) 1150 400>
, <&key_physical_attrs 100 100 1150 400 0 0 0>
, <&key_physical_attrs 100 100 775 100 0 0 0>
;
};
};
108 changes: 74 additions & 34 deletions config/boards/arm/corne/corne.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,28 @@
#include <nordic/nrf52840_qiaa.dtsi>
#include <dt-bindings/led/led.h>
#include <dt-bindings/zmk/matrix_transform.h>
#include "corne-layouts.dtsi"

/ {
model = "corne";
compatible = "corne";
compatible = "peripherals,corne";

chosen {
zephyr,code-partition = &code_partition;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zmk,kscan = &kscan0;
zephyr,display = &oled;
zmk,battery = &vbatt;
zephyr,console = &cdc_acm_uart;
zmk,underglow = &led_strip;
zmk,matrix-transform = &default_transform;
zmk,physical-layout = &corne_layout;
};

left_encoder: encoder_left {
compatible = "alps,ec11";
a-gpios = <&gpio1 10 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
b-gpios = <&gpio1 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
label = "LEFT_ENCODER";
resolution = <4>;
status = "disabled";
Expand All @@ -36,7 +40,20 @@
compatible = "zmk,keymap-sensors";
sensors = <&left_encoder>;
};


kscan0: kscan {
compatible = "zmk,kscan-gpio-matrix";
wakeup-source;
diode-direction = "col2row";
row-gpios
= <&gpio0 19 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&gpio0 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&gpio0 12 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&gpio0 11 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&gpio1 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
;
};

default_transform: keymap_transform_0 {
compatible = "zmk,matrix-transform";
columns = <14>;
Expand All @@ -49,6 +66,19 @@
RC(4,7)
>;
};

ext-power {
compatible = "zmk,ext-power-generic";
label = "EXT_POWER";
control-gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
init-delay-ms = <50>;
};

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


};

&adc {
Expand All @@ -74,6 +104,10 @@
};
};

zephyr_udc0: &usbd {
status = "okay";
};

&flash0 {
/*
* For more information, see:
Expand Down Expand Up @@ -111,17 +145,32 @@
};

&pinctrl {
i2c0_default: i2c0_default {

spi0_default: spi0_default {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 20)>,
<NRF_PSEL(SPIM_MOSI, 0, 17)>,
<NRF_PSEL(SPIM_MISO, 0, 25)>;
};
};

spi0_sleep: spi0_sleep {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 17)>,
<NRF_PSEL(TWIM_SCL, 0, 20)>;
psels = <NRF_PSEL(SPIM_SCK, 0, 20)>,
<NRF_PSEL(SPIM_MOSI, 0, 17)>,
<NRF_PSEL(SPIM_MISO, 0, 25)>;
low-power-enable;
};
};

i2c0_sleep: i2c0_sleep {
pwm0_default: pwm0_default {
group1 {
psels = <NRF_PSEL(PWM_OUT0, 1, 13)>;
};
};
pwm0_sleep: pwm0_sleep {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 17)>,
<NRF_PSEL(TWIM_SCL, 0, 20)>;
psels = <NRF_PSEL(PWM_OUT0, 1, 13)>;
low-power-enable;
};
};
Expand All @@ -140,30 +189,6 @@
};
};

&i2c0 {
status = "okay";

compatible = "nordic,nrf-twi";
pinctrl-0 = <&i2c0_default>;
pinctrl-1 = <&i2c0_sleep>;
pinctrl-names = "default", "sleep";
oled: ssd1306@3c {
compatible = "solomon,ssd1306fb";
reg = <0x3c>;
label = "DISPLAY";
width = <128>;
height = <32>;
segment-offset = <0>;
page-offset = <0>;
display-offset = <0>;
multiplex-ratio = <31>;
segment-remap;
com-invdir;
com-sequential;
prechargep = <0x22>;
};
};

&spi3 {
compatible = "nordic,nrf-spim";
status = "okay";
Expand All @@ -186,4 +211,19 @@

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

nice_view_spi: &spi0 {
compatible = "nordic,nrf-spim";
pinctrl-0 = <&spi0_default>;
pinctrl-1 = <&spi0_sleep>;
pinctrl-names = "default", "sleep";
cs-gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>;
};

&pwm0 {
status = "okay";
pinctrl-0 = <&pwm0_default>;
pinctrl-1 = <&pwm0_sleep>;
pinctrl-names = "default", "sleep";
};
Loading

0 comments on commit 6cd2fc3

Please sign in to comment.