Skip to content

Per key/layer RGB underglow#30

Closed
darknao wants to merge 23 commits into
moergo-sc:mainfrom
darknao:darknao/rgb-dts
Closed

Per key/layer RGB underglow#30
darknao wants to merge 23 commits into
moergo-sc:mainfrom
darknao:darknao/rgb-dts

Conversation

@darknao

@darknao darknao commented May 21, 2024

Copy link
Copy Markdown

This adds per key / per layer RGB underglow configuration.
It's mainly based on @valdur mod with additional changes to make it configurable via devicetree.

It includes:

  • Valdur's RGB mod
  • Refactor, move configuration to devicetree, and some battery life optimization
  • fix(rgb): auto-off logic #2244 from ZMK upstream
  • Correctly set underglow state when entering sleep #2284 from ZMK upstream
  • feat(split): Increase split interval during idle #682 from ZMK upstream

How to use:
More instructions are available on my config repo.
TLDR: Add and customize this snippet to the Custom Device-tree field in the layout editor:

#include <dt-bindings/zmk/rgb_colors.h>
/ {
    underglow-layer {
        compatible  = "zmk,underglow-layer";

        // example of RGB layer for the Lower keymap layer
        lower {
            bindings = <
                ______ ______ ______ ______ ______                                                          ______ ______ ______ ______ ______
                PURPLE   PINK   PINK   PINK   PINK   PINK                                            ______   GOLD ORANGE ORANGE ORANGE    RED
                PURPLE ______ ______ ORANGE ______ ______                                            ______ YELLOW YELLOW YELLOW ORANGE ______
                PURPLE ______ ORANGE    RED ORANGE ______                                            ______ YELLOW YELLOW YELLOW ORANGE ______
                  BLUE ______    RED    RED    RED ______ ______ ______ ______  ______ ______ ______ ______ YELLOW YELLOW YELLOW    RED   BLUE
                ______ ______ ORANGE ORANGE ORANGE        ______  GREEN ______  ______ ______ ______        YELLOW YELLOW YELLOW    RED ______
                >;
            layer-id = <LAYER_Lower>;
        };

        // This defines another RGB layer
        another-layer {
            bindings = < [...] >;
            layer-id = <LAYER_Name>;
        };
    };
};

______ means the RGB is off. You can use predefined color name or RGB hex code like 0xFF0000 for red.
Full example on the Layout Editor here

To preserve battery life, I recommend enabling the ZMK_RGB_UNDERGLOW_AUTO_OFF_IDLE KConfig to automatically turn off underglow after ZMK_IDLE_TIMEOUT ms (default to 30 seconds).
From my limited experience, you can expect around one week of battery life with no RGB on the base layer.

chrisandreae and others added 21 commits February 10, 2024 13:38
Adds Glove80's status indicator using RGB underglow support. Requires ZMK
PR#999 and PR#1243.

The underglow status is able to show layer state, battery levels,
caps/num/scroll-lock, BLE and USB state. The underglow positions selected for
each of these indicators is configured using the new devicetree node
zmk,underglow-indicators, which takes an array of integer LED positions for each
feature.
Disable underglow when battery below 10%, halve brightness when battery below 20%
Adds a Kconfig setting for the default EXT_POWER status at initialization time. Previously it was always initialized to on if no saved value was present.
Provides an entry point that builds and returns a combined LH + RH keyboard
firmware when provided a keymap via a POST body.

Wraps compilation with ccache, and includes a pre-warmed cache of the build in /tmp/ccache.
To maximize chance of a direct cache hit, changes the lambda driver to always build in /tmp/build.

some back of the envelope measurements (2012 xeon e3-1230v2, nixos)
clean build, no cache -> 21.308
clean build, cache -> 7.145
modified keymap, clean build, cache -> 12.127
Additionally adds a board definition for Glove80-v0, an early version of Glove80.
…zation

I tried using event instead of the 25ms underglow_tick to update the underglow on
layer change only. That didn't improve the battery life much....
The second change is cutting off the led strip power if the underglow is
not defined for a layer. Power is restored if a layer with rgb is
activated, and cut off as soon as the layer is disabled.
This, on the other hand, improves the battery life a lot, especially if you
don't use rgb on your base layer.
If you are using rgb on your base layer, setting
CONFIG_ZMK_RGB_UNDERGLOW_AUTO_OFF_IDLE is highly recommended.
@darknao

darknao commented Jan 23, 2025

Copy link
Copy Markdown
Author

Closing as it has been replaced with #36

@darknao darknao closed this Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants