Skip to content

Encapsulate led.cpp's own runtime state as static, not global - #5779

Open
netmindz wants to merge 1 commit into
wled:mainfrom
netmindz:refactor/ledcpp-globals
Open

Encapsulate led.cpp's own runtime state as static, not global#5779
netmindz wants to merge 1 commit into
wled:mainfrom
netmindz:refactor/ledcpp-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, #5778 for earlier ones). 5 more turned out to be private to led.cpp: briNlT, colNlT, lastNlUpdate, transitionActive, transitionStartTime.

Converted all 5 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 — 1,320,323 bytes flash, no warnings.
  • Confirmed via repo-wide grep (wled00/, usermods/) that none of the 5 converted variables are referenced outside led.cpp.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Improved internal handling of transition and nightlight runtime state.
    • No user-facing behavior or configuration changes.

5 WLED_GLOBAL variables were referenced only in led.cpp: briNlT,
colNlT, lastNlUpdate, transitionActive, transitionStartTime.
Converted all 5 to file-local `static`.

No behavior change - purely a storage-class change.

Verified: esp32dev builds and links cleanly via `pio run -e esp32dev`
(1,320,323 bytes flash, no warnings from either changed file).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UtCyBD91vAYWvBzaMyQSHd
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The change moves transition and nightlight runtime state from wled.h into file-private variables in led.cpp. Transition configuration globals remain declared in wled.h.

Changes

LED runtime state

Layer / File(s) Summary
Private runtime state
wled00/wled.h, wled00/led.cpp
led.cpp now owns file-private transition and nightlight runtime variables. wled.h retains only transition configuration globals and documents the private state.

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

Possibly related PRs

  • wled/WLED#5777: Encapsulates file-specific runtime state by moving globals from wled.h into implementation files.

Suggested labels: minor

Suggested reviewers: dedehai, softhack007

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes converting led.cpp runtime state from global to file-local static variables.

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.

Comment thread wled00/led.cpp
static unsigned long transitionStartTime;
static unsigned long lastNlUpdate;
static byte briNlT = 0; // current nightlight brightness
static byte colNlT[] = { 0, 0, 0, 0 }; // current nightlight color

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this will conflict my PR #5700 but not a big deal.

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