Skip to content

Encapsulate set.cpp's own runtime state as static, not global - #5784

Merged
netmindz merged 1 commit into
wled:mainfrom
netmindz:refactor/setcpp-globals
Aug 8, 2026
Merged

Encapsulate set.cpp's own runtime state as static, not global#5784
netmindz merged 1 commit into
wled:mainfrom
netmindz:refactor/setcpp-globals

Conversation

@netmindz

@netmindz netmindz commented Aug 8, 2026

Copy link
Copy Markdown
Member

Summary

Part of an ongoing pass identifying WLED_GLOBAL declarations that are actually only referenced in one file (see #5777-#5783 for earlier ones). 2 more turned out to be private to set.cpp: presetCycMin, presetCycMax.

Converted both to file-local static, same types and initial values as before.

No behavior change — purely a storage-class change.

Test plan

  • esp32dev: builds and links cleanly via pio run -e esp32dev, no warnings.
  • Confirmed via repo-wide grep (wled00/, usermods/) that neither converted variable is referenced outside set.cpp.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Improved internal handling of preset-cycle limits without changing user-visible behavior.
    • Reduced exposure of implementation details while preserving existing preset-cycle functionality.

2 WLED_GLOBAL variables were referenced only in set.cpp: presetCycMin,
presetCycMax. Converted both to file-local `static`.

No behavior change - purely a storage-class change.

Verified: esp32dev builds and links cleanly via `pio run -e esp32dev`
(no warnings from either changed file).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ecb858bc-91c4-4ef7-b855-7ee95927a6e9

📥 Commits

Reviewing files that changed from the base of the PR and between 0869ef4 and be6e545.

📒 Files selected for processing (2)
  • wled00/set.cpp
  • wled00/wled.h

Walkthrough

The preset-cycle minimum and maximum values are now file-local static variables in set.cpp. Their global declarations were removed from wled.h.

Changes

Preset-cycle state encapsulation

Layer / File(s) Summary
Localize preset-cycle bounds
wled00/set.cpp, wled00/wled.h
set.cpp defines presetCycMin and presetCycMax as static variables initialized to 1 and 5. wled.h no longer declares them globally.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

  • wled/WLED#5777: Encapsulates different file-specific runtime state in hue.cpp.
  • wled/WLED#5778: Replaces implementation-only globals with file-local variables.
  • wled/WLED#5779: Applies the same global-state encapsulation pattern.

Suggested reviewers: dedehai, softhack007

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: making set.cpp runtime state file-local static instead of global.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

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

@netmindz
netmindz merged commit b2ae62a into wled:main Aug 8, 2026
30 checks passed
@netmindz
netmindz deleted the refactor/setcpp-globals branch August 8, 2026 20:58
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.

2 participants