소스 검색

change movement to non-blocking

Tuan Nguyen 1 년 전
부모
커밋
0fafabb334
1개의 변경된 파일과 7개의 추가작업 그리고 2개의 파일을 삭제
  1. 7 2
      arduino_code_TMC2209/arduino_code_TMC2209.ino

+ 7 - 2
arduino_code_TMC2209/arduino_code_TMC2209.ino

@@ -349,8 +349,13 @@ void movePolar(float theta, float rho)
 
     // Move both motors synchronously
     multiStepper.moveTo(targetPositions);
-    multiStepper.runSpeedToPosition(); // Blocking call
-
+    isRunning = true;
+    
+    while (rotStepper.distanceToGo() != 0 || inOutStepper.distanceToGo() != 0)
+    {
+        multiStepper.run(); // Non-Blocking call
+    }
+    isRunning = false;
     // Update the current coordinates
     currentTheta = theta;
     currentRho = rho;