Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix retain brightness when val is changed while a layer is active #18426

Merged
merged 3 commits into from
Sep 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions quantum/rgblight/rgblight.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think similar code is needed in the RGBLIGHT_MODE_STATIC_GRADIENT case below, at line 580...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, RGBLIGHT_MODE_STATIC_GRADIENT needs it too

// 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 {
Expand Down Expand Up @@ -571,15 +580,14 @@ 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
}
#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;
Expand Down