Skip to content

Conversation

@DedeHai
Copy link
Collaborator

@DedeHai DedeHai commented Jan 24, 2026

since for smooth transitions the FPS was forced to FRAMETIME anyway and only a handful of FX actually used it there is no reason to keep this logic. With persistent segment buffers a frame can also be sent out multiple times, even if the FX does not render it (which it should for smooth transitions but it is not a requirement anymore)

  • Removed return value from all FX
  • added macro FX_FALLBACK_STATIC { mode_static(); return; }
  • Updated user_fx readme removing the reference to return FRAMETIME; and add FX_FALLBACK_STATIC references
  • fixes speedup by modifying FX to always render but not always update
    • updated mode_chase_flash()
    • updated mode_chase_flash_random()
    • updated mode_colortwinkle(), it still runs at fixed frame of 42FPS
    • udpated candle(), also still runs at fixed frame rate
    • had to almsot fully re-write of ICU FX to a state-based version. I also added a slight modification: it now blinks while paused and not simply at the start of a pause (@Aircoookie please veto if you do not like it)

Additional changes:

  • bugfix in PS to prevent potential crashes: PS could still run on uninitialized SEGMENT.data in some edge cases like calling a 2D PS preset in a 1D setup.

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling and memory cleanup when initializing particle systems in non-matrix contexts.
  • Refactor

    • Standardized effect timing to a fixed frame cadence for more predictable rendering.
    • Simplified Fire particle update flow and unified fallback handling for 2D effects.
    • Updated several effect interfaces to use void-based handlers.
  • Documentation

    • README clarified cadence and frame-timing behavior.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 24, 2026

Warning

Rate limit exceeded

@DedeHai has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 13 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Walkthrough

Effect mode functions and related typedefs changed from returning uint16_t to void, removing per-mode frame-delay returns. Service scheduler now uses a fixed FRAMETIME for next frame scheduling. ParticleSystem2D::updateFire lost the renderonly parameter and now always performs internal updates; 2D/1D init failure paths set error flags and deallocate data. README updated to use FX_FALLBACK_STATIC and clarify cadence notes.

Changes

Cohort / File(s) Summary
Effect mode signatures
usermods/user_fx/user_fx.cpp, wled00/FX.h
Mode functions (mode_static, mode_diffusionfire, others) changed from returning uint16_t to void; mode_ptr typedef and ModeData constructor updated to accept void-returning mode functions; FX_FALLBACK_STATIC macro added/used for static fallback.
Service timing / scheduler
wled00/FX_fcn.cpp
Removed per-mode frameDelay return handling; seg.next_time consistently set to nowUp + FRAMETIME; old-mode transition no longer bounded by mode-returned delay.
Particle system behaviour & error handling
wled00/FXparticleSystem.cpp, wled00/FXparticleSystem.h
ParticleSystem2D::updateFire() signature: removed renderonly; always runs internal update; non-matrix init failures now set errorFlag = ERR_NOT_IMPL, call SEGMENT.deallocateData() and return false.
Documentation / user FX notes
usermods/user_fx/README.md
Replaced early-return mode_static() uses with FX_FALLBACK_STATIC macro and removed some explicit FRAMETIME returns, adding cadence/timing explanatory notes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • netmindz
  • blazoncek
  • softhack007
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Remove FRAMETIME return value from all FX' directly and clearly summarizes the primary change: eliminating FRAMETIME return values from effect functions across the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 88.89% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@usermods/user_fx/README.md`:
- Around line 83-85: The tutorial snippets call mode_static() when a non-2D
setup is detected but do not stop execution, allowing the flow to continue into
2D-specific logic; update the conditional that checks strip.isMatrix and
SEGMENT.is2D() so that after calling mode_static() you immediately return (e.g.,
wrap mode_static() in a block and add return;) and apply the same change to the
other occurrence referenced around the second snippet (the one at 130-132) so
both examples exit early after the fallback.

In `@wled00/FXparticleSystem.h`:
- Line 23: The header currently defines WLED_DEBUG_PS unconditionally which
forces particle-system debug and extra flash into every build; remove the
default `#define` and make WLED_DEBUG_PS opt-in by guarding debug code behind a
build-time macro (e.g., rely on a compile flag such as -DENABLE_WLED_DEBUG_PS or
an existing global debug macro) so that FXparticleSystem.h only enables debug
when that build flag is set; update references to WLED_DEBUG_PS in the file so
they are inside `#ifdef` ENABLE_WLED_DEBUG_PS (or the chosen macro) and document
the new build flag for opt‑in usage.
🧹 Nitpick comments (3)
usermods/user_fx/README.md (1)

253-253: Clarify how to re‑render when skipping state updates.

The new note says to re‑render every frame, but the example still renders only inside the update interval. Consider adding a short hint or snippet showing a “render every call, update conditionally” structure to avoid confusion for readers.

wled00/FXparticleSystem.cpp (2)

1098-1102: Consider nulling PartSys on early exit to avoid dangling pointers.
SEGMENT.deallocateData() invalidates prior PS memory; setting PartSys = nullptr here makes accidental reuse safer.

♻️ Suggested change
   if (!strip.isMatrix) {
     errorFlag = ERR_NOT_IMPL; // TODO: need a better error code if more codes are added
     SEGMENT.deallocateData(); // deallocate any data to make sure data is null (there is no valid PS in data and data can only be checked for null)
+    PartSys = nullptr;
     return false; // only for 2D
   }

1850-1854: Also null PartSys in the 1D early-exit path.
This keeps callers from accidentally using a stale pointer after SEGMENT.deallocateData().

♻️ Suggested change
   if (SEGLEN == 1) {
     errorFlag = ERR_NOT_IMPL; // TODO: need a better error code if more codes are added
     SEGMENT.deallocateData(); // deallocate any data to make sure data is null (there is no valid PS in data and data can only be checked for null)
+    PartSys = nullptr;
     return false; // single pixel not supported
   }

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
usermods/user_fx/README.md (1)

302-309: Update Sinelon example to void-return to match FX changes.
The example still declares uint16_t and later shows return FRAMETIME;, but FX_FALLBACK_STATIC expands to return; and the API is now void. Please align the snippet and its narrative to avoid copy-paste compile errors.

✏️ Proposed doc fix
-static uint16_t sinelon_base(bool dual, bool rainbow=false) {
+static void sinelon_base(bool dual, bool rainbow=false) {
   if (SEGLEN <= 1) FX_FALLBACK_STATIC;
   ...
-  return FRAMETIME;
 }
-uint16_t mode_sinelon(void) {
-  return sinelon_base(false);
-}
+void mode_sinelon(void) {
+  sinelon_base(false);
+}
 
-uint16_t mode_sinelon_dual(void) {
-  return sinelon_base(true);
-}
+void mode_sinelon_dual(void) {
+  sinelon_base(true);
+}
 
-uint16_t mode_sinelon_rainbow(void) {
-  return sinelon_base(false, true);
-}
+void mode_sinelon_rainbow(void) {
+  sinelon_base(false, true);
+}

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@wled00/FXparticleSystem.h`:
- Around line 145-147: The comment for updateFire still mentions the removed
renderonly parameter and should be updated to reflect the new always-update
behavior; modify the comment on the updateFire(const uint8_t intensity)
declaration in FXparticleSystem.h to remove the "if renderonly is set, particles
are not updated" clause and instead state that updateFire always updates
particles (and is used to keep fire behavior consistent across frame skips/
transitions), or simply remove the outdated phrase so the comment matches
current behavior.

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.

1 participant