diff --git a/docs/G-Codes.md b/docs/G-Codes.md index 92cb76606afb..0071596187f7 100644 --- a/docs/G-Codes.md +++ b/docs/G-Codes.md @@ -7,7 +7,7 @@ commands that one may enter into the OctoPrint terminal tab. Klipper supports the following standard G-Code commands: - Move (G0 or G1): `G1 [X] [Y] [Z] [E] [F]` -- Dwell: `G4 P` +- Dwell: `G4 P` or `G4 S` or `G4 S P` - Move to origin: `G28 [X] [Y] [Z]` - Turn off motors: `M18` or `M84` - Wait for current moves to finish: `M400` diff --git a/klippy/toolhead.py b/klippy/toolhead.py index ce014365c6f9..28524c85fb40 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -602,10 +602,19 @@ def _calc_junction_deviation(self): self.junction_deviation = scv2 * (math.sqrt(2.) - 1.) / self.max_accel self.max_accel_to_decel = min(self.requested_accel_to_decel, self.max_accel) + def cmd_G4(self, gcmd): # Dwell - delay = gcmd.get_float('P', 0., minval=0.) / 1000. + delay_in_seconds = gcmd.get_float('S', None, minval=0.) + delay_in_milliseconds = gcmd.get_float('P', None, minval=0.) + + if delay_in_seconds is None and delay_in_milliseconds is None: + logging.warning("neither S nor P argument given") + return + + delay = (delay_in_seconds or 0) + (delay_in_milliseconds or 0) / 1000. self.dwell(delay) + def cmd_M400(self, gcmd): # Wait for current moves to finish self.wait_moves()