Fix stall oscillation loop in pingpong mode
When pingpong detected a stall and switched direction, only _stalled and _stallStartTime were reset, leaving _stallCandidateCount and _motorStartTime unchanged. This caused motor inrush current after direction change to immediately trigger another stall, creating an infinite oscillation loop. Now calls resetStallDetection() which properly resets all stall state including triggering the STALL_STABILIZE_MS grace period to ignore inrush current.
This commit is contained in:
@@ -34,7 +34,13 @@ void setupWiFi() {
|
||||
}
|
||||
|
||||
// Stall protection callback - stops motor immediately when stall detected
|
||||
// (unless pingpong with stallReturn is active - it handles stall by switching direction)
|
||||
void onMotorStall(float current) {
|
||||
if (motor.isPingpongActive() && motor.getPingpongStallReturn()) {
|
||||
// Pingpong will handle stall by switching direction
|
||||
Serial.printf("STALL DETECTED: Pingpong will switch direction (current: %.2fA)\n", current);
|
||||
return;
|
||||
}
|
||||
Serial.printf("STALL PROTECTION: Stopping motor (current: %.2fA)\n", current);
|
||||
motor.stop();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user