mcu: Integrate query_endstop_wait() into query_endstop()
There is no need to have two separate calls to query an endstop. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
ced5e35f0c
commit
b2c778b931
|
@ -55,7 +55,6 @@ class BLTouchEndstopWrapper:
|
||||||
self.get_steppers = self.mcu_endstop.get_steppers
|
self.get_steppers = self.mcu_endstop.get_steppers
|
||||||
self.home_wait = self.mcu_endstop.home_wait
|
self.home_wait = self.mcu_endstop.home_wait
|
||||||
self.query_endstop = self.mcu_endstop.query_endstop
|
self.query_endstop = self.mcu_endstop.query_endstop
|
||||||
self.query_endstop_wait = self.mcu_endstop.query_endstop_wait
|
|
||||||
self.TimeoutError = self.mcu_endstop.TimeoutError
|
self.TimeoutError = self.mcu_endstop.TimeoutError
|
||||||
# Register BLTOUCH_DEBUG command
|
# Register BLTOUCH_DEBUG command
|
||||||
self.gcode = self.printer.lookup_object('gcode')
|
self.gcode = self.printer.lookup_object('gcode')
|
||||||
|
|
|
@ -145,8 +145,7 @@ class PrinterProbe:
|
||||||
def cmd_QUERY_PROBE(self, params):
|
def cmd_QUERY_PROBE(self, params):
|
||||||
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()
|
||||||
self.mcu_probe.query_endstop(print_time)
|
res = self.mcu_probe.query_endstop(print_time)
|
||||||
res = self.mcu_probe.query_endstop_wait()
|
|
||||||
self.gcode.respond_info(
|
self.gcode.respond_info(
|
||||||
"probe: %s" % (["open", "TRIGGERED"][not not res],))
|
"probe: %s" % (["open", "TRIGGERED"][not not res],))
|
||||||
cmd_PROBE_ACCURACY_help = "Probe Z-height accuracy at current XY position"
|
cmd_PROBE_ACCURACY_help = "Probe Z-height accuracy at current XY position"
|
||||||
|
@ -244,7 +243,6 @@ class ProbeEndstopWrapper:
|
||||||
self.home_start = self.mcu_endstop.home_start
|
self.home_start = self.mcu_endstop.home_start
|
||||||
self.home_wait = self.mcu_endstop.home_wait
|
self.home_wait = self.mcu_endstop.home_wait
|
||||||
self.query_endstop = self.mcu_endstop.query_endstop
|
self.query_endstop = self.mcu_endstop.query_endstop
|
||||||
self.query_endstop_wait = self.mcu_endstop.query_endstop_wait
|
|
||||||
self.TimeoutError = self.mcu_endstop.TimeoutError
|
self.TimeoutError = self.mcu_endstop.TimeoutError
|
||||||
def _build_config(self):
|
def _build_config(self):
|
||||||
kin = self.printer.lookup_object('toolhead').get_kinematics()
|
kin = self.printer.lookup_object('toolhead').get_kinematics()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Utility for querying the current state of all endstops
|
# Utility for querying the current state of all endstops
|
||||||
#
|
#
|
||||||
# Copyright (C) 2018 Kevin O'Connor <kevin@koconnor.net>
|
# Copyright (C) 2018-2019 Kevin O'Connor <kevin@koconnor.net>
|
||||||
#
|
#
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
|
|
||||||
|
@ -16,14 +16,10 @@ class QueryEndstops:
|
||||||
self.endstops.append((mcu_endstop, name))
|
self.endstops.append((mcu_endstop, name))
|
||||||
cmd_QUERY_ENDSTOPS_help = "Report on the status of each endstop"
|
cmd_QUERY_ENDSTOPS_help = "Report on the status of each endstop"
|
||||||
def cmd_QUERY_ENDSTOPS(self, params):
|
def cmd_QUERY_ENDSTOPS(self, params):
|
||||||
toolhead = self.printer.lookup_object('toolhead')
|
|
||||||
print_time = toolhead.get_last_move_time()
|
|
||||||
# Query the endstops
|
# Query the endstops
|
||||||
for mcu_endstop, name in self.endstops:
|
print_time = self.printer.lookup_object('toolhead').get_last_move_time()
|
||||||
mcu_endstop.query_endstop(print_time)
|
out = [(name, mcu_endstop.query_endstop(print_time))
|
||||||
out = []
|
for mcu_endstop, name in self.endstops]
|
||||||
for mcu_endstop, name in self.endstops:
|
|
||||||
out.append((name, mcu_endstop.query_endstop_wait()))
|
|
||||||
# Report results
|
# Report results
|
||||||
msg = " ".join(["%s:%s" % (name, ["open", "TRIGGERED"][not not t])
|
msg = " ".join(["%s:%s" % (name, ["open", "TRIGGERED"][not not t])
|
||||||
for name, t in out])
|
for name, t in out])
|
||||||
|
|
|
@ -171,7 +171,6 @@ class TMCVirtualEndstop:
|
||||||
self.home_start = self.mcu_endstop.home_start
|
self.home_start = self.mcu_endstop.home_start
|
||||||
self.home_wait = self.mcu_endstop.home_wait
|
self.home_wait = self.mcu_endstop.home_wait
|
||||||
self.query_endstop = self.mcu_endstop.query_endstop
|
self.query_endstop = self.mcu_endstop.query_endstop
|
||||||
self.query_endstop_wait = self.mcu_endstop.query_endstop_wait
|
|
||||||
self.TimeoutError = self.mcu_endstop.TimeoutError
|
self.TimeoutError = self.mcu_endstop.TimeoutError
|
||||||
def home_prepare(self):
|
def home_prepare(self):
|
||||||
self.fields.set_field("en_pwm_mode", 0)
|
self.fields.set_field("en_pwm_mode", 0)
|
||||||
|
|
|
@ -234,10 +234,8 @@ class MCU_endstop:
|
||||||
return True
|
return True
|
||||||
def query_endstop(self, print_time):
|
def query_endstop(self, print_time):
|
||||||
self._homing = False
|
self._homing = False
|
||||||
self._min_query_time = self._mcu.monotonic()
|
self._min_query_time = eventtime = self._mcu.monotonic()
|
||||||
self._next_query_print_time = print_time
|
self._next_query_print_time = print_time
|
||||||
def query_endstop_wait(self):
|
|
||||||
eventtime = self._mcu.monotonic()
|
|
||||||
while self._check_busy(eventtime):
|
while self._check_busy(eventtime):
|
||||||
eventtime = self._mcu.pause(eventtime + 0.1)
|
eventtime = self._mcu.pause(eventtime + 0.1)
|
||||||
return self._last_state.get('pin_value', self._invert) ^ self._invert
|
return self._last_state.get('pin_value', self._invert) ^ self._invert
|
||||||
|
|
Loading…
Reference in New Issue