Arduino-PID-Library
Arduino-PID-Library copied to clipboard
Merged two "ifs" into one
Merged this two ifs:
if(!pOnE) outputSum-= kp * dInput;
if(pOnE) output = kp * error;
else output = 0;
into this one:
if(pOnE) output = kp * error;
else { outputSum -= kp * dInput; output = 0; }
I expect a performance improvement by the if reduction, or am I missing something?
I also separated the derivative computing from the ouputSum merging to add comments to indicate where each parameter is being computed.
Changed this:
/*Compute Rest of PID Output*/
output += outputSum - kd * dInput;
into this:
/*Compute derivative*/
output -= kd * dInput;
/*Merge*/
output += outputSum;
I believe it will compile the same, whether is separated or not. But if you don't like this part I'll remake the PR to remove this.