aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--klippy/extras/gcode_move.py9
-rw-r--r--klippy/gcode.py13
-rw-r--r--klippy/homing.py7
-rw-r--r--klippy/klippy.py4
-rw-r--r--klippy/toolhead.py8
-rw-r--r--klippy/webhooks.py11
6 files changed, 24 insertions, 28 deletions
diff --git a/klippy/extras/gcode_move.py b/klippy/extras/gcode_move.py
index 08c926e9..4bdfdf8b 100644
--- a/klippy/extras/gcode_move.py
+++ b/klippy/extras/gcode_move.py
@@ -1,6 +1,6 @@
# G-Code G1 movement commands (and associated coordinate manipulation)
#
-# Copyright (C) 2016-2020 Kevin O'Connor <kevin@koconnor.net>
+# Copyright (C) 2016-2021 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
@@ -34,6 +34,7 @@ class GCodeMove:
gcode.register_command('G0', self.cmd_G1)
gcode.register_command('M114', self.cmd_M114, True)
gcode.register_command('GET_POSITION', self.cmd_GET_POSITION, True)
+ self.Coord = gcode.Coord
# G-Code coordinate manipulation
self.absolute_coord = self.absolute_extrude = True
self.base_position = [0.0, 0.0, 0.0, 0.0]
@@ -94,9 +95,9 @@ class GCodeMove:
'extrude_factor': self.extrude_factor,
'absolute_coordinates': self.absolute_coord,
'absolute_extrude': self.absolute_extrude,
- 'homing_origin': homing.Coord(*self.homing_position),
- 'position': homing.Coord(*self.last_position),
- 'gcode_position': homing.Coord(*move_position),
+ 'homing_origin': self.Coord(*self.homing_position),
+ 'position': self.Coord(*self.last_position),
+ 'gcode_position': self.Coord(*move_position),
}
def reset_last_position(self):
if self.is_printer_ready:
diff --git a/klippy/gcode.py b/klippy/gcode.py
index f34b9ea2..dc83d2b0 100644
--- a/klippy/gcode.py
+++ b/klippy/gcode.py
@@ -1,13 +1,17 @@
# Parse gcode commands
#
-# Copyright (C) 2016-2020 Kevin O'Connor <kevin@koconnor.net>
+# Copyright (C) 2016-2021 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import os, re, logging, collections, shlex
-import homing
+
+class CommandError(Exception):
+ pass
+
+Coord = collections.namedtuple('Coord', ('x', 'y', 'z', 'e'))
class GCodeCommand:
- error = homing.CommandError
+ error = CommandError
def __init__(self, gcode, command, commandline, params, need_ack):
self._command = command
self._commandline = commandline
@@ -68,7 +72,8 @@ class GCodeCommand:
# Parse and dispatch G-Code commands
class GCodeDispatch:
- error = homing.CommandError
+ error = CommandError
+ Coord = Coord
def __init__(self, printer):
self.printer = printer
self.is_fileinput = not not printer.get_start_args().get("debuginput")
diff --git a/klippy/homing.py b/klippy/homing.py
index 2e2e072d..49f5a8dc 100644
--- a/klippy/homing.py
+++ b/klippy/homing.py
@@ -1,6 +1,6 @@
# Code for state tracking during homing operations
#
-# Copyright (C) 2016-2019 Kevin O'Connor <kevin@koconnor.net>
+# Copyright (C) 2016-2021 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging, math, collections
@@ -157,8 +157,3 @@ def multi_complete(printer, completions):
return completions[0]
cb = (lambda e: all([c.wait() for c in completions]))
return printer.get_reactor().register_callback(cb)
-
-class CommandError(Exception):
- pass
-
-Coord = collections.namedtuple('Coord', ('x', 'y', 'z', 'e'))
diff --git a/klippy/klippy.py b/klippy/klippy.py
index fb1d5f9f..e2c580bc 100644
--- a/klippy/klippy.py
+++ b/klippy/klippy.py
@@ -5,7 +5,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import sys, os, gc, optparse, logging, time, collections, importlib
-import util, reactor, queuelogger, msgproto, homing
+import util, reactor, queuelogger, msgproto
import gcode, configfile, pins, mcu, toolhead, webhooks
message_ready = "Printer is ready"
@@ -47,7 +47,7 @@ Printer is shutdown
class Printer:
config_error = configfile.error
- command_error = homing.CommandError
+ command_error = gcode.CommandError
def __init__(self, main_reactor, bglogger, start_args):
self.bglogger = bglogger
self.start_args = start_args
diff --git a/klippy/toolhead.py b/klippy/toolhead.py
index 82cc1556..5c229dc7 100644
--- a/klippy/toolhead.py
+++ b/klippy/toolhead.py
@@ -1,10 +1,10 @@
# Code for coordinating events on the printer toolhead
#
-# Copyright (C) 2016-2020 Kevin O'Connor <kevin@koconnor.net>
+# Copyright (C) 2016-2021 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import math, logging, importlib
-import mcu, homing, chelper, kinematics.extruder
+import mcu, chelper, kinematics.extruder
# Common suffixes: _d is distance (in mm), _v is velocity (in
# mm/second), _v2 is velocity squared (mm^2/s^2), _t is time (in
@@ -196,7 +196,6 @@ class DripModeEndSignal(Exception):
# Main code to track events (and their timing) on the printer toolhead
class ToolHead:
- Coord = homing.Coord
def __init__(self, config):
self.printer = config.get_printer()
self.reactor = self.printer.get_reactor()
@@ -251,6 +250,8 @@ class ToolHead:
self.trapq_free_moves = ffi_lib.trapq_free_moves
self.step_generators = []
# Create kinematics class
+ gcode = self.printer.lookup_object('gcode')
+ self.Coord = gcode.Coord
self.extruder = kinematics.extruder.DummyExtruder(self.printer)
kin_name = config.get('kinematics')
try:
@@ -265,7 +266,6 @@ class ToolHead:
logging.exception(msg)
raise config.error(msg)
# Register commands
- gcode = self.printer.lookup_object('gcode')
gcode.register_command('G4', self.cmd_G4)
gcode.register_command('M400', self.cmd_M400)
gcode.register_command('SET_VELOCITY_LIMIT',
diff --git a/klippy/webhooks.py b/klippy/webhooks.py
index 24613b04..7fffc1fe 100644
--- a/klippy/webhooks.py
+++ b/klippy/webhooks.py
@@ -3,13 +3,8 @@
# Copyright (C) 2020 Eric Callahan <arksine.code@gmail.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license
-import logging
-import socket
-import os
-import sys
-import errno
-import json
-import homing
+import logging, socket, os, sys, errno, json
+import gcode
# Json decodes strings as unicode types in Python 2.x. This doesn't
# play well with some parts of Klipper (particuarly displays), so we
@@ -27,7 +22,7 @@ def byteify(data, ignore_dicts=False):
for k, v in data.items()}
return data
-class WebRequestError(homing.CommandError):
+class WebRequestError(gcode.CommandError):
def __init__(self, message,):
Exception.__init__(self, message)