Temp: have residency updates on 1s clock.
Temperature residency time / temperature achieved check is in the order of seconds, while updates for residency time were being called every 10ms - unnecessarily often.
This commit is contained in:
parent
8e977d50ce
commit
03c8d71a56
2
clock.c
2
clock.c
|
|
@ -91,6 +91,8 @@ static void clock_250ms(void) {
|
|||
display_clock();
|
||||
#endif
|
||||
|
||||
temp_residency_tick();
|
||||
|
||||
if (DEBUG_POSITION && (debug_flags & DEBUG_POSITION)) {
|
||||
// current position
|
||||
update_current_position();
|
||||
|
|
|
|||
50
temp.c
50
temp.c
|
|
@ -380,27 +380,7 @@ void temp_sensor_tick() {
|
|||
(EWMA_SCALE-EWMA_ALPHA) * temp_sensors_runtime[i].last_read_temp
|
||||
) / EWMA_SCALE);
|
||||
}
|
||||
if (labs((int16_t)(temp_sensors_runtime[i].last_read_temp - temp_sensors_runtime[i].target_temp)) < (TEMP_HYSTERESIS*4)) {
|
||||
if (temp_sensors_runtime[i].temp_residency < (TEMP_RESIDENCY_TIME*120))
|
||||
temp_sensors_runtime[i].temp_residency++;
|
||||
}
|
||||
else {
|
||||
// Deal with flakey sensors which occasionally report a wrong value
|
||||
// by setting residency back, but not entirely to zero.
|
||||
if (temp_sensors_runtime[i].temp_residency > 10)
|
||||
temp_sensors_runtime[i].temp_residency -= 10;
|
||||
else
|
||||
temp_sensors_runtime[i].temp_residency = 0;
|
||||
}
|
||||
|
||||
if (DEBUG_PID && (debug_flags & DEBUG_PID))
|
||||
sersendf_P(PSTR("DU temp: {%d %d %d.%d}"), i,
|
||||
temp_sensors_runtime[i].last_read_temp,
|
||||
temp_sensors_runtime[i].last_read_temp / 4,
|
||||
(temp_sensors_runtime[i].last_read_temp & 0x03) * 25);
|
||||
}
|
||||
if (DEBUG_PID && (debug_flags & DEBUG_PID))
|
||||
sersendf_P(PSTR("\n"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -418,6 +398,36 @@ void temp_heater_tick() {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Called every 1s from clock.c. Update temperature residency info.
|
||||
*/
|
||||
void temp_residency_tick() {
|
||||
temp_sensor_t i;
|
||||
|
||||
for (i = 0; i < NUM_TEMP_SENSORS; i++) {
|
||||
if (labs((int16_t)(temp_sensors_runtime[i].last_read_temp - temp_sensors_runtime[i].target_temp)) < (TEMP_HYSTERESIS*4)) {
|
||||
if (temp_sensors_runtime[i].temp_residency < (TEMP_RESIDENCY_TIME*120))
|
||||
temp_sensors_runtime[i].temp_residency += 100;
|
||||
}
|
||||
else {
|
||||
// Deal with flakey sensors which occasionally report a wrong value
|
||||
// by setting residency back, but not entirely to zero.
|
||||
if (temp_sensors_runtime[i].temp_residency > 100)
|
||||
temp_sensors_runtime[i].temp_residency -= 100;
|
||||
else
|
||||
temp_sensors_runtime[i].temp_residency = 0;
|
||||
}
|
||||
|
||||
if (DEBUG_PID && (debug_flags & DEBUG_PID))
|
||||
sersendf_P(PSTR("DU temp: {%d %d %d.%d}"), i,
|
||||
temp_sensors_runtime[i].last_read_temp,
|
||||
temp_sensors_runtime[i].last_read_temp / 4,
|
||||
(temp_sensors_runtime[i].last_read_temp & 0x03) * 25);
|
||||
}
|
||||
if (DEBUG_PID && (debug_flags & DEBUG_PID))
|
||||
sersendf_P(PSTR("\n"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Report whether all temp sensors in use are reading their target
|
||||
* temperatures. Used for M116 and friends.
|
||||
|
|
|
|||
Loading…
Reference in New Issue