From 77aa40213be999d84242ddfe2f160dc11e3ec5cb Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Sat, 16 Sep 2023 11:50:12 -0700 Subject: [PATCH] feat(shields): Add soft-off to the nrf52840dk ZMK Uno * Use Button 1 for soft off on the nrf52840 when using the ZMK Uno shield. --- .../boards/nrf52840dk_nrf52840.overlay | 45 ++++++++++++++++++- app/boards/shields/zmk_uno/zmk_uno.overlay | 3 ++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/app/boards/shields/zmk_uno/boards/nrf52840dk_nrf52840.overlay b/app/boards/shields/zmk_uno/boards/nrf52840dk_nrf52840.overlay index 5ac7af7c532..5f3b9683a58 100644 --- a/app/boards/shields/zmk_uno/boards/nrf52840dk_nrf52840.overlay +++ b/app/boards/shields/zmk_uno/boards/nrf52840dk_nrf52840.overlay @@ -12,6 +12,15 @@ bias-pull-up; }; }; + + qdec_sleep: qdec_sleep { + group1 { + psels = , + ; + bias-pull-up; + low-power-enable; + }; + }; }; // Set up the QDEC hardware based driver and give it the same label as the deleted node. @@ -20,5 +29,39 @@ encoder: &qdec0 { led-pre = <0>; steps = <80>; pinctrl-0 = <&qdec_default>; - pinctrl-names = "default"; + pinctrl-1 = <&qdec_sleep>; + pinctrl-names = "default", "sleep"; }; + +/ { + behaviors { + soft_off: behavior_soft_off { + compatible = "zmk,behavior-soft-off"; + #binding-cells = <0>; + label = "SOFT_OFF"; + status = "okay"; + }; + }; + + wakeup_source: wakeup_source { + compatible = "zmk,wakeup-trigger-key"; + status = "okay"; + + trigger = <&button0>; + wakeup-source; + }; + + soft_off_wakers { + compatible = "zmk,soft-off-wakeup-sources"; + status = "okay"; + + wakeup-sources = <&wakeup_source>; + }; + + soft_off_behavior_key { + compatible = "zmk,behavior-key"; + status = "okay"; + bindings = <&soft_off>; + key = <&button0>; + }; +}; \ No newline at end of file diff --git a/app/boards/shields/zmk_uno/zmk_uno.overlay b/app/boards/shields/zmk_uno/zmk_uno.overlay index 02bb4ad8e81..38c5827f4f6 100644 --- a/app/boards/shields/zmk_uno/zmk_uno.overlay +++ b/app/boards/shields/zmk_uno/zmk_uno.overlay @@ -132,6 +132,7 @@ nice_view_spi: &arduino_spi { kscan_matrix: kscan_matrix { compatible = "zmk,kscan-gpio-matrix"; + wakeup-source; diode-direction = "col2row"; @@ -149,6 +150,7 @@ nice_view_spi: &arduino_spi { kscan_direct: kscan_direct { compatible = "zmk,kscan-gpio-direct"; + wakeup-source; status = "disabled"; input-gpios @@ -163,6 +165,7 @@ nice_view_spi: &arduino_spi { kscan_sp3t_toggle: kscan_sp3t_toggle { compatible = "zmk,kscan-gpio-direct"; toggle-mode; + wakeup-source; input-gpios = <&arduino_header 4 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>