mirror of https://github.com/Desuuuu/klipper.git
mcu: Use regular send_with_response() for query_endstop()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
a116fa9054
commit
e148dbe52a
|
@ -147,7 +147,6 @@ class MCU_endstop:
|
|||
self._invert = pin_params['invert']
|
||||
self._oid = self._home_cmd = self._query_cmd = None
|
||||
self._mcu.register_config_callback(self._build_config)
|
||||
self._homing = False
|
||||
self._min_query_time = 0.
|
||||
self._next_query_print_time = 0.
|
||||
self._last_state = {}
|
||||
|
@ -179,17 +178,16 @@ class MCU_endstop:
|
|||
" rest_ticks=%u pin_value=%c", cq=cmd_queue)
|
||||
self._query_cmd = self._mcu.lookup_command(
|
||||
"end_stop_query_state oid=%c", cq=cmd_queue)
|
||||
self._mcu.register_response(self._handle_end_stop_state,
|
||||
"end_stop_state", self._oid)
|
||||
def home_prepare(self):
|
||||
pass
|
||||
def home_start(self, print_time, sample_time, sample_count, rest_time,
|
||||
triggered=True):
|
||||
clock = self._mcu.print_time_to_clock(print_time)
|
||||
rest_ticks = int(rest_time * self._mcu.get_adjusted_freq())
|
||||
self._homing = True
|
||||
self._min_query_time = self._mcu.monotonic()
|
||||
self._next_query_print_time = print_time + self.RETRY_QUERY
|
||||
self._mcu.register_response(self._handle_end_stop_state,
|
||||
"end_stop_state", self._oid)
|
||||
self._home_cmd.send(
|
||||
[self._oid, clock, self._mcu.seconds_to_clock(sample_time),
|
||||
sample_count, rest_ticks, triggered ^ self._invert],
|
||||
|
@ -198,8 +196,11 @@ class MCU_endstop:
|
|||
s.note_homing_start(clock)
|
||||
def home_wait(self, home_end_time):
|
||||
eventtime = self._mcu.monotonic()
|
||||
while self._check_busy(eventtime, home_end_time):
|
||||
eventtime = self._mcu.pause(eventtime + 0.1)
|
||||
try:
|
||||
while self._check_busy(eventtime, home_end_time):
|
||||
eventtime = self._mcu.pause(eventtime + 0.1)
|
||||
finally:
|
||||
self._mcu.register_response(None, "end_stop_state", self._oid)
|
||||
def home_finalize(self):
|
||||
pass
|
||||
def _handle_end_stop_state(self, params):
|
||||
|
@ -209,12 +210,9 @@ class MCU_endstop:
|
|||
# Check if need to send an end_stop_query command
|
||||
last_sent_time = self._last_state.get('#sent_time', -1.)
|
||||
if last_sent_time >= self._min_query_time or self._mcu.is_fileoutput():
|
||||
if not self._homing:
|
||||
return False
|
||||
if not self._last_state.get('homing', 0):
|
||||
for s in self._steppers:
|
||||
s.note_homing_end(did_trigger=True)
|
||||
self._homing = False
|
||||
return False
|
||||
last_sent_print_time = self._mcu.estimated_print_time(
|
||||
last_sent_time)
|
||||
|
@ -222,7 +220,6 @@ class MCU_endstop:
|
|||
# Timeout - disable endstop checking
|
||||
for s in self._steppers:
|
||||
s.note_homing_end()
|
||||
self._homing = False
|
||||
self._home_cmd.send([self._oid, 0, 0, 0, 0, 0])
|
||||
raise self.TimeoutError("Timeout during endstop homing")
|
||||
if self._mcu.is_shutdown():
|
||||
|
@ -233,12 +230,12 @@ class MCU_endstop:
|
|||
self._query_cmd.send([self._oid])
|
||||
return True
|
||||
def query_endstop(self, print_time):
|
||||
self._homing = False
|
||||
self._min_query_time = eventtime = self._mcu.monotonic()
|
||||
self._next_query_print_time = print_time
|
||||
while self._check_busy(eventtime):
|
||||
eventtime = self._mcu.pause(eventtime + 0.1)
|
||||
return self._last_state.get('pin_value', self._invert) ^ self._invert
|
||||
clock = self._mcu.print_time_to_clock(print_time)
|
||||
if self._mcu.is_fileoutput():
|
||||
return 0
|
||||
params = self._query_cmd.send_with_response(
|
||||
[self._oid], "end_stop_state", self._oid, minclock=clock)
|
||||
return params['pin_value'] ^ self._invert
|
||||
|
||||
class MCU_digital_out:
|
||||
def __init__(self, mcu, pin_params):
|
||||
|
|
Loading…
Reference in New Issue