mirror of https://github.com/Desuuuu/klipper.git
z_tilt: Use new GCodeCommand wrappers
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
ff6c11e827
commit
dce46ea053
|
@ -74,22 +74,23 @@ class RetryHelper:
|
||||||
config.getfloat("retry_tolerance", 0., above=0.)
|
config.getfloat("retry_tolerance", 0., above=0.)
|
||||||
self.value_label = "Probed points range"
|
self.value_label = "Probed points range"
|
||||||
self.error_msg_extra = error_msg_extra
|
self.error_msg_extra = error_msg_extra
|
||||||
def start(self, params):
|
def start(self, gcmd):
|
||||||
self.max_retries = self.gcode.get_int('RETRIES', params,
|
self.max_retries = gcmd.get_int('RETRIES', self.default_max_retries,
|
||||||
default=self.default_max_retries, minval=0, maxval=30)
|
minval=0, maxval=30)
|
||||||
self.retry_tolerance = self.gcode.get_float('RETRY_TOLERANCE', params,
|
self.retry_tolerance = gcmd.get_float('RETRY_TOLERANCE',
|
||||||
default=self.default_retry_tolerance, minval=0, maxval=1.0)
|
self.default_retry_tolerance,
|
||||||
|
minval=0.0, maxval=1.0)
|
||||||
self.current_retry = 0
|
self.current_retry = 0
|
||||||
self.previous = None
|
self.previous = None
|
||||||
self.increasing = 0
|
self.increasing = 0
|
||||||
def check_increase(self,error):
|
def check_increase(self, error):
|
||||||
if self.previous and error > self.previous + 0.0000001:
|
if self.previous and error > self.previous + 0.0000001:
|
||||||
self.increasing += 1
|
self.increasing += 1
|
||||||
elif self.increasing > 0:
|
elif self.increasing > 0:
|
||||||
self.increasing -= 1
|
self.increasing -= 1
|
||||||
self.previous = error
|
self.previous = error
|
||||||
return self.increasing > 1
|
return self.increasing > 1
|
||||||
def check_retry(self,z_positions):
|
def check_retry(self, z_positions):
|
||||||
if self.max_retries == 0:
|
if self.max_retries == 0:
|
||||||
return
|
return
|
||||||
error = max(z_positions) - min(z_positions)
|
error = max(z_positions) - min(z_positions)
|
||||||
|
@ -124,13 +125,13 @@ class ZTilt:
|
||||||
self.probe_helper.minimum_points(2)
|
self.probe_helper.minimum_points(2)
|
||||||
self.z_helper = ZAdjustHelper(config, len(self.z_positions))
|
self.z_helper = ZAdjustHelper(config, len(self.z_positions))
|
||||||
# Register Z_TILT_ADJUST command
|
# Register Z_TILT_ADJUST command
|
||||||
self.gcode = self.printer.lookup_object('gcode')
|
gcode = self.printer.lookup_object('gcode')
|
||||||
self.gcode.register_command('Z_TILT_ADJUST', self.cmd_Z_TILT_ADJUST,
|
gcode.register_command('Z_TILT_ADJUST', self.cmd_Z_TILT_ADJUST,
|
||||||
desc=self.cmd_Z_TILT_ADJUST_help)
|
desc=self.cmd_Z_TILT_ADJUST_help)
|
||||||
cmd_Z_TILT_ADJUST_help = "Adjust the Z tilt"
|
cmd_Z_TILT_ADJUST_help = "Adjust the Z tilt"
|
||||||
def cmd_Z_TILT_ADJUST(self, params):
|
def cmd_Z_TILT_ADJUST(self, gcmd):
|
||||||
self.retry_helper.start(params)
|
self.retry_helper.start(gcmd)
|
||||||
self.probe_helper.start_probe(params)
|
self.probe_helper.start_probe(gcmd)
|
||||||
def probe_finalize(self, offsets, positions):
|
def probe_finalize(self, offsets, positions):
|
||||||
# Setup for coordinate descent analysis
|
# Setup for coordinate descent analysis
|
||||||
z_offset = offsets[2]
|
z_offset = offsets[2]
|
||||||
|
|
Loading…
Reference in New Issue