summaryrefslogtreecommitdiff
path: root/quantum/rgblight
diff options
context:
space:
mode:
authorizmishi <31067139+izmishi@users.noreply.github.com>2022-09-28 18:16:24 +0100
committerGitHub <noreply@github.com>2022-09-28 13:16:24 -0400
commit703d8cd417115d6e37090e26e358cf73f6346113 (patch)
treebdcfe8af8521d09e193e81250dcc7386bcf4e0e7 /quantum/rgblight
parent8d8e70fc3f39b2588a650883ec03d8c60719d8f0 (diff)
Fix retain brightness when val is changed while a layer is active (#18426)
* Fix retain brightness when val is changed while a layer is active * Fix retain brightness for RGBLIGHT_MODE_STATIC_GRADIENT * Fix formatting
Diffstat (limited to 'quantum/rgblight')
-rw-r--r--quantum/rgblight/rgblight.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c
index 73b352cea8..37cd7a66ab 100644
--- a/quantum/rgblight/rgblight.c
+++ b/quantum/rgblight/rgblight.c
@@ -523,10 +523,19 @@ void rgblight_sethsv_noeeprom_old(uint8_t hue, uint8_t sat, uint8_t val) {
523 523
524void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) { 524void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) {
525 if (rgblight_config.enable) { 525 if (rgblight_config.enable) {
526#ifdef RGBLIGHT_SPLIT
527 if (rgblight_config.hue != hue || rgblight_config.sat != sat || rgblight_config.val != val) {
528 RGBLIGHT_SPLIT_SET_CHANGE_HSVS;
529 }
530#endif
526 rgblight_status.base_mode = mode_base_table[rgblight_config.mode]; 531 rgblight_status.base_mode = mode_base_table[rgblight_config.mode];
527 if (rgblight_config.mode == RGBLIGHT_MODE_STATIC_LIGHT) { 532 if (rgblight_config.mode == RGBLIGHT_MODE_STATIC_LIGHT) {
528 // same static color 533 // same static color
529 LED_TYPE tmp_led; 534 LED_TYPE tmp_led;
535#ifdef RGBLIGHT_LAYERS_RETAIN_VAL
536 // needed for rgblight_layers_write() to get the new val, since it reads rgblight_config.val
537 rgblight_config.val = val;
538#endif
530 sethsv(hue, sat, val, &tmp_led); 539 sethsv(hue, sat, val, &tmp_led);
531 rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b); 540 rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b);
532 } else { 541 } else {
@@ -568,15 +577,14 @@ void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool w
568 dprintf("rgblight rainbow set hsv: %d,%d,%d,%u\n", i, _hue, direction, range); 577 dprintf("rgblight rainbow set hsv: %d,%d,%d,%u\n", i, _hue, direction, range);
569 sethsv(_hue, sat, val, (LED_TYPE *)&led[i + rgblight_ranges.effect_start_pos]); 578 sethsv(_hue, sat, val, (LED_TYPE *)&led[i + rgblight_ranges.effect_start_pos]);
570 } 579 }
580# ifdef RGBLIGHT_LAYERS_RETAIN_VAL
581 // needed for rgblight_layers_write() to get the new val, since it reads rgblight_config.val
582 rgblight_config.val = val;
583# endif
571 rgblight_set(); 584 rgblight_set();
572 } 585 }
573#endif 586#endif
574 } 587 }
575#ifdef RGBLIGHT_SPLIT
576 if (rgblight_config.hue != hue || rgblight_config.sat != sat || rgblight_config.val != val) {
577 RGBLIGHT_SPLIT_SET_CHANGE_HSVS;
578 }
579#endif
580 rgblight_config.hue = hue; 588 rgblight_config.hue = hue;
581 rgblight_config.sat = sat; 589 rgblight_config.sat = sat;
582 rgblight_config.val = val; 590 rgblight_config.val = val;