summaryrefslogtreecommitdiff
path: root/quantum/rgblight
diff options
context:
space:
mode:
authorPatrick Stadler <patrick.stadler@gmail.com>2021-07-22 08:46:12 +0200
committerGitHub <noreply@github.com>2021-07-21 23:46:12 -0700
commitfb9a254a432e307e82c9dce45e1aba2cf21fa339 (patch)
treee4fc4e5464764d421d89ad0e6189a77e03d68851 /quantum/rgblight
parent85128302c83b7d8b2525f371c96b46ae79aac801 (diff)
Retain brightness with lighting layers (#13025)
Add guard `RGBLIGHT_LAYERS_RETAIN_VAL` to retain the currently used val when applying lighting layers.
Diffstat (limited to 'quantum/rgblight')
-rw-r--r--quantum/rgblight/rgblight.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c
index 54face173c..373dc08d3a 100644
--- a/quantum/rgblight/rgblight.c
+++ b/quantum/rgblight/rgblight.c
@@ -694,6 +694,9 @@ bool rgblight_get_layer_state(uint8_t layer) {
// Write any enabled LED layers into the buffer
static void rgblight_layers_write(void) {
+# ifdef RGBLIGHT_LAYERS_RETAIN_VAL
+ uint8_t current_val = rgblight_get_val();
+# endif
uint8_t i = 0;
// For each layer
for (const rgblight_segment_t *const *layer_ptr = rgblight_layers; i < RGBLIGHT_MAX_LAYERS; layer_ptr++, i++) {
@@ -714,7 +717,11 @@ static void rgblight_layers_write(void) {
// Write segment.count LEDs
LED_TYPE *const limit = &led[MIN(segment.index + segment.count, RGBLED_NUM)];
for (LED_TYPE *led_ptr = &led[segment.index]; led_ptr < limit; led_ptr++) {
+# ifdef RGBLIGHT_LAYERS_RETAIN_VAL
+ sethsv(segment.hue, segment.sat, current_val, led_ptr);
+# else
sethsv(segment.hue, segment.sat, segment.val, led_ptr);
+# endif
}
segment_ptr++;
}