probe: Add last_z_result to get the latest z result in an Macro (#3835)

Signed-off-by: Christian Schnellrieder <schnello.android@gmail.com>
This commit is contained in:
Christian S 2021-02-19 04:03:32 +01:00 committed by GitHub
parent b2cbb9aa96
commit bc2f6faa17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -214,6 +214,8 @@ The following are common printer attributes:
as "triggered" during the last QUERY_PROBE command. Note, due to the as "triggered" during the last QUERY_PROBE command. Note, due to the
order of template expansion (see above), the QUERY_PROBE command order of template expansion (see above), the QUERY_PROBE command
must be run prior to the macro containing this reference. must be run prior to the macro containing this reference.
- `printer.probe.last_z_result`: Returns the Z result value of the last
PROBE command.
- `printer.configfile.settings.<section>.<option>`: Returns the given - `printer.configfile.settings.<section>.<option>`: Returns the given
config file setting (or default value) during the last software config file setting (or default value) during the last software
start or restart. (Any settings changed at run-time will not be start or restart. (Any settings changed at run-time will not be

View File

@ -26,6 +26,7 @@ class PrinterProbe:
self.probe_calibrate_z = 0. self.probe_calibrate_z = 0.
self.multi_probe_pending = False self.multi_probe_pending = False
self.last_state = False self.last_state = False
self.last_z_result = 0.
# Infer Z position to move to during a probe # Infer Z position to move to during a probe
if config.has_section('stepper_z'): if config.has_section('stepper_z'):
zconfig = config.getsection('stepper_z') zconfig = config.getsection('stepper_z')
@ -185,6 +186,7 @@ class PrinterProbe:
def cmd_PROBE(self, gcmd): def cmd_PROBE(self, gcmd):
pos = self.run_probe(gcmd) pos = self.run_probe(gcmd)
gcmd.respond_info("Result is z=%.6f" % (pos[2],)) gcmd.respond_info("Result is z=%.6f" % (pos[2],))
self.last_z_result = pos[2]
cmd_QUERY_PROBE_help = "Return the status of the z-probe" cmd_QUERY_PROBE_help = "Return the status of the z-probe"
def cmd_QUERY_PROBE(self, gcmd): def cmd_QUERY_PROBE(self, gcmd):
toolhead = self.printer.lookup_object('toolhead') toolhead = self.printer.lookup_object('toolhead')
@ -193,7 +195,8 @@ class PrinterProbe:
self.last_state = res self.last_state = res
gcmd.respond_info("probe: %s" % (["open", "TRIGGERED"][not not res],)) gcmd.respond_info("probe: %s" % (["open", "TRIGGERED"][not not res],))
def get_status(self, eventtime): def get_status(self, eventtime):
return {'last_query': self.last_state} return {'last_query': self.last_state,
'last_z_result': self.last_z_result}
cmd_PROBE_ACCURACY_help = "Probe Z-height accuracy at current XY position" cmd_PROBE_ACCURACY_help = "Probe Z-height accuracy at current XY position"
def cmd_PROBE_ACCURACY(self, gcmd): def cmd_PROBE_ACCURACY(self, gcmd):
speed = gcmd.get_float("PROBE_SPEED", self.speed, above=0.) speed = gcmd.get_float("PROBE_SPEED", self.speed, above=0.)