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:
devdesk
2026-02-05 20:49:59 +02:00
parent 568339367e
commit 241d1ae457
4 changed files with 93 additions and 21 deletions

View File

@@ -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();
}