Change check for out of bounds setpoints.
Makes more sense this way, and is compatible with more boards. ESP32 chips don't seem to like min/max with mixed types.
This commit is contained in:
parent
ff8129f400
commit
0e74d66125
@ -45,6 +45,7 @@ char* KettleState() {
|
|||||||
case OFF: return (char*)"OFF";
|
case OFF: return (char*)"OFF";
|
||||||
case AUTOMATIC: return (char*)"AUT";
|
case AUTOMATIC: return (char*)"AUT";
|
||||||
case MANUAL: return (char*)"MAN";
|
case MANUAL: return (char*)"MAN";
|
||||||
|
default: return (char*)"OFF";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,8 +89,8 @@ void doEncoder() {
|
|||||||
KettleSetpoint = (KettleSetpoint / inc) * inc - inc;
|
KettleSetpoint = (KettleSetpoint / inc) * inc - inc;
|
||||||
}
|
}
|
||||||
|
|
||||||
KettleSetpoint = max(KettleSetpoint,0);
|
if (KettleSetpoint > 212) KettleSetpoint=212;
|
||||||
KettleSetpoint = min(KettleSetpoint,212);
|
if (KettleSetpoint < 0) KettleSetpoint=0;
|
||||||
|
|
||||||
} else if (Controller.Mode() == MANUAL) {
|
} else if (Controller.Mode() == MANUAL) {
|
||||||
if (result == DIR_CW) {
|
if (result == DIR_CW) {
|
||||||
@ -98,8 +99,8 @@ void doEncoder() {
|
|||||||
KettleDuty = (KettleDuty / inc) * inc - inc;
|
KettleDuty = (KettleDuty / inc) * inc - inc;
|
||||||
}
|
}
|
||||||
|
|
||||||
KettleDuty = max(KettleDuty,0);
|
if (KettleDuty > 100) KettleDuty = 100;
|
||||||
KettleDuty = min(KettleDuty,100);
|
if (KettleDuty < 0) KettleDuty = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
//menu.update();
|
//menu.update();
|
||||||
|
@ -28,8 +28,8 @@ bool thermoControl::Compute() {
|
|||||||
*output_pwm = outMax;
|
*output_pwm = outMax;
|
||||||
} else if (error > hysteresis) {
|
} else if (error > hysteresis) {
|
||||||
*output_pwm = 100 * error / max_pwr_threshold;
|
*output_pwm = 100 * error / max_pwr_threshold;
|
||||||
*output_pwm = max(*output_pwm, outMin);
|
if (*output_pwm > 100) *output_pwm = 100;
|
||||||
*output_pwm = min(*output_pwm, outMax);
|
if (*output_pwm < 0) *output_pwm = 0;
|
||||||
} else {
|
} else {
|
||||||
*output_pwm = 0;
|
*output_pwm = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user