gcode_arcs: detect CW / CCW move with renamed G2/G3 command (#5096)

The G2 / G3 command might be renamed using `gcode_macro` + `rename_existing`. This change allow detecting clockwise / anti-clockwise moves when the command gets renamed.

Signed-off-by: Nick Douma <n.douma@nekoconeko.nl>
This commit is contained in:
Nick Douma 2022-01-23 02:47:51 +01:00 committed by GitHub
parent 2f1edac922
commit 28b568a6ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -20,9 +20,15 @@ class ArcSupport:
self.gcode_move = self.printer.load_object(config, 'gcode_move')
self.gcode = self.printer.lookup_object('gcode')
self.gcode.register_command("G2", self.cmd_G2)
self.gcode.register_command("G3", self.cmd_G2)
self.gcode.register_command("G3", self.cmd_G3)
def cmd_G2(self, gcmd):
self._cmd_inner(gcmd, True)
def cmd_G3(self, gcmd):
self._cmd_inner(gcmd, False)
def _cmd_inner(self, gcmd, clockwise):
gcodestatus = self.gcode_move.get_status()
if not gcodestatus['absolute_coordinates']:
raise gcmd.error("G2/G3 does not support relative move mode")
@ -40,7 +46,6 @@ class ArcSupport:
raise gcmd.error("G2/G3 neither I nor J given")
asE = gcmd.get_float("E", None)
asF = gcmd.get_float("F", None)
clockwise = (gcmd.get_command() == 'G2')
# Build list of linear coordinates to move to
coords = self.planArc(currentPos, [asX, asY, asZ], [asI, asJ],