Skip to content

Commit 779ad8c

Browse files
authored
Changed return value for the current tunning stage
Please, check example suggested in the other PR.
1 parent 8b465d4 commit 779ad8c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/QuickPID.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,18 @@ byte AutoTunePID::autoTuneLoop()
367367
case NEW_TUNINGS: // ready to apply tunings
368368
*_output = 0;
369369
_autoTuneStage++;
370-
return NEW_TUNINGS;
370+
//return NEW_TUNINGS;
371371
break;
372+
373+
case RUN_PID: // ready to apply tunings
374+
return RUN_PID;
375+
break;
372376
}
373-
return RUN_PID;
377+
378+
if(_autoTuneStage < 1) // safety measure to avoid overflow of _autoTuneStage variable if its value is 0, which shouldn't happen never. Nonetheless...
379+
return 0
380+
else
381+
return _autoTuneStage - 1;
374382
}
375383

376384
void AutoTunePID::setAutoTuneConstants(float* kp, float* ki, float* kd)

0 commit comments

Comments
 (0)