From 9860d2850fe86d23f84ec028d2bfda9f5600aef3 Mon Sep 17 00:00:00 2001 From: Markus Amsler Date: Fri, 25 Mar 2011 19:24:04 +0100 Subject: [PATCH] heater: only reset residency if temp really changed Skeinforge generates sometimes multiple calls to M104/M140, which would add a slow delay on the next M101. --- extruder/temp.c | 15 +++++++++------ temp.c | 15 +++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/extruder/temp.c b/extruder/temp.c index 4c25958..ef9d286 100644 --- a/extruder/temp.c +++ b/extruder/temp.c @@ -304,12 +304,15 @@ void temp_set(temp_sensor_t index, uint16_t temperature) { if (index >= NUM_TEMP_SENSORS) return; - temp_sensors_runtime[index].target_temp = temperature; - temp_sensors_runtime[index].temp_residency = 0; -#ifdef TEMP_INTERCOM - if (temp_sensors[index].temp_type == TT_INTERCOM) - send_temperature(temp_sensors[index].temp_pin, temperature); -#endif + // only reset residency if temp really changed + if (temp_sensors_runtime[index].target_temp != temperature) { + temp_sensors_runtime[index].target_temp = temperature; + temp_sensors_runtime[index].temp_residency = 0; + #ifdef TEMP_INTERCOM + if (temp_sensors[index].temp_type == TT_INTERCOM) + send_temperature(temp_sensors[index].temp_pin, temperature); + #endif + } } /// return most recent reading for a sensor diff --git a/temp.c b/temp.c index 741427a..44f89ee 100644 --- a/temp.c +++ b/temp.c @@ -304,12 +304,15 @@ void temp_set(temp_sensor_t index, uint16_t temperature) { if (index >= NUM_TEMP_SENSORS) return; - temp_sensors_runtime[index].target_temp = temperature; - temp_sensors_runtime[index].temp_residency = 0; -#ifdef TEMP_INTERCOM - if (temp_sensors[index].temp_type == TT_INTERCOM) - send_temperature(temp_sensors[index].temp_pin, temperature); -#endif + // only reset residency if temp really changed + if (temp_sensors_runtime[index].target_temp != temperature) { + temp_sensors_runtime[index].target_temp = temperature; + temp_sensors_runtime[index].temp_residency = 0; + #ifdef TEMP_INTERCOM + if (temp_sensors[index].temp_type == TT_INTERCOM) + send_temperature(temp_sensors[index].temp_pin, temperature); + #endif + } } /// return most recent reading for a sensor