From 65416bf7864199930e29cbebd357122ab0c22316 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Thu, 26 Sep 2024 08:46:23 +0200 Subject: [PATCH] . --- klippy/extras/fan.py | 4 +--- klippy/extras/temperature_fan.py | 1 + klippy/extras/z_tilt_ng.py | 28 +++++++++++----------------- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/klippy/extras/fan.py b/klippy/extras/fan.py index b248c6d58..6659c2152 100644 --- a/klippy/extras/fan.py +++ b/klippy/extras/fan.py @@ -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 diff --git a/klippy/extras/temperature_fan.py b/klippy/extras/temperature_fan.py index ff519499d..949cfbe05 100644 --- a/klippy/extras/temperature_fan.py +++ b/klippy/extras/temperature_fan.py @@ -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(), diff --git a/klippy/extras/z_tilt_ng.py b/klippy/extras/z_tilt_ng.py index d2e5ee573..0a4e1cffb 100644 --- a/klippy/extras/z_tilt_ng.py +++ b/klippy/extras/z_tilt_ng.py @@ -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 @@ -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] @@ -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) @@ -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 @@ -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: @@ -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))