Skip to content

Commit

Permalink
refactor(shields): Set ZMK Uno physical layouts.
Browse files Browse the repository at this point in the history
* Add physical layout definitions for uno and split uno shields.
  • Loading branch information
petejohanson committed Jun 9, 2024
1 parent 30d48c3 commit cc051db
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 20 deletions.
3 changes: 0 additions & 3 deletions app/boards/shields/zmk_uno/zmk_uno.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)>
Expand Down
6 changes: 1 addition & 5 deletions app/boards/shields/zmk_uno/zmk_uno.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -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;
// };
// };

Expand Down
35 changes: 34 additions & 1 deletion app/boards/shields/zmk_uno/zmk_uno.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
#include "zmk_uno.dtsi"

#include <behaviors.dtsi>
#include <physical_layouts.dtsi>
#include <dt-bindings/zmk/bt.h>
#include <dt-bindings/zmk/outputs.h>

/ {
chosen {
zmk,matrix-transform = &matrix_transform;
zmk,physical-layout = &matrix_physical_layout;
};

sensors: sensors {
compatible = "zmk,keymap-sensors";
sensors = <&encoder>;
Expand Down Expand Up @@ -56,4 +58,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>
;
};

};
49 changes: 45 additions & 4 deletions app/boards/shields/zmk_uno/zmk_uno_split.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@

#include "zmk_uno.dtsi"

#include <physical_layouts.dtsi>

left_encoder: &encoder {
status = "disabled";
};

/ {
chosen {
zmk,matrix-transform = &split_matrix_transform;
zmk,physical-layout = &matrix_physical_layout;
};

split_matrix_transform: split_matrix_transform {
Expand All @@ -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";
Expand Down
7 changes: 1 addition & 6 deletions app/boards/shields/zmk_uno/zmk_uno_split.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -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;
// };
// };

Expand Down
2 changes: 1 addition & 1 deletion app/boards/shields/zmk_uno/zmk_uno_split_right.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
};

&split_direct_matrix_transform {
row-offset = <2>;
col-offset = <4>;
};

&right_encoder {
Expand Down

0 comments on commit cc051db

Please sign in to comment.