diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2019-01-10 12:27:56 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2019-01-10 12:27:56 -0500 |
commit | 32632c8226139896e1becf87c0cdd47a8c0b89ed (patch) | |
tree | 263f9daa1ead098ba4859dd792550cfc83720b46 /klippy | |
parent | 0119e42d13e6088ceb020c7f885d2a64afecbf98 (diff) | |
download | kutter-32632c8226139896e1becf87c0cdd47a8c0b89ed.tar.gz kutter-32632c8226139896e1becf87c0cdd47a8c0b89ed.tar.xz kutter-32632c8226139896e1becf87c0cdd47a8c0b89ed.zip |
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>
Diffstat (limited to 'klippy')
-rw-r--r-- | klippy/mcu.py | 13 |
1 files changed, 8 insertions, 5 deletions
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): |