diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2016-09-22 11:09:20 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2016-09-22 11:29:27 -0400 |
commit | 0685802cb8b72c44e3e87e1011ed99b43d3bca44 (patch) | |
tree | ffffe062070549ad41a8435da67f1e67b090b1ff /klippy/homing.py | |
parent | c8ff439722eae62d3e3bbb11f77c987b8e594959 (diff) | |
download | kutter-0685802cb8b72c44e3e87e1011ed99b43d3bca44.tar.gz kutter-0685802cb8b72c44e3e87e1011ed99b43d3bca44.tar.xz kutter-0685802cb8b72c44e3e87e1011ed99b43d3bca44.zip |
homing: Support querying the current status of endstops
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/homing.py')
-rw-r--r-- | klippy/homing.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/klippy/homing.py b/klippy/homing.py index 8670c45a..1bfe141e 100644 --- a/klippy/homing.py +++ b/klippy/homing.py @@ -11,6 +11,7 @@ class Homing: self.toolhead = toolhead self.changed_axes = changed_axes + self.eventtime = 0. self.states = [] self.endstops = [] def plan_home(self, forcepos, movepos, steppers, speed): @@ -21,6 +22,7 @@ class Homing: def plan_axes_update(self, callback): self.states.append((callback, (self.changed_axes,))) def check_busy(self, eventtime): + self.eventtime = eventtime while self.states: first = self.states[0] ret = first[0](*first[1]) @@ -57,8 +59,34 @@ class Homing: def do_wait_endstop(self): # Check if endstops have triggered for es in self.endstops: - if es.is_homing(): + if es.check_busy(self.eventtime): return True # Finished del self.endstops[:] return False + +class QueryEndstops: + def __init__(self, names, steppers): + self.endstops = [] + self.busy = [] + for name, stepper in zip(names, steppers): + es = stepper.query_endstop() + if es is None: + continue + self.endstops.append((name, es)) + self.busy.append(es) + def check_busy(self, eventtime): + while self.busy: + busy = self.busy[0].check_busy(eventtime) + if busy: + return True + self.busy.pop(0) + return False + def get_msg(self): + msgs = [] + for name, es in self.endstops: + msg = "open" + if es.get_last_triggered(): + msg = "TRIGGERED" + msgs.append("%s:%s" % (name, msg)) + return " ".join(msgs) |