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.
This commit is contained in:
Markus Amsler 2011-03-25 19:24:04 +01:00 committed by Michael Moon
parent 3a271ee487
commit 9860d2850f
2 changed files with 18 additions and 12 deletions

View File

@ -304,12 +304,15 @@ void temp_set(temp_sensor_t index, uint16_t temperature) {
if (index >= NUM_TEMP_SENSORS) if (index >= NUM_TEMP_SENSORS)
return; return;
temp_sensors_runtime[index].target_temp = temperature; // only reset residency if temp really changed
temp_sensors_runtime[index].temp_residency = 0; if (temp_sensors_runtime[index].target_temp != temperature) {
#ifdef TEMP_INTERCOM temp_sensors_runtime[index].target_temp = temperature;
if (temp_sensors[index].temp_type == TT_INTERCOM) temp_sensors_runtime[index].temp_residency = 0;
send_temperature(temp_sensors[index].temp_pin, temperature); #ifdef TEMP_INTERCOM
#endif if (temp_sensors[index].temp_type == TT_INTERCOM)
send_temperature(temp_sensors[index].temp_pin, temperature);
#endif
}
} }
/// return most recent reading for a sensor /// return most recent reading for a sensor

15
temp.c
View File

@ -304,12 +304,15 @@ void temp_set(temp_sensor_t index, uint16_t temperature) {
if (index >= NUM_TEMP_SENSORS) if (index >= NUM_TEMP_SENSORS)
return; return;
temp_sensors_runtime[index].target_temp = temperature; // only reset residency if temp really changed
temp_sensors_runtime[index].temp_residency = 0; if (temp_sensors_runtime[index].target_temp != temperature) {
#ifdef TEMP_INTERCOM temp_sensors_runtime[index].target_temp = temperature;
if (temp_sensors[index].temp_type == TT_INTERCOM) temp_sensors_runtime[index].temp_residency = 0;
send_temperature(temp_sensors[index].temp_pin, temperature); #ifdef TEMP_INTERCOM
#endif if (temp_sensors[index].temp_type == TT_INTERCOM)
send_temperature(temp_sensors[index].temp_pin, temperature);
#endif
}
} }
/// return most recent reading for a sensor /// return most recent reading for a sensor