Skip to content

Commit 98cef95

Browse files
authored
Merge pull request br3ttb#7 from gnalbandian/patch-1
Changed return value for the current tunning stage
2 parents 0fbd0da + 779ad8c commit 98cef95

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)