From a238ec6f98e78af9d398c68b74d73f3254e0cbf3 Mon Sep 17 00:00:00 2001 From: Arksine Date: Tue, 21 May 2019 20:47:33 -0400 Subject: idle_timeout: Add SET_IDLE_TIMEOUT gcode Signed-off-by: Eric Callahan --- klippy/extras/idle_timeout.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'klippy/extras/idle_timeout.py') diff --git a/klippy/extras/idle_timeout.py b/klippy/extras/idle_timeout.py index b422f388..848852e8 100644 --- a/klippy/extras/idle_timeout.py +++ b/klippy/extras/idle_timeout.py @@ -23,6 +23,8 @@ class IdleTimeout: self.state = "Idle" self.idle_timeout = config.getfloat('timeout', 600., above=0.) self.idle_gcode = config.get('gcode', DEFAULT_IDLE_GCODE).split('\n') + self.gcode.register_command( + 'SET_IDLE_TIMEOUT', self.cmd_SET_IDLE_TIMEOUT) def handle_ready(self): self.toolhead = self.printer.lookup_object('toolhead') self.timeout_timer = self.reactor.register_timer(self.timeout_handler) @@ -88,6 +90,16 @@ class IdleTimeout: self.reactor.update_timer(self.timeout_timer, curtime + check_time) self.printer.send_event("idle_timeout:printing", est_print_time + PIN_MIN_TIME) + def cmd_SET_IDLE_TIMEOUT(self, params): + timeout = self.gcode.get_float( + 'TIMEOUT', params, self.idle_timeout, above=0.) + self.idle_timeout = timeout + self.gcode.respond_info( + "idle_timeout: Timeout set to %.2f s" % timeout) + if self.state == "Ready": + checktime = self.reactor.monotonic() + timeout + self.reactor.update_timer( + self.timeout_timer, checktime) def load_config(config): return IdleTimeout(config) -- cgit v1.2.3-70-g09d2