Skip to content

Commit

Permalink
refactor(shields): MurphPad
Browse files Browse the repository at this point in the history
* Added matrix transforms for three optional layouts.

* Tweaked default keymap to be more immediately useful for ZMK and more
  closely resemble the default keymaps of non-ZMK firmware.

* Board-specific Kconfig settings migrated to main shield file, so they
  will be exposed to end-users through the setup script.

* Removed deprecated label properties and tidied formatting.

* Aligned encoder configuration with current standards.

* Corrected default number of RGB LEDs.
  • Loading branch information
lesshonor committed Jan 9, 2024
1 parent 0e2f94b commit e173060
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 43 deletions.
3 changes: 0 additions & 3 deletions app/boards/shields/murphpad/boards/nice_nano.conf

This file was deleted.

2 changes: 1 addition & 1 deletion app/boards/shields/murphpad/boards/nice_nano.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
spi-max-frequency = <4000000>;

/* WS2812 */
chain-length = <10>; /* arbitrary; change at will */
chain-length = <8>; /* number of SMD LED footprints on PCB */
spi-one-frame = <0x70>;
spi-zero-frame = <0x40>;

Expand Down
2 changes: 1 addition & 1 deletion app/boards/shields/murphpad/boards/nice_nano_v2.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
spi-max-frequency = <4000000>;

/* WS2812 */
chain-length = <10>; /* arbitrary; change at will */
chain-length = <8>; /* number of SMD LED footprints on PCB */
spi-one-frame = <0x70>;
spi-zero-frame = <0x40>;

Expand Down
11 changes: 8 additions & 3 deletions app/boards/shields/murphpad/murphpad.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Uncomment to turn on logging, and set ZMK logging to debug output
# Uncomment to turn on USB logging
# CONFIG_ZMK_USB_LOGGING=y

# Uncomment both to enable encoder
# Uncomment both to enable encoder(s)
CONFIG_EC11=y
CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y

# Uncomment to enable OLED
CONFIG_ZMK_DISPLAY=y
CONFIG_ZMK_DISPLAY=y

# Uncomment both to enable underglow
# Note that this will only work if an implementation exists for your board; check under the shield folder for board-specific overlays.
#CONFIG_ZMK_RGB_UNDERGLOW=y
#CONFIG_WS2812_STRIP=y
55 changes: 28 additions & 27 deletions app/boards/shields/murphpad/murphpad.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -7,63 +7,62 @@
#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/bt.h>
#include <dt-bindings/zmk/outputs.h>
#include <dt-bindings/zmk/rgb.h>


#define TIMEOUT 300

