Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 23, 2025

Fix gamma correction not enabled on fresh install

  • Understand the issue: gammaCorrectCol initialized as true but gets overwritten to false on fresh install
  • Analyze config loading code in cfg.cpp
  • Fix the config loading to use proper defaults when config file doesn't exist
    • Added default value using gammaCorrectVal for light_gc_col (matches gammaCorrectCol = true default)
    • Added default value 1.0f for light_gc_bri (matches gammaCorrectBri = false default)
  • Test the fix to ensure gamma correction is enabled on fresh install
  • Run build and test suite to validate changes
    • npm test - All 16 tests passed ✓
    • pio run -e esp32dev - Build successful ✓
  • Code review completed - No issues found ✓
  • Security scan completed - No vulnerabilities ✓
  • Address PR feedback
    • Use gammaCorrectVal instead of hardcoded 2.2f for better maintainability ✓
    • Remove _codeql_detected_source_root file ✓
    • Revert changes to .gitignore

Summary:
Fixed the gamma correction initialization bug by adding proper default values in the configuration loading code. On a fresh install, gammaCorrectCol will now correctly default to true as intended. Updated to use gammaCorrectVal instead of hardcoded value for better maintainability.

Original prompt

This section details on the original issue you should resolve

<issue_title>"Use Gamma correction for color" not enabled on fresh install</issue_title>
<issue_description>### What happened?

on fresh installs, color gamma correction is not enabled, even though the variable gammaCorrectCol is initialized as true.

To Reproduce Bug

Expected Behavior

Should be enabled on a fresh install.

Install Method

Self-Compiled

What version of WLED?

0.16

Which microcontroller/board are you seeing the problem on?

ESP32

Relevant log/trace output

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct</issue_description>

<agent_instructions>please check the first-boot logic when no config file exists and determine why the init value is not used.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed gamma correction default handling to improve color accuracy and brightness control in lighting output.
    • Enhanced gamma correction flag behavior to ensure consistent and proper lighting performance across different configuration scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

The PR modifies gamma correction default handling in wled00/cfg.cpp, changing how missing JSON fields for brightness and color default values are processed. It adds explicit logic to toggle the gammaCorrectCol flag based on computed light_gc_col validation, addressing fresh installation configuration issues.

Changes

Cohort / File(s) Summary
Gamma Correction Defaults
wled00/cfg.cpp
Modified JSON field defaulting for gamma-corrected brightness (bri defaults to 1.0f) and color (col defaults to gammaCorrectVal); added explicit else branch to set gammaCorrectCol to false when light_gc_col is not > 1.0f

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • blazoncek

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix gamma correction for color not enabled on fresh install' directly and clearly summarizes the primary change—fixing the initialization issue where color gamma correction wasn't enabled on fresh installs.
Linked Issues check ✅ Passed The code changes in cfg.cpp properly address the linked issue #5224 by providing correct defaults (gammaCorrectVal for light_gc_col, 1.0f for light_gc_bri) when config files don't exist, ensuring color gamma correction is enabled on fresh installs.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing gamma correction initialization defaults in cfg.cpp; no unrelated modifications to other systems or features were introduced.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI changed the title [WIP] Fix gamma correction not enabled on fresh install Fix gamma correction for color not enabled on fresh install Dec 23, 2025
Copilot AI requested a review from DedeHai December 23, 2025 10:31
wled00/cfg.cpp Outdated
float light_gc_bri = light["gc"]["bri"];
float light_gc_col = light["gc"]["col"];
float light_gc_bri = light["gc"]["bri"] | 1.0f; // default to 1.0 (false)
float light_gc_col = light["gc"]["col"] | 2.2f; // default to 2.2 (true)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not initialize to gammaCorrectVal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! Changed to use gammaCorrectVal instead of hardcoded 2.2f for better maintainability. Fixed in b68a9e0.

@@ -0,0 +1 @@
. No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

File removed and added to .gitignore to prevent it from being committed again. Fixed in b68a9e0.

@DedeHai
Copy link
Collaborator

DedeHai commented Dec 23, 2025

@copilot please address comments

Copy link
Contributor Author

Copilot AI commented Dec 23, 2025

@copilot please address comments

Both comments have been addressed in commit b68a9e0:

  1. Line 510 now uses gammaCorrectVal instead of hardcoded 2.2f
  2. _codeql_detected_source_root file removed and added to .gitignore

.gitignore Outdated
/wled00/html_*.h

# CodeQL
_codeql_detected_source_root
Copy link
Collaborator

Choose a reason for hiding this comment

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

revert changes to itignore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted in 48fab36.

@DedeHai
Copy link
Collaborator

DedeHai commented Dec 23, 2025

@copilot revert changes to itignore

Copy link
Contributor Author

Copilot AI commented Dec 23, 2025

@copilot revert changes to itignore

Changes to .gitignore reverted in 48fab36.

Copilot AI requested a review from DedeHai December 23, 2025 13:02
@DedeHai
Copy link
Collaborator

DedeHai commented Dec 28, 2025

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 28, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@DedeHai DedeHai marked this pull request as ready for review December 28, 2025 09:17
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.

"Use Gamma correction for color" not enabled on fresh install

2 participants