improve bootup behaviour for boot presets#5686
Conversation
Walkthrough
ChangesBoot-up LED color initialization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Tools execution failed with the following error: Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error) 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 |
|
@coderabbitai please check for any edge cases that may have a changed behaviour and come up with a test plan to verify this PR works as intended. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Get the PR diff
gh pr diff 5686 --repo wled/WLED
echo "===== wled.cpp segment ====="
gh api repos/wled/WLED/contents/wled00/wled.cpp?ref=refs/pull/5686/head --jq '.content' | base64 -d | grep -n "bootPreset\|turnOnAtBoot\|briS\|colPri\|transitionDelay\|beginStrip\|BLACK\|DEFAULT_COLOR\|bootTime\|CALL_MODE_INIT" -A2 -B2
echo "===== FX.h segment ====="
gh api repos/wled/WLED/contents/wled00/FX.h?ref=refs/pull/5686/head --jq '.content' | base64 -d | grep -n "DEFAULT_COLOR\|bootTime\|bootupDelay\|colors\[0\]\|BLACK\|WLED_BOOTUPDELAY" -A5 -B2
echo "===== wled.h colPri ====="
gh api repos/wled/WLED/contents/wled00/wled.h?ref=refs/pull/5686/head --jq '.content' | base64 -d | grep -n "colPri\|colSec" -A2 -B2Length of output: 11599 🏁 Script executed: #!/bin/bash
# Get full beginStrip function from PR branch
gh api repos/wled/WLED/contents/wled00/wled.cpp?ref=refs/pull/5686/head --jq '.content' | base64 -d | grep -n "beginStrip\|void WLED::begin" -A 80 | head -120
echo "=====FX.h Segment constructor====="
gh api repos/wled/WLED/contents/wled00/FX.h?ref=refs/pull/5686/head --jq '.content' | base64 -d | grep -n "Segment()\|Segment ::\|bootTime\|bootupDelay\|colors\[0\]" -A 10 -B 5 | head -80Length of output: 9859
Edge Case AnalysisEC-1:
|
| # | turnOnAtBoot |
bootPreset |
rlyPin |
transitionDelayDefault |
Notes |
|---|---|---|---|---|---|
| T-1 | false | 0 | none | 700ms (default) | Baseline: all off at boot |
| T-2 | true | 0 | none | 700ms | LEDs on at briS, fade from black |
| T-3 | true | 0 | none | 0 | Instant on, no fade |
| T-4 | false | N (valid preset) | none | 700ms | Preset applied, LEDs may be off |
| T-5 | true | N (valid preset) | none | 700ms | LEDs on + preset fades in from black |
| T-6 | true | N (valid preset) | none | 0 | Instant preset, no fade |
| T-7 | true | 0 | configured | 700ms | Relay controls on/off, then fade |
| T-8 | false | N | configured | 700ms | Relay stays off, preset applied silently |
| T-9 | true | N (playlist preset) | none | 700ms | Playlist boot preset |
| T-10 | true | 0 | none | 700ms | briS = 0 (first install fallback) |
Test Cases
T-1: All Off at Boot
- Set
turnOnAtBoot = false,bootPreset = 0. - Power cycle.
- Expected: All LEDs remain off. No flicker on first frame.
- Check:
bri = 0, no relay command issued, strip dark.
T-2: Turn-On Fade from Black
- Set
turnOnAtBoot = true,bootPreset = 0, default orange color saved,transitionDelayDefault = 700ms. - Power cycle.
- Expected: LEDs fade from black to
briSbrightness in orange over ~700ms. - Check: No flash of orange before fade starts; brightness reaches
briSexactly.
T-3: Instant Turn-On (No Fade)
- Set
turnOnAtBoot = true,bootPreset = 0,transitionDelayDefault = 0. - Power cycle.
- Expected: LEDs turn on instantly at
briS, no fade transition. - Check: No visible ramp-up from zero.
T-4: Boot Preset Only (LEDs Stay Off?)
- Set
turnOnAtBoot = false,bootPreset = N(preset with explicit brightness embedded). - Power cycle.
- Expected (verify): Does the preset turn on the LEDs if it has a
brifield? Or do LEDs stay off becausebri = 0? - Check:
brivalue after boot; compare with and without brightness saved in the preset.
T-5: Turn-On + Boot Preset Fade
- Set
turnOnAtBoot = true,bootPreset = N,transitionDelayDefault = 700ms. - Power cycle.
- Expected: LEDs start black, fade to the preset's colors at
briSbrightness over 700ms. - Check: No orange flash before fade; all segment channels (col0, col1, col2) fade correctly;
briSis respected vs. preset brightness.
T-6: Turn-On + Boot Preset Instant (No Fade)
- Set
turnOnAtBoot = true,bootPreset = N,transitionDelayDefault = 0. - Power cycle.
- Expected: Preset applied immediately at
briSwith no fade. - Check: Same as T-5 but instantaneous.
T-7: Relay + Turn-On + Boot Preset
- Configure relay pin, set
turnOnAtBoot = true,bootPreset = N. - Power cycle.
- Expected: Relay fires, LEDs turn on after relay delay, preset fades in.
- Check:
strip.show()is NOT called before relay activates; no premature LED output.
T-8: Power Toggle After Boot (briLast regression)
- Any configuration.
- Power cycle, wait for boot to complete.
- Toggle LEDs off via button or API.
- Toggle LEDs back on.
- Expected: LEDs restore to the expected brightness (
briSor preset brightness). - Check: Confirm
briLastholds the correct value—not0—after boot.
T-9: Boot Playlist Preset
- Set
bootPreset = Nwhere N is a playlist preset. - Power cycle.
- Expected: Playlist starts, advances entries correctly, no duplicate first-entry playback.
- Check: Playlist timing is correct; first entry isn't played twice.
T-10: First-Install (briS = 0)
- Factory reset (or manually set
briS = 0in config). - Set
turnOnAtBoot = true. - Power cycle.
- Expected: LEDs turn on at brightness 128 (fallback).
- Check: Not dark; confirms
bri = briS ? briS : 128fallback works.
T-11: New Segment Within 5-Second Boot Window
- Power cycle, immediately (< 5 seconds) go to the segment editor and add a new segment.
- Expected: New segment starts black instead of orange.
- Check (UX regression): Does the user see unexpected black? Is this behavior acceptable? After 5 seconds, verify new segments correctly start in orange.
T-12: Multi-Segment Boot Preset
- Configure a preset that defines 3+ segments with different colors.
- Set
bootPreset = N,turnOnAtBoot = true. - Power cycle.
- Expected: All active segments fade from black to their respective preset colors. Inactive segments remain black/off.
- Check:
colors[1]andcolors[2]also transition correctly (not justcolors[0]).
T-13: Non-Fade Transition Mode
- Set the transition mode to a non-fade type (e.g., Wipe),
bootPreset = N,turnOnAtBoot = true. - Power cycle.
- Expected: Per PR description, LEDs start at default brightness immediately without fading from black.
- Check: No black-to-color animation; LEDs snap to preset state.
T-14: WLED_BOOTUPDELAY Defined
- Compile with
WLED_BOOTUPDELAY = 10000(10s). - Power cycle; wait 8 seconds, add a segment.
- Expected: Segment still starts black (within 15s window).
- Wait 16 seconds, add another segment.
- Expected: Segment starts in orange (outside window).
The most critical cases to verify first are EC-3 (transition not restored for boot preset path, affecting whether fade-in actually occurs), EC-4 (briLast not set, affecting power toggle), and EC-2 (whether bri stays 0 when turnOnAtBoot = false + bootPreset > 0 renders the preset invisible until handlePresets() in setup()).
|
I tested all the suggested cases and made some improvements. this is how it works now, copy from source code comment for reference:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@wled00/wled.cpp`:
- Line 624: Fix the typo in the comment on line 624 where "booup" is misspelled.
Change "booup" to "bootup" in the comment that starts with "if a booup preset is
set" to correctly read "if a bootup preset is set".
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3ae61826-11cf-47e0-bd66-338208522b86
📒 Files selected for processing (1)
wled00/wled.cpp
| // if turnOnAtBoot is false, strip is set to black. It will fade in to startup brightness and orange when turned on | ||
| // if a bootup preset is set, it will fade to that preset if it has on:true set (to default brightness) or to that preset's brightness if set | ||
| // if turnOnAtBoot is true the LEDs will fade in to orange and default brightness | ||
| // if a booup preset is set, it will start at the default brightness except if "fade" transition is used, then it will still fade from black |
There was a problem hiding this comment.
Typo: "booup" should be "bootup".
📝 Proposed fix
- // if a booup preset is set, it will start at the default brightness except if "fade" transition is used, then it will still fade from black
+ // if a bootup preset is set, it will start at the default brightness except if "fade" transition is used, then it will still fade from black📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // if a booup preset is set, it will start at the default brightness except if "fade" transition is used, then it will still fade from black | |
| // if a bootup preset is set, it will start at the default brightness except if "fade" transition is used, then it will still fade from black |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@wled00/wled.cpp` at line 624, Fix the typo in the comment on line 624 where
"booup" is misspelled. Change "booup" to "bootup" in the comment that starts
with "if a booup preset is set" to correctly read "if a bootup preset is set".
changes made:
full refactor of the bootup behaviour regarding "bootup preset" and "turn on at boot" here is how it works now:
Segments created by a bootup presets no longer use the DEFAULT_COLOR but start out black: segments created within the first 5s after bootup default to black
DEFAULT_COLOR used for new segments is now the same as the bootup color (AA which is 170 changed to A0 which is 160)
TLDR;
no matter if "turn on at boot" is now set or not, boot up presets are applied correctly. If "turn on at boot" is set, LEDs always turn on.
Summary by CodeRabbit
Summary by CodeRabbit