src/bangbang.cpp
float bangbang::update(float input, float setpoint, float target) {
	float error = setpoint - input;
	if (error > 0 && error > this->threshold) {
		return this->max;
	} else if (error > 0 && error <= this->threshold) {
		return this->min;
	} else if (error < 0 && fabs(error) > fabs(this->threshold)) {
		return -this->max;
	} else if (error < 0 && fabs(error) <= fabs(this->threshold)) {
		return -this->min;
	} else {
		return 0;
	}
}
/* When the error is positive and greater than the output threshold, output positive max power
 * however, when the error is less than the threshold, output minimum positive power.
 * The same happens when the error is negative, except the output is now negative.
 * The error is simply the distance from where you are to where you want to be.
 */
When the error is positive and greater than the output threshold, output positive max power
however, when the error is less than the threshold, output minimum positive power.
The same happens when the error is negative, except the output is now negative.
The error is simply the distance from where you are to where you want to be.
When the error is positive and greater than the output threshold output positive max power however when the error is less than the threshold output minimum positive power . The same happens when the error is negative except the output is now negative . The error is simply the distance from where you are to where you want to be .
float bangbang::update(float input, float setpoint, float target) {
	float error = setpoint - input;
	if (error > 0 && error > this->threshold) {
		return this->max;
	} else if (error > 0 && error <= this->threshold) {
		return this->min;
	} else if (error < 0 && fabs(error) > fabs(this->threshold)) {
		return -this->max;
	} else if (error < 0 && fabs(error) <= fabs(this->threshold)) {
		return -this->min;
	} else {
		return 0;
	}
}
float bangbang :: update ( float input , float setpoint , float target ) { float error = setpoint - input ; if ( error > 0 && error > this -> threshold ) { return this -> max ; } else if ( error > 0 && error <= this -> threshold ) { return this -> min ; } else if ( error < 0 && fabs ( error ) > fabs ( this -> threshold ) ) { return - this -> max ; } else if ( error < 0 && fabs ( error ) <= fabs ( this -> threshold ) ) { return - this -> min ; } else { return 0 ; } }
When the error is positive and greater than the output threshold, output positive max power
 however, when the error is less than the threshold, output minimum positive power.
When the error is positive and greater than the output threshold output positive max power however when the error is less than the threshold output minimum positive power .