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

Add VIA support for QMK backlight, QMK RGBLight #7911

Merged
merged 4 commits into from
Jan 20, 2020

Conversation

wilba
Copy link
Contributor

@wilba wilba commented Jan 15, 2020

This PR adds VIA support for QMK core's backlight and RGBLight (aka. RGB underglow).

via_lighting

Description

VIA developers are working on a fully generalized solution to the problem of keyboards having many different lighting implementations. This PR focusses on bringing VIA support to the many keyboards already in QMK which use QMK's backlight and/or RGBLight features. It is minimal and matches the current set of lighting parameters that exist now, in order to support keyboards already in QMK now, while we work on a more generalized solution that can handle keyboards that have specific differences to the majority, such as indicator LEDs.

By default, if a keyboard enables BACKLIGHT_ENABLE and/or RGBLIGHT_ENABLE, and also VIA_ENABLE, then via.c will compile in the protocol handling for what VIA will require to connect the user interface controls to the lighting parameters. There is also a way of overriding the default behaviour and allowing keyboard-level code to handle the VIA protocol. Keyboards by wilba.tech, yiancardesigns and cannonkeys do this. For keyboards that disable some of the RGBLight modes, this will require overriding the default behaviour of VIA and explicitly defining the mode names in the .json file that VIA uses for that keyboard.

There are some minor changes to QMK Core's backlight and RGBLight code to support how VIA will throttle the amount of EEPROM updates that occur by delaying the sending of a id_lighting_save until a timeout after the last send of id_lighting_set_value. This allows fast changing brightness and color changing (through sliders/color pickers) to not cause a lot of redundant EEPROM updates. This is why eeconfig_update_backlight_current(void) and eeconfig_update_rgblight_current(void) were added, and via.c calls functions that change the lighting parameters without the EEPROM update.

In the <keyboard>.json file that VIA uses:

"lighting": "qmk_backlight" - keyboard uses QMK backlight only (or a custom overide)
"lighting": "qmk_rgblight" - keyboard uses QMK RGBLight only (or a custom overide)
"lighting": "qmk_backlight_rgblight" - keyboard uses both QMK backlight and QMK RGBLight (or a custom overide)

VIA developers are working hard on VIA and helping people to add keyboards, as well as designing a system to support QMK's greatest strength, the ability to customize firmware. We appreciate people's patience and understanding that we cannot support every keyboards's specific needs at this time.

Types of Changes

  • Core

  • Bugfix

  • New feature

  • Enhancement/optimization

  • Keyboard (addition or update)

  • Keymap/layout/userspace (addition or update)

  • Documentation

Checklist

  • My code follows the code style of this project.
  • 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).

@wilba
Copy link
Contributor Author

wilba commented Jan 15, 2020

@fcoury Thank you for your work, I had to change how some of it worked as the mapping of RGBLight modes you did wasn't compatible with the enums being conditionally defined when keyboards disable some modes.

@drashna drashna requested a review from a team January 15, 2020 19:25
@fcoury
Copy link
Contributor

fcoury commented Jan 15, 2020

@Wilba6582 really glad to see this closer to being released, thanks a lot for your (re)work and review here.

@MxBlu
Copy link
Contributor

MxBlu commented Jan 16, 2020

The implentation for animation speed would only works for rgblight_matrix I believe, rgblight underglow still just uses mode - base_mode:

uint8_t delta = rgblight_config.mode - rgblight_status.base_mode;

I'll test it later and post my results.

@wilba
Copy link
Contributor Author

wilba commented Jan 16, 2020

Effect speed was added to the protocol in case this is used in future by RGBLight (i.e. it doesn't do anything at present with the "underglow" modes). It's also there in case someone wants to do a custom implementation at the keyboard level.

As I mentioned already, this PR does not try to refactor the current system of embedding effect speeds into the mode enum, or do any mapping or subset of available modes, just connect the existing RGBLight to VIA's UI so end users can pick a mode and color.

@wilba wilba mentioned this pull request Jan 16, 2020
7 tasks
@MxBlu
Copy link
Contributor

MxBlu commented Jan 18, 2020

Tested this PR as working for rgblight in mxss with no config, and with custom backlighting enabled too.

Copy link
Contributor

@mechmerlin mechmerlin left a comment

Choose a reason for hiding this comment

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

LGTM =)

@MxBlu
Copy link
Contributor

MxBlu commented Jan 20, 2020

Looks like 667045b caused a conflict (clang-format do be like that).

Copy link
Member

@fauxpark fauxpark left a comment

Choose a reason for hiding this comment

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

Just some tiny clang-format related things. Worth running it on via.[ch] too.

quantum/backlight/backlight.c Outdated Show resolved Hide resolved
quantum/backlight/backlight.c Show resolved Hide resolved
@mechmerlin mechmerlin merged commit 484a9b1 into qmk:master Jan 20, 2020
drashna pushed a commit to zsa/qmk_firmware that referenced this pull request Feb 14, 2020
* Add VIA support for QMK backlight, QMK RGBLight

* clang-format changes
fdidron pushed a commit to zsa/qmk_firmware that referenced this pull request Feb 15, 2020
* Add VIA support for QMK backlight, QMK RGBLight

* clang-format changes
HokieGeek pushed a commit to HokieGeek/qmk_firmware that referenced this pull request Feb 21, 2020
* Add VIA support for QMK backlight, QMK RGBLight

* clang-format changes
fdidron pushed a commit to zsa/qmk_firmware that referenced this pull request Feb 26, 2020
* Add VIA support for QMK backlight, QMK RGBLight

* clang-format changes
kylekuj pushed a commit to kylekuj/qmk_firmware that referenced this pull request Apr 21, 2020
* Add VIA support for QMK backlight, QMK RGBLight

* clang-format changes
@wilba wilba deleted the via_lighting_pr branch March 23, 2021 23:11
BorisTestov pushed a commit to BorisTestov/qmk_firmware that referenced this pull request May 23, 2024
* Add VIA support for QMK backlight, QMK RGBLight

* clang-format changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants