From bd8b3b94c7afa9fc48c8ef683b96d603e358a728 Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Wed, 1 May 2024 14:07:48 -0700 Subject: [PATCH] refactor(shields): Set ZMK Uno physical layouts. * Add physical layout definitions for uno and split uno shields. --- app/boards/shields/zmk_uno/zmk_uno.dtsi | 3 -- app/boards/shields/zmk_uno/zmk_uno.keymap | 6 +-- app/boards/shields/zmk_uno/zmk_uno.overlay | 35 ++++++++++++- app/boards/shields/zmk_uno/zmk_uno_split.dtsi | 49 +++++++++++++++++-- .../shields/zmk_uno/zmk_uno_split.keymap | 7 +-- .../zmk_uno/zmk_uno_split_right.overlay | 2 +- 6 files changed, 82 insertions(+), 20 deletions(-) diff --git a/app/boards/shields/zmk_uno/zmk_uno.dtsi b/app/boards/shields/zmk_uno/zmk_uno.dtsi index ba1d3b5da806..9ea625a420f2 100644 --- a/app/boards/shields/zmk_uno/zmk_uno.dtsi +++ b/app/boards/shields/zmk_uno/zmk_uno.dtsi @@ -40,10 +40,8 @@ nice_view_spi: &arduino_spi { / { chosen { - zmk,kscan = &kscan_matrix; zmk,backlight = &backlight; zmk,underglow = &led_strip; - zmk,matrix-transform = &matrix_transform; }; // Commented out until we add more powerful power domain support @@ -109,7 +107,6 @@ nice_view_spi: &arduino_spi { kscan_direct: kscan_direct { compatible = "zmk,kscan-gpio-direct"; wakeup-source; - status = "disabled"; input-gpios = <&arduino_header 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> diff --git a/app/boards/shields/zmk_uno/zmk_uno.keymap b/app/boards/shields/zmk_uno/zmk_uno.keymap index a7f6a2675d5c..186cdb60a384 100644 --- a/app/boards/shields/zmk_uno/zmk_uno.keymap +++ b/app/boards/shields/zmk_uno/zmk_uno.keymap @@ -13,13 +13,9 @@ // Uncomment the following lines if using the "Direct Wire" jumper to switch the matrix to a direct wire. -// &kscan_direct { status = "okay"; }; -// &kscan_matrix { status = "disabled"; }; - // / { // chosen { -// zmk,matrix-transform = &direct_matrix_transform; -// zmk,kscan = &kscan_direct; +// zmk,physical-layout = &direct_physical_layout; // }; // }; diff --git a/app/boards/shields/zmk_uno/zmk_uno.overlay b/app/boards/shields/zmk_uno/zmk_uno.overlay index 6948112b8b0e..2a8eb26635a6 100644 --- a/app/boards/shields/zmk_uno/zmk_uno.overlay +++ b/app/boards/shields/zmk_uno/zmk_uno.overlay @@ -7,13 +7,15 @@ #include "zmk_uno.dtsi" #include +#include #include #include / { chosen { - zmk,matrix-transform = &matrix_transform; + zmk,physical-layout = &matrix_physical_layout; }; + sensors: sensors { compatible = "zmk,keymap-sensors"; sensors = <&encoder>; @@ -58,4 +60,35 @@ }; }; + matrix_physical_layout: matrix_physical_layout { + compatible = "zmk,physical-layout"; + display-name = "Matrix Layout"; + + kscan = <&kscan_matrix>; + transform = <&matrix_transform>; + + keys + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 100 100 0 0 0> + ; + }; + + direct_physical_layout: direct_physical_layout { + compatible = "zmk,physical-layout"; + + display-name = "Direct Wire Layout"; + + kscan = <&kscan_direct>; + transform = <&direct_matrix_transform>; + + keys + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 100 100 0 0 0> + ; + }; + }; diff --git a/app/boards/shields/zmk_uno/zmk_uno_split.dtsi b/app/boards/shields/zmk_uno/zmk_uno_split.dtsi index dac6fc3e4ee7..9afbf79a4aeb 100644 --- a/app/boards/shields/zmk_uno/zmk_uno_split.dtsi +++ b/app/boards/shields/zmk_uno/zmk_uno_split.dtsi @@ -6,13 +6,15 @@ #include "zmk_uno.dtsi" + #include + left_encoder: &encoder { status = "disabled"; }; / { chosen { - zmk,matrix-transform = &split_matrix_transform; + zmk,physical-layout = &matrix_physical_layout; }; split_matrix_transform: split_matrix_transform { @@ -31,18 +33,57 @@ split_direct_matrix_transform: split_direct_matrix_transform { compatible = "zmk,matrix-transform"; - rows = <3>; + rows = <2>; columns = <4>; map = < RC(0,0) RC(0,1) RC(0,2) RC(0,3) - RC(2,0) RC(2,1) - RC(2,2) RC(2,3) + RC(1,0) RC(1,1) + RC(1,2) RC(1,3) >; }; + matrix_physical_layout: matrix_physical_layout { + compatible = "zmk,physical-layout"; + display-name = "Matrix Layout"; + + kscan = <&kscan_matrix>; + transform = <&split_matrix_transform>; + + keys + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 100 100 0 0 0> + , <&key_physical_attrs 100 100 0 200 0 0 0> + , <&key_physical_attrs 100 100 100 200 0 0 0> + , <&key_physical_attrs 100 100 0 300 0 0 0> + , <&key_physical_attrs 100 100 100 300 0 0 0> + ; + }; + + direct_physical_layout: direct_physical_layout { + compatible = "zmk,physical-layout"; + + display-name = "Direct Wire Layout"; + + kscan = <&kscan_direct>; + transform = <&split_direct_matrix_transform>; + + keys + = <&key_physical_attrs 100 100 0 0 0 0 0> + , <&key_physical_attrs 100 100 100 0 0 0 0> + , <&key_physical_attrs 100 100 0 100 0 0 0> + , <&key_physical_attrs 100 100 100 100 0 0 0> + , <&key_physical_attrs 100 100 0 200 0 0 0> + , <&key_physical_attrs 100 100 100 200 0 0 0> + , <&key_physical_attrs 100 100 0 300 0 0 0> + , <&key_physical_attrs 100 100 100 300 0 0 0> + ; + }; + right_encoder: right_encoder { steps = <80>; status = "disabled"; diff --git a/app/boards/shields/zmk_uno/zmk_uno_split.keymap b/app/boards/shields/zmk_uno/zmk_uno_split.keymap index 0e50a2833f0b..d2daa6ead657 100644 --- a/app/boards/shields/zmk_uno/zmk_uno_split.keymap +++ b/app/boards/shields/zmk_uno/zmk_uno_split.keymap @@ -14,14 +14,9 @@ // Uncomment the following lines if using the "Direct Wire" jumper to switch the matrix to a direct wire. - -// &kscan_direct { status = "okay"; }; -// &kscan_matrix { status = "disabled"; }; - // / { // chosen { -// zmk,matrix-transform = &split_direct_matrix_transform; -// zmk,kscan = &kscan_direct; +// zmk,physical-layout = &direct_physical_layout; // }; // }; diff --git a/app/boards/shields/zmk_uno/zmk_uno_split_right.overlay b/app/boards/shields/zmk_uno/zmk_uno_split_right.overlay index 9c2e7d7f2eef..acfad5a24f2d 100644 --- a/app/boards/shields/zmk_uno/zmk_uno_split_right.overlay +++ b/app/boards/shields/zmk_uno/zmk_uno_split_right.overlay @@ -11,7 +11,7 @@ }; &split_direct_matrix_transform { - row-offset = <2>; + row-offset = <1>; }; &right_encoder {