probe: add get_status wrapper to probe for last_query from query_probe command (#3296)

Add get_status wrapper with last_query status for macros  It is sometimes useful to determine the state of the probe from a macro. If the probe is connected to an endstop pin, the results can be obtained via QUERY_ENDSTOPS but if a physical endstop is in use in addition to the probe the probe state cannot be obtained. This change allows one to use QUERY_PROBE  and then access the printer.probe.last_query object to obtain the state.

Signed-off-by: Paul McGowan <mental405@gmail.com>
This commit is contained in:
Paul McGowan 2020-09-09 23:10:35 -04:00 committed by GitHub
parent c7ea4b89c9
commit 5a2f406fd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -194,6 +194,10 @@ The following are common printer attributes:
QUERY_ENDSTOP command. Note, due to the order of template expansion QUERY_ENDSTOP command. Note, due to the order of template expansion
(see above), the QUERY_STATUS command must be run prior to the macro (see above), the QUERY_STATUS command must be run prior to the macro
containing this reference. containing this reference.
- `printer.probe.last_query`: Returns True if the probe was reported
as "triggered" during the last QUERY_PROBE command. Note, due to the
order of template expansion (see above), the QUERY_STATUS command
must be run prior to the macro containing this reference.
- `printer.configfile.config["<section>"]["<option>"]`: Returns the - `printer.configfile.config["<section>"]["<option>"]`: Returns the
given config file setting as read by Klipper during the last given config file setting as read by Klipper during the last
software start or restart. (Any settings changed at run-time will software start or restart. (Any settings changed at run-time will

View File

@ -25,6 +25,7 @@ class PrinterProbe:
self.z_offset = config.getfloat('z_offset') self.z_offset = config.getfloat('z_offset')
self.probe_calibrate_z = 0. self.probe_calibrate_z = 0.
self.multi_probe_pending = False self.multi_probe_pending = False
self.last_state = False
# 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')
@ -187,7 +188,10 @@ class PrinterProbe:
toolhead = self.printer.lookup_object('toolhead') toolhead = self.printer.lookup_object('toolhead')
print_time = toolhead.get_last_move_time() print_time = toolhead.get_last_move_time()
res = self.mcu_probe.query_endstop(print_time) res = self.mcu_probe.query_endstop(print_time)
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):
return {'last_query': self.last_state}
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.)