From 9227bb5fd058b5c85cfadaa1055c32dfd9b65346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sun, 30 Jun 2013 19:15:16 +0200 Subject: [PATCH] Removed peakZ again, doesn't work this way Slicers might raise the print head first for a "nose dive" onto the print platform, leading to a high peakZ already dialed in, with no way to get it down again. This way events won't be fired until the print reaches the height of the initial starting point. As a z-change is a z-change if z changes, we'll just fire the event now (if oldZ != newZ). Event consumers will have to think of a way to filter out the noise. --- octoprint/printer.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/octoprint/printer.py b/octoprint/printer.py index 6f18cad..5cee964 100644 --- a/octoprint/printer.py +++ b/octoprint/printer.py @@ -59,7 +59,6 @@ class Printer(): self._currentZ = None - self._peakZ = -1 self._progress = None self._printTime = None self._printTimeLeft = None @@ -184,7 +183,6 @@ class Printer(): return self._setCurrentZ(None) - self._peakZ = -1 self._comm.startPrint() def togglePausePrint(self): @@ -385,12 +383,11 @@ class Printer(): Callback method for the comm object, called upon change of the z-layer. """ oldZ = self._currentZ - # only do this if we hit a new Z peak level. Some slicers do a Z-lift when retracting / moving without printing - # and some do anti-backlash up-then-down movement when advancing layers - if newZ > self._peakZ: - self._peakZ = newZ + if newZ != oldZ: + # we have to react to all z-changes, even those that might "go backward" due to a slicer's retraction or + # anti-backlash-routines. Event subscribes should individually take care to filter out "wrong" z-changes eventManager().fire("ZChange", newZ) - + self._setCurrentZ(newZ) def mcSdStateChange(self, sdReady):