From 667ed584de8b86949512c7d39f659f3b853f8f12 Mon Sep 17 00:00:00 2001 From: Kim Streich Date: Sat, 26 Mar 2022 12:20:42 +0400 Subject: [PATCH] Added underglow to sofle shield commit cd4f9fb9e7efe5760e1b75d4647574ace38c8655 Author: Kim Streich Date: Sat Mar 26 11:53:24 2022 +0400 Sofle Shield: Added adjust layer to default keymap commit 2a2dad0041463819489cc054a9210c459f0dee30 Author: Kim Streich Date: Sat Mar 26 12:08:18 2022 +0400 Sofle Shield: Add underglow support commit 5ff17c56197293b71dfe304aaad946540a224963 Author: Kim Streich Date: Sat Mar 26 11:34:34 2022 +0400 Sofle Shield: Increase default encoder resolution --- app/boards/shields/sofle/Kconfig.defconfig | 8 +++- .../shields/sofle/boards/nice_nano.overlay | 28 ++++++++++++++ .../shields/sofle/boards/nice_nano_v2.overlay | 28 ++++++++++++++ .../shields/sofle/boards/nrfmicro_11.overlay | 28 ++++++++++++++ .../shields/sofle/boards/nrfmicro_13.overlay | 28 ++++++++++++++ app/boards/shields/sofle/sofle.conf | 8 ++++ app/boards/shields/sofle/sofle.dtsi | 4 +- app/boards/shields/sofle/sofle.keymap | 37 ++++++++++++++++++- app/boards/shields/sofle/sofle.zmk.yml | 1 + 9 files changed, 166 insertions(+), 4 deletions(-) create mode 100644 app/boards/shields/sofle/boards/nice_nano.overlay create mode 100644 app/boards/shields/sofle/boards/nice_nano_v2.overlay create mode 100644 app/boards/shields/sofle/boards/nrfmicro_11.overlay create mode 100644 app/boards/shields/sofle/boards/nrfmicro_13.overlay diff --git a/app/boards/shields/sofle/Kconfig.defconfig b/app/boards/shields/sofle/Kconfig.defconfig index fcee7fbe..9aae082b 100644 --- a/app/boards/shields/sofle/Kconfig.defconfig +++ b/app/boards/shields/sofle/Kconfig.defconfig @@ -8,7 +8,7 @@ config ZMK_KEYBOARD_NAME config ZMK_SPLIT_BLE_ROLE_CENTRAL default y - + endif if SHIELD_SOFLE_LEFT || SHIELD_SOFLE_RIGHT @@ -52,4 +52,10 @@ endchoice endif # LVGL +if ZMK_RGB_UNDERGLOW + +config WS2812_STRIP + default y +endif + endif diff --git a/app/boards/shields/sofle/boards/nice_nano.overlay b/app/boards/shields/sofle/boards/nice_nano.overlay new file mode 100644 index 00000000..198d8e35 --- /dev/null +++ b/app/boards/shields/sofle/boards/nice_nano.overlay @@ -0,0 +1,28 @@ +&spi1 { + compatible = "nordic,nrf-spim"; + status = "okay"; + mosi-pin = <6>; + // Unused pins, needed for SPI definition, but not used by the ws2812 driver itself. + sck-pin = <5>; + miso-pin = <7>; + + led_strip: ws2812@0 { + compatible = "worldsemi,ws2812-spi"; + label = "WS2812"; + + /* SPI */ + reg = <0>; /* ignored, but necessary for SPI bindings */ + spi-max-frequency = <4000000>; + + /* WS2812 */ + chain-length = <29>; /* arbitrary; change at will */ + spi-one-frame = <0x70>; + spi-zero-frame = <0x40>; + }; +}; + +/ { + chosen { + zmk,underglow = &led_strip; + }; +}; diff --git a/app/boards/shields/sofle/boards/nice_nano_v2.overlay b/app/boards/shields/sofle/boards/nice_nano_v2.overlay new file mode 100644 index 00000000..198d8e35 --- /dev/null +++ b/app/boards/shields/sofle/boards/nice_nano_v2.overlay @@ -0,0 +1,28 @@ +&spi1 { + compatible = "nordic,nrf-spim"; + status = "okay"; + mosi-pin = <6>; + // Unused pins, needed for SPI definition, but not used by the ws2812 driver itself. + sck-pin = <5>; + miso-pin = <7>; + + led_strip: ws2812@0 { + compatible = "worldsemi,ws2812-spi"; + label = "WS2812"; + + /* SPI */ + reg = <0>; /* ignored, but necessary for SPI bindings */ + spi-max-frequency = <4000000>; + + /* WS2812 */ + chain-length = <29>; /* arbitrary; change at will */ + spi-one-frame = <0x70>; + spi-zero-frame = <0x40>; + }; +}; + +/ { + chosen { + zmk,underglow = &led_strip; + }; +}; diff --git a/app/boards/shields/sofle/boards/nrfmicro_11.overlay b/app/boards/shields/sofle/boards/nrfmicro_11.overlay new file mode 100644 index 00000000..198d8e35 --- /dev/null +++ b/app/boards/shields/sofle/boards/nrfmicro_11.overlay @@ -0,0 +1,28 @@ +&spi1 { + compatible = "nordic,nrf-spim"; + status = "okay"; + mosi-pin = <6>; + // Unused pins, needed for SPI definition, but not used by the ws2812 driver itself. + sck-pin = <5>; + miso-pin = <7>; + + led_strip: ws2812@0 { + compatible = "worldsemi,ws2812-spi"; + label = "WS2812"; + + /* SPI */ + reg = <0>; /* ignored, but necessary for SPI bindings */ + spi-max-frequency = <4000000>; + + /* WS2812 */ + chain-length = <29>; /* arbitrary; change at will */ + spi-one-frame = <0x70>; + spi-zero-frame = <0x40>; + }; +}; + +/ { + chosen { + zmk,underglow = &led_strip; + }; +}; diff --git a/app/boards/shields/sofle/boards/nrfmicro_13.overlay b/app/boards/shields/sofle/boards/nrfmicro_13.overlay new file mode 100644 index 00000000..198d8e35 --- /dev/null +++ b/app/boards/shields/sofle/boards/nrfmicro_13.overlay @@ -0,0 +1,28 @@ +&spi1 { + compatible = "nordic,nrf-spim"; + status = "okay"; + mosi-pin = <6>; + // Unused pins, needed for SPI definition, but not used by the ws2812 driver itself. + sck-pin = <5>; + miso-pin = <7>; + + led_strip: ws2812@0 { + compatible = "worldsemi,ws2812-spi"; + label = "WS2812"; + + /* SPI */ + reg = <0>; /* ignored, but necessary for SPI bindings */ + spi-max-frequency = <4000000>; + + /* WS2812 */ + chain-length = <29>; /* arbitrary; change at will */ + spi-one-frame = <0x70>; + spi-zero-frame = <0x40>; + }; +}; + +/ { + chosen { + zmk,underglow = &led_strip; + }; +}; diff --git a/app/boards/shields/sofle/sofle.conf b/app/boards/shields/sofle/sofle.conf index fe3f0f4f..1f74aa33 100644 --- a/app/boards/shields/sofle/sofle.conf +++ b/app/boards/shields/sofle/sofle.conf @@ -7,3 +7,11 @@ # Uncomment these two lines to add support for encoders # CONFIG_EC11=y # CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y + +# Uncomment this line below to add rgb underglow / backlight support +# CONFIG_ZMK_RGB_UNDERGLOW=y + +# Uncomment the line below to disable external power toggling by the underglow. +# By default toggling the underglow on and off also toggles external power +# on and off. This also causes the display to turn off. +# CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER=n diff --git a/app/boards/shields/sofle/sofle.dtsi b/app/boards/shields/sofle/sofle.dtsi index 9646b59d..d959f589 100644 --- a/app/boards/shields/sofle/sofle.dtsi +++ b/app/boards/shields/sofle/sofle.dtsi @@ -49,7 +49,7 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,5) RC(4,6) RC(3,6) RC(3,7) label = "LEFT_ENCODER"; a-gpios = <&pro_micro 21 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; b-gpios = <&pro_micro 20 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; - resolution = <4>; + resolution = <2>; status = "disabled"; }; @@ -58,7 +58,7 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,5) RC(4,6) RC(3,6) RC(3,7) label = "RIGHT_ENCODER"; a-gpios = <&pro_micro 20 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; b-gpios = <&pro_micro 21 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; - resolution = <4>; + resolution = <2>; status = "disabled"; }; diff --git a/app/boards/shields/sofle/sofle.keymap b/app/boards/shields/sofle/sofle.keymap index 395ecf1d..9c07601a 100644 --- a/app/boards/shields/sofle/sofle.keymap +++ b/app/boards/shields/sofle/sofle.keymap @@ -7,8 +7,25 @@ #include #include #include +#include +#include + +#define BASE 0 +#define LOWER 1 +#define RAISE 2 +#define ADJUST 3 / { + + // Activate ADJUST layer by pressing raise and lower + conditional_layers { + compatible = "zmk,conditional-layers"; + adjust_layer { + if-layers = ; + then-layer = ; + }; + }; + keymap { compatible = "zmk,keymap"; @@ -24,7 +41,7 @@ &kp ESC &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BSPC &kp TAB &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp SQT &kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp C_MUTE &none &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp RSHFT - &kp LGUI &kp LALT &kp LCTRL &mo 1 &kp RET &kp SPACE &mo 2 &kp RCTRL &kp RALT &kp RGUI + &kp LGUI &kp LALT &kp LCTRL &mo LOWER &kp RET &kp SPACE &mo RAISE &kp RCTRL &kp RALT &kp RGUI >; sensor-bindings = <&inc_dec_kp C_VOL_UP C_VOL_DN &inc_dec_kp PG_UP PG_DN>; @@ -66,5 +83,23 @@ sensor-bindings = <&inc_dec_kp C_VOL_UP C_VOL_DN &inc_dec_kp PG_UP PG_DN>; }; + +// ------------------------------------------------------------------------------------------------------------ +// |BTCLR | BT1 | BT2 | BT3 | BT4 | BT5 | | | | | | | | +// |EXTPWR|RGB_HUD|RGB_HUI|RGB_SAD|RGB_SAI|RGB_EFF| | | | | | | | +// | |RGB_BRD|RGB_BRI| | | | | | | | | | | +// | | | | | | |RGB_TOG| | | | | | | | | +// | | | | | | | | | | | | + + Adjust_layer { + bindings = < +&bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &none &none &none &none &none &none +&ext_power EXT_POWER_TOGGLE_CMD &rgb_ug RGB_HUD &rgb_ug RGB_HUI &rgb_ug RGB_SAD &rgb_ug RGB_SAI &rgb_ug RGB_EFF &none &none &none &none &none &none +&none &rgb_ug RGB_BRD &rgb_ug RGB_BRI &none &none &none &none &none &none &none &none &none +&none &none &none &none &none &none &rgb_ug RGB_TOG &none &none &none &none &none &none &none + &none &none &none &none &none &none &none &none &none &none + >; + }; + }; }; diff --git a/app/boards/shields/sofle/sofle.zmk.yml b/app/boards/shields/sofle/sofle.zmk.yml index 5f6f99c3..47b66d67 100644 --- a/app/boards/shields/sofle/sofle.zmk.yml +++ b/app/boards/shields/sofle/sofle.zmk.yml @@ -9,6 +9,7 @@ features: - keys - display - encoder + - underglow siblings: - sofle_left - sofle_right