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)
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

15
temp.c
View File

@ -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