Dont wrap negative deltas

This commit is contained in:
Ben V. Brown
2022-02-05 09:59:45 +11:00
parent 4f2179287e
commit c38dfb6007
2 changed files with 5 additions and 5 deletions

View File

@@ -148,12 +148,12 @@ void detectThermalRunaway(const int16_t currentTipTempInC, const int tError) {
// Check for thermal runaway, where it has been x seconds with negligible (y) temp rise
// While trying to actively heat
// If we are more than 20C below the setpoint
if ((tError > THERMAL_RUNAWAY_TEMP_C)) {
// Temp error is high
// If we have heated up by more than 20C since last sample point, snapshot time and tip temp
int16_t delta = (int16_t)currentTipTempInC - (int16_t)tipTempCRunawayTemp;
if (delta < 0) {
delta = -delta;
}
if (delta > THERMAL_RUNAWAY_TEMP_C) {
// We have heated up more than the threshold, reset the timer
tipTempCRunawayTemp = currentTipTempInC;