Skip to content

Fix time overflow / timer reset in various FX and random palette handling - #5922

Open
DedeHai wants to merge 2 commits into
wled:mainfrom
DedeHai:millis_overflow_fixes
Open

DedeHai wants to merge 2 commits into
wled:mainfrom
DedeHai:millis_overflow_fixes

Conversation

@DedeHai

@DedeHai DedeHai commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

as discovered in #5906 there were a few places where millis() rollover or strip.now resets could cause stalls.

Summary by CodeRabbit

  • Bug Fixes
    • Improved timing reliability across multiple lighting effects, including scanners, flash effects, spaceships, bees, and other animated modes.
    • Prevented animation timing issues when the device’s internal clock wraps around or contains outdated timing information.
    • Improved random color palette transitions for smoother blending and more consistent completion.
    • Refined color-change timing in Floating Blobs and related effects for more predictable visual behavior.

@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

Multiple effects now use elapsed-time or remaining-time calculations for timer checks. Random-palette generation and blending also use wrap-safe elapsed-time calculations, with an updated timestamp field.

Changes

Effect and Palette Timing

Layer / File(s) Summary
Single-effect timer updates
wled00/FX.cpp
Android, Chase Flash, Larson Scanner, Halloween Eyes, Tetrix, Hourglass, and Springy use updated elapsed-time or remaining-time checks.
2D effect timer updates
wled00/FX.cpp
Spaceships, Crazy Bees, Ghost Rider, and Floating Blobs use elapsed-time checks for updates, direction changes, or color changes.
Random-palette blending timing
wled00/FX.h, wled00/FX_fcn.cpp
The palette timestamp field is renamed. Palette generation and blending use 16-bit elapsed-time calculations, and the Segment size documentation and field order are updated.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: softhack007

Merge Risk: 🔵 Low · up to ab4e9

The scanner may pause briefly at clock rollover, and palette blending may remain incomplete after a long update gap. These bounded issues merit fixes or explicit acceptance before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed 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 clearly and concisely describes the main changes: fixing time overflow, timer resets, and random palette handling across multiple effects.
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.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

coderabbitai[bot]

This comment was marked as resolved.

@softhack007
softhack007 self-requested a review October 22, 2026 18:05
@softhack007

Copy link
Copy Markdown
Member

@coderabbitai does this PR overlap with changes in #5908 ?

@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
for pr in 5908 5922; do
  echo "=== PR $pr metadata ==="
  gh api "repos/wled/WLED/pulls/$pr" --jq '{number,title,state,merged,base:.base.ref,head:.head.sha,body,html_url}'
  echo "=== PR $pr files and patches ==="
  gh api --paginate "repos/wled/WLED/pulls/$pr/files?per_page=100" --jq '.[] | {filename,status,additions,deletions,patch}'
done

Length of output: 34898


@softhack007 Yes. The current diffs overlap in two timing fixes in wled00/FX.cpp.

Function Shared change Difference
mode_2Dcrazybees() Both replace the absolute deadline with an elapsed-time check and set SEGENV.step = strip.now after an update. #5908 also initializes SEGENV.step = unsigned(strip.now - 1024) for an immediate first redraw. It also widens bee coordinates and increases MAX_BEES to 8.
mode_2Dghostrider() Both use the same elapsed-time approach. #5908 also initializes the timestamp for an immediate redraw and clamps the interval with max(2, 1024 / (cols+rows)). #5922 does not include that clamp.

The remaining changes are separate:

  • #5922 fixes timing in other effects and changes random-palette handling in wled00/FX.h and wled00/FX_fcn.cpp.
  • #5908 fixes large-panel rendering and adds lerp16by8() to fastled_slim.h.

Recommendation: When reconciling the two PRs, retain #5908’s versions of the two shared timing blocks, including their initialization and Ghost Rider interval clamp. Keep #5922’s other timing and palette changes. Neither PR replaces the other.

This comparison uses both PRs’ current patches. I have not tested whether Git can merge them without conflicts.

You are interacting with an AI system.

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