diff options
Diffstat (limited to 'klippy/extras/query_endstops.py')
-rw-r--r-- | klippy/extras/query_endstops.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/klippy/extras/query_endstops.py b/klippy/extras/query_endstops.py index f0e5c58e..9682228f 100644 --- a/klippy/extras/query_endstops.py +++ b/klippy/extras/query_endstops.py @@ -8,21 +8,24 @@ class QueryEndstops: def __init__(self, config): self.printer = config.get_printer() self.endstops = [] + self.last_state = {} gcode = self.printer.lookup_object('gcode') gcode.register_command("QUERY_ENDSTOPS", self.cmd_QUERY_ENDSTOPS, desc=self.cmd_QUERY_ENDSTOPS_help) gcode.register_command("M119", self.cmd_QUERY_ENDSTOPS) def register_endstop(self, mcu_endstop, name): self.endstops.append((mcu_endstop, name)) + def get_status(self, eventtime): + return {'last_query': {name: value for name, value in self.last_state}} cmd_QUERY_ENDSTOPS_help = "Report on the status of each endstop" def cmd_QUERY_ENDSTOPS(self, params): # Query the endstops print_time = self.printer.lookup_object('toolhead').get_last_move_time() - out = [(name, mcu_endstop.query_endstop(print_time)) - for mcu_endstop, name in self.endstops] + self.last_state = [(name, mcu_endstop.query_endstop(print_time)) + for mcu_endstop, name in self.endstops] # Report results msg = " ".join(["%s:%s" % (name, ["open", "TRIGGERED"][not not t]) - for name, t in out]) + for name, t in self.last_state]) gcode = self.printer.lookup_object('gcode') gcode.respond(msg) |