-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Remove gamma value lower limit to enable inverse gamma correction #5187
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughExpand the acceptable range for gamma correction values by lowering the minimum threshold from 1.0 to 0.1 across validation logic and UI input constraints, allowing values in the range [0.1, 3] instead of [1.0, 3]. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Repository UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Did you check both gamma functions create correct tables for the new range? |
|
I checked the functions, they do work still. |
wled00/cfg.cpp
Outdated
| CJSON(gammaCorrectVal, light["gc"]["val"]); // default 2.2 | ||
| float light_gc_bri = light["gc"]["bri"]; | ||
| float light_gc_col = light["gc"]["col"]; | ||
| if (light_gc_bri > 1.0f) gammaCorrectBri = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update this
Allow gamma values from 0.1 to 3.0 instead of restricting to > 1.0. This enables inverse gamma curves for use cases requiring brightened mid-tones and compressed highlights. Changes: - Update backend validation in set.cpp and cfg.cpp to accept 0.1-3.0 - Update HTML form min value from 1 to 0.1 The calcGammaTable() function already supports any gamma value mathematically, so this just removes an artificial restriction.
eeb5144 to
9d55b18
Compare
|
I think I have it figured out - updated lines 511 and 513 to check != 1.0f instead of > 1.0f so gamma correction is enabled for any non-linear value (both below and above 1.0). This should fix the persistence issue after reboot. |
Summary
Remove the artificial restriction that prevents gamma values below 1.0, enabling inverse gamma correction.
Motivation
LEDs can appear too dark at low brightness levels. Inverse gamma correction (gamma < 1.0) is needed to brighten the lower end of the brightness curve and make dimmed LEDs more visible.
Currently, gamma values are restricted to > 1.0, which only allows standard gamma correction. This PR removes that limitation.
Changes
set.cppandcfg.cppto allow gamma range 0.1-3.0 (was 1.0-3.0)settings_leds.htmto match (min="0.1")Technical Details
The
NeoGammaWLEDMethod::calcGammaTable()function already supports any gamma value mathematically. This PR simply removes an artificial restriction that prevented values < 1.0.Testing
Tested on v0.15.3 and latest main - inverse gamma values (< 1.0) now work correctly and improve visibility at low brightness levels.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.