fix(switches): widen fsPreviousState to 32-bit to fix toggle detection for more than 16 switches - #7560
Conversation
…s T22 SW5/SW6 toggling)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe switch previous-state bitset is widened from 16-bit to 32-bit storage. Indexed lookup and state toggling use 32-bit-compatible operations, with tests covering single toggles while switches remain held. ChangesSwitch State Tracking
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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: 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 `@radio/src/switches.cpp`:
- Line 95: Update the widened bitset mutation near fsPreviousState to construct
the mask from uint32_t before shifting, replacing the signed 1 << i expression
so bit index 31 is handled safely.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 32d3fa60-309e-4347-aa80-dec0bc8c5123
📒 Files selected for processing (1)
radio/src/switches.cpp
Verifies that holding a custom switch does not generate phantom toggle events. Fails on the pre-fix code for T22 SW5/SW6 (switch indices 16/17), where fsPreviousState was truncated to 16 bits. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Thanks for catching this. Also added a unit test that would have caught this if it had been there at the time, which will protect against future regressions. |
…n for more than 16 switches (#7560) Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
The
fsPreviousStatevariable was declared asuint16_t, which only supports up to 16 switches. On radios with more than 16 switches (like the T22), switches beyond the 16th (SW5/SW6) would have their states lost or incorrectly tracked.This change:
fsPreviousStatefromuint16_ttouint32_tto support more switchesgetFSPreviousPhysicalState()using a direct shift-and-mask patternSummary by CodeRabbit