&encoder_1 {
&middle_left_encoder {
status = "okay";
};

&encoder_2 {
&top_right_encoder {
status = "okay";
};

&sensors {
sensors = <&middle_left_encoder &top_right_encoder>;
};

/ {
combos {
compatible = "zmk,combos";
combo_btclr {
timeout-ms = <TIMEOUT>;
key-positions = <1 6>;
key-positions = <0 4>;
bindings = <&bt BT_CLR>;
};
combo_reset {
timeout-ms = <TIMEOUT>;
key-positions = <1 3>;
key-positions = <0 2>;
bindings = <&sys_reset>;
};
combo_bootloader {
timeout-ms = <TIMEOUT>;
key-positions = <1 2>;
key-positions = <0 1>;
bindings = <&bootloader>;
};
combo_bt_nxt {
timeout-ms = <TIMEOUT>;
key-positions = <1 4>;
key-positions = <0 3>;
bindings = <&bt BT_NXT>;
};
};

sensors {
compatible = "zmk,keymap-sensors";
sensors = <&encoder_1 &encoder_2>;
triggers-per-rotation = <20>;
};


keymap0: keymap {
compatible = "zmk,keymap";

default_layer {
display-name = "default layer";
bindings = <
&bt BT_CLR &kp TAB &kp F5 &kp LC(LA(C)) &kp LG(D)
&rgb_ug RGB_TOG &kp ESC &kp KP_DIVIDE &kp KP_MULTIPLY &kp KP_MINUS
&rgb_ug RGB_EFF &kp KP_N7 &kp KP_N8 &kp KP_N9 &kp KP_PLUS
&kp C_MUTE &kp KP_N4 &kp KP_N5 &kp KP_N6 &trans
&mo 1 &kp KP_N1 &kp KP_N2 &kp KP_N3 &kp KP_ENTER
&kp BSPC &kp KP_N0 &trans &kp KP_DOT &trans
&kp F1 &kp F2 &kp F3 &kp F4
&kp KP_NUM &kp KP_DIVIDE &kp KP_MULTIPLY &kp KP_MINUS
&kp KP_N7 &kp KP_N8 &kp KP_N9 &kp KP_PLUS
&kp C_MUTE &kp KP_N4 &kp KP_N5 &kp KP_N6 &trans
&mo 1 &kp KP_N1 &kp KP_N2 &kp KP_N3 &kp KP_ENTER
&kp BSPC &kp KP_N0 &trans &kp KP_DOT &trans

&bt BT_CLR &rgb_ug RGB_TOG &rgb_ug RGB_EFF
>;
sensor-bindings = <&inc_dec_kp C_VOL_UP C_VOL_DN &inc_dec_kp PG_UP PG_DN>;

Expand All @@ -72,15 +71,17 @@
fn_layer {
display-name = "fn layer";
bindings = <
&trans &trans &trans &trans &trans
&trans &kp KP_NUM &trans &trans &trans
&trans &trans &trans &trans &trans
&bt BT_CLR &trans &trans &trans &trans
&trans &trans &trans &trans &trans
&kp DEL &trans &trans &trans &trans
&out OUT_TOG &bt BT_PRV &bt BT_NXT &trans
&trans &trans &trans &trans
&rgb_ug RGB_HUD &rgb_ug RGB_SPI &rgb_ug RGB_HUI &trans
&bt BT_CLR &rgb_ug RGB_EFR &rgb_ug RGB_TOG &rgb_ug RGB_EFF &trans
&trans &rgb_ug RGB_BRD &rgb_ug RGB_SPD &rgb_ug RGB_BRI &trans
&kp DEL &rgb_ug RGB_SAD &trans &rgb_ug RGB_SAI &trans

&trans &trans &trans
>;
sensor-bindings = <&inc_dec_kp PG_UP PG_DN &inc_dec_kp C_VOL_UP C_VOL_DN>;

};
};
};
};
71 changes: 63 additions & 8 deletions app/boards/shields/murphpad/murphpad.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,101 @@
/ {
chosen {
zephyr,display = &oled;
zmk,kscan = &kscan0;
zmk,kscan = &kscan;
zmk,matrix-transform = &all_1u_transform;
};

kscan0: kscan {
kscan: kscan_0 {
compatible = "zmk,kscan-gpio-matrix";

diode-direction = "col2row";
row-gpios
= <&pro_micro 20 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
= <&pro_micro 20 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 16 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 15 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 18 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 19 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 18 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 19 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
;
col-gpios
= <&pro_micro 9 GPIO_ACTIVE_HIGH>
, <&pro_micro 6 GPIO_ACTIVE_HIGH>
, <&pro_micro 5 GPIO_ACTIVE_HIGH>
, <&pro_micro 4 GPIO_ACTIVE_HIGH>
, <&pro_micro 10 GPIO_ACTIVE_HIGH>
, <&pro_micro 10 GPIO_ACTIVE_HIGH>
;
};

encoder_1: encoder_1 {
all_1u_transform: keymap_transform_0 {
compatible = "zmk,matrix-transform";
columns = <5>;
rows = <6>;
map = <
RC(0,1) RC(0,2) RC(0,3) RC(0,4)
RC(1,1) RC(1,2) RC(1,3) RC(1,4)
RC(2,1) RC(2,2) RC(2,3) RC(2,4)
RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4)
RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,4)
RC(5,0) RC(5,1) RC(5,2) RC(5,3) RC(5,4)

RC(0,0) RC(1,0) RC(2,0)
>;
};

right_numpad_transform: keymap_transform_1 {
compatible = "zmk,matrix-transform";
columns = <5>;
rows = <6>;
map = <
RC(0,1) RC(0,2) RC(0,3) RC(0,4)
RC(1,1) RC(1,2) RC(1,3) RC(1,4)
RC(2,1) RC(2,2) RC(2,3) RC(2,4)
RC(3,0) RC(3,2) RC(3,3) RC(3,4)
RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,4)
RC(5,0) RC(5,2) RC(5,4)

RC(0,0) RC(1,0) RC(2,0)
>;
};

left_numpad_transform: keymap_transform_2 {
compatible = "zmk,matrix-transform";
columns = <5>;
rows = <6>;
map = <
RC(0,1) RC(0,2) RC(0,3) RC(0,4)
RC(1,1) RC(1,2) RC(1,3) RC(1,4)
RC(2,1) RC(2,2) RC(2,3) RC(2,4)
RC(3,0) RC(3,1) RC(3,2) RC(3,3)
RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,4)
RC(5,0) RC(5,1) RC(5,3)

RC(0,0) RC(1,0) RC(2,0)
>;
};

middle_left_encoder: encoder_1: encoder_1 {
compatible = "alps,ec11";
a-gpios = <&pro_micro 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
b-gpios = <&pro_micro 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
steps = <80>;
status = "disabled";
};

encoder_2: encoder_2 {
top_right_encoder: encoder_2: encoder_2 {
compatible = "alps,ec11";
a-gpios = <&pro_micro 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
b-gpios = <&pro_micro 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
steps = <80>;
status = "disabled";
};

sensors: sensors_0 {
compatible = "zmk,keymap-sensors";
sensors = <&middle_left_encoder &top_right_encoder>;
triggers-per-rotation = <20>;
};

};

&pro_micro_i2c {
Expand Down

0 comments on commit e173060

Please sign in to comment.