mcu: Fix timing of endstop checking
Make sure to not query the given endstop until after the start of the requested operation. This ensures that the operation has started prior to querying the status of that operation. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
0119e42d13
commit
32632c8226
|
@ -146,7 +146,8 @@ class MCU_endstop:
|
|||
self._oid = self._home_cmd = self._query_cmd = None
|
||||
self._mcu.register_config_callback(self._build_config)
|
||||
self._homing = False
|
||||
self._min_query_time = self._next_query_time = 0.
|
||||
self._min_query_time = 0.
|
||||
self._next_query_print_time = 0.
|
||||
self._last_state = {}
|
||||
def get_mcu(self):
|
||||
return self._mcu
|
||||
|
@ -185,7 +186,7 @@ class MCU_endstop:
|
|||
rest_ticks = int(rest_time * self._mcu.get_adjusted_freq())
|
||||
self._homing = True
|
||||
self._min_query_time = self._mcu.monotonic()
|
||||
self._next_query_time = self._min_query_time + self.RETRY_QUERY
|
||||
self._next_query_print_time = print_time + self.RETRY_QUERY
|
||||
self._home_cmd.send(
|
||||
[self._oid, clock, self._mcu.seconds_to_clock(sample_time),
|
||||
sample_count, rest_ticks, 1 ^ self._invert], reqclock=clock)
|
||||
|
@ -222,13 +223,15 @@ class MCU_endstop:
|
|||
raise self.TimeoutError("Timeout during endstop homing")
|
||||
if self._mcu.is_shutdown():
|
||||
raise error("MCU is shutdown")
|
||||
if eventtime >= self._next_query_time:
|
||||
self._next_query_time = eventtime + self.RETRY_QUERY
|
||||
est_print_time = self._mcu.estimated_print_time(eventtime)
|
||||
if est_print_time >= self._next_query_print_time:
|
||||
self._next_query_print_time = est_print_time + self.RETRY_QUERY
|
||||
self._query_cmd.send([self._oid])
|
||||
return True
|
||||
def query_endstop(self, print_time):
|
||||
self._homing = False
|
||||
self._min_query_time = self._next_query_time = self._mcu.monotonic()
|
||||
self._min_query_time = self._mcu.monotonic()
|
||||
self._next_query_print_time = print_time
|
||||
def query_endstop_wait(self):
|
||||
eventtime = self._mcu.monotonic()
|
||||
while self._check_busy(eventtime):
|
||||
|
|
Loading…
Reference in New Issue