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

Conversation

izmishi
Copy link
Contributor

@izmishi izmishi commented Sep 19, 2022

Description

If RGBLIGHT_LAYERS_RETAIN_VAL is defined while lighting layers are used, rgblight_layers_write() checks rgblight_config.val for the currently set brightness. However, rgblight_sethsv_eeprom_helper() updates rgblight_config.val with the new val after it calls rgblight_setrgb(), which ultimately calls rgblight_layers_write(). This means that if the brightness is changed while a lighting layer is active, the LEDs won't change to the new brightness until the lighting layer changes, or the HSV is changed again.

Tested with Iris Rev. 3

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@github-actions github-actions bot added the core label Sep 19, 2022
Copy link
Contributor

@spidey3 spidey3 left a comment

Choose a reason for hiding this comment

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

LGTM, but please see the suggested change below, and please test this with RGBLIGHT_EFFECT_STATIC_GRADIENT.

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

@izmishi
Copy link
Contributor Author

izmishi commented Sep 20, 2022

I've made the requested changes and tested it with RGBLIGHT_EFFECT_STATIC_GRADIENT on my keyboard.

@izmishi izmishi requested a review from spidey3 September 23, 2022 21:18
@drashna drashna requested a review from a team September 24, 2022 14:29
@spidey3 spidey3 merged commit 703d8cd into qmk:develop Sep 28, 2022
ramonimbao pushed a commit to ramonimbao/qmk_firmware that referenced this pull request Nov 28, 2022
…k#18426)

* Fix retain brightness when val is changed while a layer is active

* Fix retain brightness for RGBLIGHT_MODE_STATIC_GRADIENT

* Fix formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants