Skip to content

Commit

Permalink
z_thermal_adjust: fix temp initialization
Browse files Browse the repository at this point in the history
Fix initial 0.0degC reading influencing smoothed temperature and initial adjust.
Signed-off-by: Robert Pazdzior <[email protected]>
  • Loading branch information
alchemyEngine authored Feb 24, 2024
1 parent 66d2a80 commit ec0af89
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions klippy/extras/z_thermal_adjust.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,16 @@ def move(self, newpos, speed):

def temperature_callback(self, read_time, temp):
'Called everytime the Z adjust thermistor is read'
with self.lock:
time_diff = read_time - self.last_temp_time
self.last_temp = temp
self.last_temp_time = read_time
temp_diff = temp - self.smoothed_temp
adj_time = min(time_diff * self.inv_smooth_time, 1.)
self.smoothed_temp += temp_diff * adj_time
self.measured_min = min(self.measured_min, self.smoothed_temp)
self.measured_max = max(self.measured_max, self.smoothed_temp)
if temp:
with self.lock:
time_diff = read_time - self.last_temp_time
self.last_temp = temp
self.last_temp_time = read_time
temp_diff = temp - self.smoothed_temp
adj_time = min(time_diff * self.inv_smooth_time, 1.)
self.smoothed_temp += temp_diff * adj_time
self.measured_min = min(self.measured_min, self.smoothed_temp)
self.measured_max = max(self.measured_max, self.smoothed_temp)

def get_temp(self, eventtime):
return self.smoothed_temp, 0.
Expand Down

0 comments on commit ec0af89

Please sign in to comment.