Set invert_probe only once conditionally for G38.x commands
[clinton/Smoothieware.git] / src / modules / tools / zprobe / ZProbe.cpp
index e16e9b8..23c6b75 100644 (file)
@@ -255,7 +255,8 @@ void ZProbe::on_gcode_received(void *argument)
     Gcode *gcode = static_cast<Gcode *>(argument);
 
     if( gcode->has_g && gcode->g >= 29 && gcode->g <= 32) {
-
+        
+        invert_probe = false;
         // make sure the probe is defined and not already triggered before moving motors
         if(!this->pin.connected()) {
             gcode->stream->printf("ZProbe pin not configured.\n");
@@ -365,13 +366,12 @@ void ZProbe::on_gcode_received(void *argument)
         if(gcode->subcode == 4 || gcode->subcode == 5) {
             invert_probe = true;
         } else {
-            invert_probe = false;   // not sure this is needed since it is always reset to 0 below
+            invert_probe = false;
         }
+
         probe_XYZ(gcode, x, y, z);
 
-        if(gcode->subcode == 4 || gcode->subcode == 5) {
-            invert_probe = false;
-        }
+        invert_probe = false;
 
         return;