From c244a5cb7bdeb96f5618b14e5ad7e1a950a33b55 Mon Sep 17 00:00:00 2001 From: Kim Streich Date: Sat, 26 Mar 2022 12:08:18 +0400 Subject: [PATCH] Sofle Shield: Add underglow support Update sofle underglow to zephyr 3 --- app/boards/shields/sofle/Kconfig.defconfig | 6 ++++ .../shields/sofle/boards/nice_nano.overlay | 35 +++++++++++++++++++ .../shields/sofle/boards/nice_nano_v2.overlay | 35 +++++++++++++++++++ .../shields/sofle/boards/nrfmicro_11.overlay | 35 +++++++++++++++++++ .../shields/sofle/boards/nrfmicro_13.overlay | 35 +++++++++++++++++++ app/boards/shields/sofle/sofle.conf | 8 +++++ app/boards/shields/sofle/sofle.zmk.yml | 1 + 7 files changed, 155 insertions(+) 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 cc598d67..4e7bf884 100644 --- a/app/boards/shields/sofle/Kconfig.defconfig +++ b/app/boards/shields/sofle/Kconfig.defconfig @@ -46,4 +46,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..de33fcd7 --- /dev/null +++ b/app/boards/shields/sofle/boards/nice_nano.overlay @@ -0,0 +1,35 @@ +#include + +&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>; + color-mapping = < + LED_COLOR_ID_GREEN + LED_COLOR_ID_RED + LED_COLOR_ID_BLUE + >; + }; +}; + +/ { + 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..de33fcd7 --- /dev/null +++ b/app/boards/shields/sofle/boards/nice_nano_v2.overlay @@ -0,0 +1,35 @@ +#include + +&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>; + color-mapping = < + LED_COLOR_ID_GREEN + LED_COLOR_ID_RED + LED_COLOR_ID_BLUE + >; + }; +}; + +/ { + 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..de33fcd7 --- /dev/null +++ b/app/boards/shields/sofle/boards/nrfmicro_11.overlay @@ -0,0 +1,35 @@ +#include + +&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>; + color-mapping = < + LED_COLOR_ID_GREEN + LED_COLOR_ID_RED + LED_COLOR_ID_BLUE + >; + }; +}; + +/ { + 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..de33fcd7 --- /dev/null +++ b/app/boards/shields/sofle/boards/nrfmicro_13.overlay @@ -0,0 +1,35 @@ +#include + +&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>; + color-mapping = < + LED_COLOR_ID_GREEN + LED_COLOR_ID_RED + LED_COLOR_ID_BLUE + >; + }; +}; + +/ { + 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.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