Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeanon committed Sep 26, 2024
1 parent adaa075 commit 65416bf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
4 changes: 1 addition & 3 deletions klippy/extras/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,7 @@ def get_status(self, eventtime):

def fan_check(self):
measured_time = self.reactor.monotonic()
eventtime = self.estimated_print_time(
measured_time
)
eventtime = self.estimated_print_time(measured_time)
rpm = self.tachometer.get_status(eventtime)["rpm"]
if self.last_fan_value and rpm is not None and rpm < self.min_rpm:
self.num_err += 1
Expand Down
1 change: 1 addition & 0 deletions klippy/extras/temperature_fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ def interpolate(below, above, temp):
above[0] - below[0]
)
return

below = [
self.temperature_fan.min_temp,
self.temperature_fan.get_min_speed(),
Expand Down
28 changes: 11 additions & 17 deletions klippy/extras/z_tilt_ng.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def adjust_steppers(self, adjustments, speed):
for s in self.z_steppers:
s.set_trapq(None)
# Move each z stepper (sorted from lowest to highest) until they match
positions = [(-a, s) for a, s in zip(adjustments, self.z_steppers)]
positions = [(float(-a), s) for a, s in zip(adjustments, self.z_steppers)]
positions.sort(key=(lambda k: k[0]))
first_stepper_offset, first_stepper = positions[0]
z_low = curpos[2] - first_stepper_offset
Expand Down Expand Up @@ -333,20 +333,17 @@ def errorfunc(params):
total_error += adjusted_height(pos, params) ** 2
return total_error

new_params = mathutil.coordinate_descent(params.keys(), params, errorfunc)

new_params = mathutil.coordinate_descent(params.keys(), params, errorfunc)
# Apply results
speed = self.probe_helper.get_lift_speed()
logging.info("Calculated bed tilt parameters: %s", new_params)
return new_params

def apply_adjustments(self, offsets, new_params):
z_offset = offsets[2]
speed = self.probe_helper.get_lift_speed()
x_adjust = new_params["x_adjust"]
y_adjust = new_params["y_adjust"]
z_adjust = (
x_adjust = float(new_params["x_adjust"])
y_adjust = float(new_params["y_adjust"])
z_adjust = float(
new_params["z_adjust"]
- z_offset
- x_adjust * offsets[0]
Expand Down Expand Up @@ -398,14 +395,11 @@ def cal_finalize(self, offsets, positions):
)
if this_error < prev_error:
return "retry"
z_offsets = np.mean(self.cal_runs[-avlen:], axis=0)
z_offsets = np.mean(self.cal_runs[-avlen:], axis=0).tolist()
z_offsets = [z - offsets[2] for z in z_offsets]
self.z_offsets = z_offsets
s_zoff = ""
for off in z_offsets[: self.num_probe_points]:
s_zoff += "%.6f, " % off
s_zoff = s_zoff[:-2]
self.cal_gcmd.respond_info("final z_offsets are: %s" % (s_zoff))
s_zoff = ", ".join(["%.6f" % off for off in z_offsets[: self.num_probe_points]])
self.cal_gcmd.respond_info("final z_offsets are: %s" % s_zoff)
configfile = self.printer.lookup_object("configfile")
section = self.section
configfile.set(section, "z_offsets", s_zoff)
Expand Down Expand Up @@ -508,9 +502,9 @@ def ad_finalize(self, offsets, positions):
self.ad_gcmd.respond_info("current estimated z_positions %s" % (s_zpos))
self.ad_runs.append(z_pos)
if len(self.ad_runs) >= avlen:
self.z_positions = np.mean(self.ad_runs[-avlen:], axis=0)
self.z_positions = np.mean(self.ad_runs[-avlen:], axis=0).tolist()
else:
self.z_positions = np.mean(self.ad_runs, axis=0)
self.z_positions = np.mean(self.ad_runs, axis=0).tolist()

# We got a first estimate of the pivot points. Now apply the
# adjustemts to all motors and repeat the process until the result
Expand All @@ -523,7 +517,7 @@ def ad_finalize(self, offsets, positions):
self.apply_adjustments(offsets, self.ad_params[0])
if len(self.ad_runs) >= avlen:
errors = np.std(self.ad_runs[-avlen:], axis=0)
error = np.std(errors)
error = np.std(errors).item()
if self.ad_error is None:
self.ad_gcmd.respond_info("current error: %.6f" % (error))
else:
Expand All @@ -543,7 +537,7 @@ def ad_finalize_done(self, offsets):
np = self.numpy
avlen = self.cal_avg_len
# calculate probe point z offsets
z_offsets = np.mean(self.ad_points[-avlen:], axis=0)
z_offsets = np.mean(self.ad_points[-avlen:], axis=0).tolist()
z_offsets = [z - offsets[2] for z in z_offsets]
self.z_offsets = z_offsets
logging.info("final z_offsets %s", (z_offsets))
Expand Down

0 comments on commit 65416bf

Please sign in to comment.