Alan Simms / threeAxis
Revision:
3:09abcf461dc2
Parent:
2:5206484275e3
diff -r 5206484275e3 -r 09abcf461dc2 threeAxis.cpp
--- a/threeAxis.cpp	Wed Dec 15 02:10:48 2021 +0000
+++ b/threeAxis.cpp	Thu Dec 16 10:51:37 2021 +0000
@@ -42,7 +42,7 @@
 
 void threeAxis::runBuffer(){
     int i = 0;
-    while(i <= bufferIndex){
+    while(i < bufferIndex){
         goTo(buffer[i][0], buffer[i][1], buffer[i][2]);
         i = i+1;
     }
@@ -160,6 +160,10 @@
     limitsEnabled = val;
 }
 
+bool threeAxis::getLimitsEn(){
+    return limitsEnabled;
+}
+
 /*void threeAxis::goTo(float xVal, float yVal, float zVal){
     int xSteps = (int)xVal*_stepRatio;
     int ySteps = (int)yVal*_stepRatio;
@@ -181,19 +185,31 @@
     toZ = zSteps;
     
     
+    if(limitsEnabled){
+        if (toX > (int)(_xMax / _stepRatio)){
+            toX = (int)(_xMax / _stepRatio);
+        }
     
-    if (toX > (int)(_xMax / _stepRatio)){
-        toX = (int)(_xMax / _stepRatio);
-    }
+        if (toY > (int)(_yMax / _stepRatio)){
+            toY = (int)(_yMax / _stepRatio);
+        }
     
-    if (toY > (int)(_yMax / _stepRatio)){
-        toY = (int)(_yMax / _stepRatio);
-    }
-    
-    if (toZ > (int)(_zMax / _stepRatio)){
-        toZ = (int)(_zMax / _stepRatio);
-    }
-    
+        if (toZ > (int)(_zMax / _stepRatio)){
+            toZ = (int)(_zMax / _stepRatio);
+        }
+        
+        if (toX<0){
+            toX = 0;
+        }
+        
+        if (toY<0){
+            toY = 0;
+        }
+        
+        if (toZ<0){
+            toZ = 0;
+        }
+    }    
     //uLCD.printf("\nTo: %d, %d, %d", toX, toY, toZ);
     //uLCD.printf("\nCur: %d, %d, %d", currX, currY, currZ);
     int xStepVal = 1;