Skip to content

Adding support of subtracting of a white with a given color temperature#1993

Open
lougovsk wants to merge 13 commits intohyperion-project:masterfrom
lougovsk:feature/custom_white_K
Open

Adding support of subtracting of a white with a given color temperature#1993
lougovsk wants to merge 13 commits intohyperion-project:masterfrom
lougovsk:feature/custom_white_K

Conversation

@lougovsk
Copy link
Copy Markdown
Contributor

Summary

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • [X ] Feature
  • Code style update
  • Refactor
  • Docs
  • Build-related changes
  • Other, please describe:

If changing the UI of web configuration, please provide the before/after screenshot:

After
Screenshot 2026-03-31 at 00 46 00

Does this PR introduce a breaking change? (check one)

  • Yes
  • [X ] No

If yes, please describe the impact and migration path for existing setups:

The PR fulfills these requirements:

  • When resolving a specific issue, it's referenced in the PR's body (e.g. Fixes: #xxx[,#xxx], where "xxx" is the issue number)

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature
  • Related documents have been updated (docs/docs/en)
  • Related tests have been updated

PLEASE DON'T FORGET TO ADD YOUR CHANGES TO CHANGELOG.MD

  • Yes, CHANGELOG.md is also updated

To avoid wasting your time, it's best to open a feature request issue first and wait for approval before working on it.

Other information:
This MR corresponds to the #1956

google-labs-jules Bot and others added 12 commits March 30, 2026 07:24
This commit introduces RGBW (Red, Green, Blue, White) data handling
for the E1.31 UDP LED device.

Key changes:

1.  **LedDeviceUdpE131.h modifications:**
    *   Included `utils/ColorRgbw.h` and `utils/RgbToRgbw.h`.
    *   Added private member variables:
        *   `_whiteAlgorithm` (RGBW::WhiteAlgorithm) to store the selected white calibration mode.
        *   `_ledRGBWCount` (int) to store the total number of channels (3 for RGB, 4 for RGBW).
        *   `_temp_rgbw` (ColorRgbw) as a temporary variable for color conversion.

2.  **LedDeviceUdpE131.cpp modifications:**
    *   Constructor now initializes `_whiteAlgorithm` to `INVALID` and `_ledRGBWCount` to 0.
    *   `init()` method:
        *   Reads `whiteAlgorithm` from the device configuration (defaults to "white_off").
        *   Converts the string to `RGBW::WhiteAlgorithm`.
        *   Sets `_ledRGBWCount` based on `_ledCount` and whether a white channel is active (3 * _ledCount for RGB, 4 * _ledCount for RGBW).
    *   `write()` method:
        *   Uses `_ledRGBWCount` for `dmxChannelCount`.
        *   Creates a temporary buffer for pixel data.
        *   If `_whiteAlgorithm` is `WHITE_OFF`, copies RGB data directly.
        *   Otherwise, converts RGB to RGBW using `RGBW::Rgb_to_Rgbw` and copies R,G,B,W data.
        *   Populates E1.31 packet properties using the new (potentially RGBW) data buffer.

3.  **JSON Schema Update (libsrc/leddevice/schemas/schema-e131.json):**
    *   Added a `whiteAlgorithm` property to the E1.31 device schema.
    *   This allows users to select the white channel calibration method ("white_off", "subtractive", "additive").
    *   Includes a default value of "white_off".

**Compilation Status:**

The project successfully configures with CMake after installing numerous dependencies (Qt6, libudev, XCB libs, ALSA, CEC, libp8-platform, libusb).
However, the `make` process consistently times out after approximately 6 minutes and 40 seconds, regardless of the number of parallel jobs (`-j nproc`, `-j 2`, `-j 1`) or if a specific target (`hyperiond`) is built.

This suggests a potential hang or an extremely long compilation step for a particular file/module within the project, which could not be identified due to lack of verbose output during the timeout.

Further investigation or environment adjustments are needed to complete the full build.
   ledRGB(W)Count variable from LedDevice instead of creating a new
   locally
2. Fixed the problem where DMX Max channel count was hardcoded to 512.
   WLED e.g. in MultiRGB mode relies on 510 (3*170) channels. On other
   hand for MultiRGBW it expect 512 (4*128) channels. So obviously it
   has to be a parameter.
3. Updated corresponding configuration for WebUI
The previous implementation used the raw limiting channel value (uScale)
as the white LED drive, which undershot by a factor of sumW/wlim. The
correct drive under the 1/3-efficiency model is fRatio*sumW, capped at
255 with fActualRatio back-calculated for the RGB subtraction.

Also fix div-by-zero on low color temperatures (zero white channel
components), replace non-standard u_int16_t/u_int8_t with uint16_t/
uint8_t, fix invalid default whiteTemp=0 -> 5000, fix _customWhite-
Temperature type int -> uint16_t, and improve readability of
ColorRgb::white().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The 1/3 efficiency assumption (fRatio * sumW) was over-driving the white
channel by up to 2x at 2700K, causing warm white flood that washed out
saturated colors: magenta lost saturation, green shifted yellow, cyan
lost its blue component. Switch to 1:1 (fRatio * 255) which assumes the
white LED matches one RGB channel in per-channel output — a better fit
for typical RGBW strips.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Revert white drive from fRatio*255 back to fRatio*sumW to test whether
the 1/3 efficiency model produces better results now that post-processing
gamma correction is properly configured.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hyperion-project
Copy link
Copy Markdown

Hello @lougovsk 👋

I'm the Hyperion Project Bot and I want to thank you for
contributing to Hyperion with your pull requests!

To help you and other users test your pull requests faster,
I'll create a link for you to your workflow artifacts.

🔗 https://github.com/hyperion-project/hyperion.ng/actions/runs/23771942253

Of course, if you make changes to your PR, I will create a new link.

Best regards,
Hyperion Project

pow/log -> qPow/qLn in ColorRgb::white(), add <QtMath> include.
round -> qRound, std::numeric_limits::infinity() -> qInf() in
RgbToRgbw.cpp, remove <limits> include.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hyperion-project
Copy link
Copy Markdown

Hey @lougovsk I created a new link to your workflow artifacts:
🔗 https://github.com/hyperion-project/hyperion.ng/actions/runs/23801325662

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant