Clean up setGeometry (for 0.15.x only) - #5474
Conversation
Reorganize setGeometry to perform all checks first before applying the values. This lets us accurately detect changes before starting a transition.
🚥 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. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@wled00/FX_fcn.cpp`:
- Around line 488-490: The stop-path currently flips i2Y < i1Y but only sets i2
= 0, leaving startY/stopY written with the reversed (invalid) Y bounds; update
the code handling the stop case (references: i1Y, i2Y, i2, startY, stopY) to
normalize or clear the Y pair before storing—either swap i1Y/i2Y so startY <=
stopY or set startY/stopY to a safe default (e.g., zeroed) when you set i2 = 0;
apply the same normalization/clearing logic in the other analogous stop branch
around the second occurrence mentioned (lines ~529-530) so future partial
updates don’t reuse reversed bounds.
- Around line 461-472: The sanitisation currently forces i2 to 1, breaking the
inactive/deletion sentinel i2==0 used by
setGeometry(0,0)/Segment::deactivate()/seg.stop logic; change the clamping so
i2==0 is preserved as the inactive path (e.g. if i2 == 0 leave it alone,
otherwise apply the lower-bound clamp that sets i2 to 1 when 0 < i2 < 1), so
modify the block around the i2 clamps in FX_fcn.cpp (the i2/i1 sanitisation
code) to allow i2==0 to pass through unchanged before any final disable checks.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
- Improve early stop check - Remove redundant Y size check
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@wled00/FX_fcn.cpp`:
- Around line 496-501: The preserved ofs (set when ofs == UINT16_MAX) can be >=
the new segment length after shrinking and will cause
setPixelColor()/getPixelColor() to read/write out of bounds; after computing the
final segment bounds (using i1, i2, i1Y, i2Y) and before using ofs, renormalize
it relative to the new segment length: compute segLen = i2 - i1 (or the
appropriate Y-length if using i1Y/i2Y) and if segLen == 0 disable the segment
(as done with i2 = 0), otherwise if ofs >= segLen replace ofs with ofs % segLen
(or clamp to 0) so subsequent calls to setPixelColor()/getPixelColor() wrap
correctly within the new length.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
|
@willmmiles is this PR ready for merging into 0_15 ? |
It works for me, but there's been no human reviews. I think 0_15_x is probably defunct now anyways, I'll make sure it gets ported upstream. |
|
Reorganize setGeometry to perform all checks first before applying the values. This lets us accurately detect if the geometry was, in fact, actually changed before inducing a transition.
This should fix #5427 by not blanking the lights when the segment geometry hasn't actually changed.
Summary by CodeRabbit