Fix orientation detection static variable reset bug in calibration#515
Fix orientation detection static variable reset bug in calibration#515Copilot wants to merge 2 commits intoMaslow-Mainfrom
Conversation
- Reorder timer initialization check before settlingCompleted check to ensure static variables are reset properly when calibration restarts - Move settlingStartTime static variable to function scope for proper reset - Add documentation comments explaining reset mechanism Co-authored-by: BarbourSmith <9359447+BarbourSmith@users.noreply.github.com>
|
@copilot Can you explain to me why |
So it's never "leftover" from a previous run - the code explicitly sets it to 0 before each calibration begins. This is why my fix works: when the next calibration starts and |
The orientation detection process failed to run on subsequent calibration attempts due to a static variable order-of-operations bug. The
settlingCompletedflag was checked before the timer initialization logic could reset it.Changes
detectOrientation(): Timer check and static variable reset now occurs before the early return checksettlingStartTimeto function scope: Ensures proper reset alongside other static variablesorientationDetectTimer == 0and static variable resetTechnical Detail
Before:
After:
When
resetCalibrationState()setsorientationDetectTimer = 0, the next call todetectOrientation()now properly resets all static state before checking exit conditions.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.