diff --git a/klippy/mcu.py b/klippy/mcu.py index febc69b7..a0bfc14f 100644 --- a/klippy/mcu.py +++ b/klippy/mcu.py @@ -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):