From dfb4cca1831330dc81606fe9dad87d7e3c514141 Mon Sep 17 00:00:00 2001 From: Izumu Mishima <31067139+izmishi@users.noreply.github.com> Date: Mon, 19 Sep 2022 20:14:25 +0100 Subject: [PATCH 1/3] Fix retain brightness when val is changed while a layer is active --- quantum/rgblight/rgblight.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c index e5d3a98bea5e..7e0c611dc696 100644 --- a/quantum/rgblight/rgblight.c +++ b/quantum/rgblight/rgblight.c @@ -526,10 +526,19 @@ void rgblight_sethsv_noeeprom_old(uint8_t hue, uint8_t sat, uint8_t val) { void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) { if (rgblight_config.enable) { +#ifdef RGBLIGHT_SPLIT + if (rgblight_config.hue != hue || rgblight_config.sat != sat || rgblight_config.val != val) { + RGBLIGHT_SPLIT_SET_CHANGE_HSVS; + } +#endif rgblight_status.base_mode = mode_base_table[rgblight_config.mode]; if (rgblight_config.mode == RGBLIGHT_MODE_STATIC_LIGHT) { // same static color LED_TYPE tmp_led; +#ifdef RGBLIGHT_LAYERS_RETAIN_VAL + // needed for rgblight_layers_write() to get the new val, since it reads rgblight_config.val + rgblight_config.val = val; +#endif sethsv(hue, sat, val, &tmp_led); rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b); } else { @@ -575,11 +584,6 @@ void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool w } #endif } -#ifdef RGBLIGHT_SPLIT - if (rgblight_config.hue != hue || rgblight_config.sat != sat || rgblight_config.val != val) { - RGBLIGHT_SPLIT_SET_CHANGE_HSVS; - } -#endif rgblight_config.hue = hue; rgblight_config.sat = sat; rgblight_config.val = val; From c621039761c4dee386a7f624a9163bff50aef12e Mon Sep 17 00:00:00 2001 From: Izumu Mishima <31067139+izmishi@users.noreply.github.com> Date: Tue, 20 Sep 2022 12:37:58 +0100 Subject: [PATCH 2/3] Fix retain brightness for RGBLIGHT_MODE_STATIC_GRADIENT --- quantum/rgblight/rgblight.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c index 7e0c611dc696..7ab6d1161515 100644 --- a/quantum/rgblight/rgblight.c +++ b/quantum/rgblight/rgblight.c @@ -580,6 +580,10 @@ void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool w dprintf("rgblight rainbow set hsv: %d,%d,%d,%u\n", i, _hue, direction, range); sethsv(_hue, sat, val, (LED_TYPE *)&led[i + rgblight_ranges.effect_start_pos]); } +#ifdef RGBLIGHT_LAYERS_RETAIN_VAL + // needed for rgblight_layers_write() to get the new val, since it reads rgblight_config.val + rgblight_config.val = val; +#endif rgblight_set(); } #endif From 23ca7b15f6c26d2670394840f1eb1e581a2d246e Mon Sep 17 00:00:00 2001 From: Izumu Mishima <31067139+izmishi@users.noreply.github.com> Date: Wed, 21 Sep 2022 12:55:08 +0100 Subject: [PATCH 3/3] Fix formatting --- quantum/rgblight/rgblight.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c index 7ab6d1161515..73d3249293d1 100644 --- a/quantum/rgblight/rgblight.c +++ b/quantum/rgblight/rgblight.c @@ -580,10 +580,10 @@ void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool w dprintf("rgblight rainbow set hsv: %d,%d,%d,%u\n", i, _hue, direction, range); sethsv(_hue, sat, val, (LED_TYPE *)&led[i + rgblight_ranges.effect_start_pos]); } -#ifdef RGBLIGHT_LAYERS_RETAIN_VAL +# ifdef RGBLIGHT_LAYERS_RETAIN_VAL // needed for rgblight_layers_write() to get the new val, since it reads rgblight_config.val rgblight_config.val = val; -#endif +# endif rgblight_set(); } #endif