diff --git a/extruder/heater.c b/extruder/heater.c index 0e65503..cb86f56 100644 --- a/extruder/heater.c +++ b/extruder/heater.c @@ -269,7 +269,7 @@ void heater_tick(heater_t h, temp_sensor_t t, uint16_t current_temp, uint16_t ta } // compare where we're at to where we should be - if (labs(current_temp - heaters_runtime[h].sane_temperature) > TEMP_HYSTERESIS) { + if (labs((int16_t)(current_temp - heaters_runtime[h].sane_temperature)) > TEMP_HYSTERESIS) { // no change, or change in wrong direction for a long time- heater is broken! pid_output = 0; sersendf_P(PSTR("!! heater %d or temp sensor %d broken- temp is %d.%dC, target is %d.%dC, didn't reach %d.%dC in %d0 milliseconds\n"), h, t, current_temp >> 2, (current_temp & 3) * 25, target_temp >> 2, (target_temp & 3) * 25, heaters_runtime[h].sane_temperature >> 2, (heaters_runtime[h].sane_temperature & 3) * 25, heaters_runtime[h].sanity_counter); diff --git a/extruder/temp.c b/extruder/temp.c index ef9d286..9e93f28 100644 --- a/extruder/temp.c +++ b/extruder/temp.c @@ -269,7 +269,7 @@ void temp_sensor_tick() { } temp_sensors_runtime[i].last_read_temp = temp; - if (labs(temp - temp_sensors_runtime[i].target_temp) < TEMP_HYSTERESIS) { + if (labs((int16_t)(temp - temp_sensors_runtime[i].target_temp)) < TEMP_HYSTERESIS) { if (temp_sensors_runtime[i].temp_residency < TEMP_RESIDENCY_TIME) temp_sensors_runtime[i].temp_residency++; } diff --git a/heater.c b/heater.c index 5113ddb..3faec61 100644 --- a/heater.c +++ b/heater.c @@ -269,7 +269,7 @@ void heater_tick(heater_t h, temp_sensor_t t, uint16_t current_temp, uint16_t ta } // compare where we're at to where we should be - if (labs(current_temp - heaters_runtime[h].sane_temperature) > TEMP_HYSTERESIS) { + if (labs((int16_t)(current_temp - heaters_runtime[h].sane_temperature)) > TEMP_HYSTERESIS) { // no change, or change in wrong direction for a long time- heater is broken! pid_output = 0; sersendf_P(PSTR("!! heater %d or temp sensor %d broken- temp is %d.%dC, target is %d.%dC, didn't reach %d.%dC in %d0 milliseconds\n"), h, t, current_temp >> 2, (current_temp & 3) * 25, target_temp >> 2, (target_temp & 3) * 25, heaters_runtime[h].sane_temperature >> 2, (heaters_runtime[h].sane_temperature & 3) * 25, heaters_runtime[h].sanity_counter); diff --git a/temp.c b/temp.c index 44f89ee..5d0095b 100644 --- a/temp.c +++ b/temp.c @@ -269,7 +269,7 @@ void temp_sensor_tick() { } temp_sensors_runtime[i].last_read_temp = temp; - if (labs(temp - temp_sensors_runtime[i].target_temp) < TEMP_HYSTERESIS) { + if (labs((int16_t)(temp - temp_sensors_runtime[i].target_temp)) < TEMP_HYSTERESIS) { if (temp_sensors_runtime[i].temp_residency < TEMP_RESIDENCY_TIME) temp_sensors_runtime[i].temp_residency++; }