Browse Source

Optimize calculation of block->millimeters for DELTA

Scott Lahteine 8 years ago
parent
commit
b921f6b69d
1 changed files with 16 additions and 4 deletions
  1. 16
    4
      Marlin/planner.cpp

+ 16
- 4
Marlin/planner.cpp View File

@@ -803,9 +803,15 @@ void Planner::check_axes_activity() {
803 803
     #endif
804 804
   #else
805 805
     float delta_mm[4];
806
-    delta_mm[X_AXIS] = dx / axis_steps_per_mm[X_AXIS];
807
-    delta_mm[Y_AXIS] = dy / axis_steps_per_mm[Y_AXIS];
808
-    delta_mm[Z_AXIS] = dz / axis_steps_per_mm[Z_AXIS];
806
+    #if ENABLED(DELTA)
807
+      // On delta all axes (should!) have the same steps-per-mm
808
+      // so calculate distance in steps first, then do one division
809
+      // at the end to get millimeters
810
+    #else
811
+      delta_mm[X_AXIS] = dx / axis_steps_per_mm[X_AXIS];
812
+      delta_mm[Y_AXIS] = dy / axis_steps_per_mm[Y_AXIS];
813
+      delta_mm[Z_AXIS] = dz / axis_steps_per_mm[Z_AXIS];
814
+    #endif
809 815
   #endif
810 816
   delta_mm[E_AXIS] = (de / axis_steps_per_mm[E_AXIS]) * volumetric_multiplier[extruder] * extruder_multiplier[extruder] / 100.0;
811 817
 
@@ -820,10 +826,16 @@ void Planner::check_axes_activity() {
820 826
         sq(delta_mm[X_HEAD]) + sq(delta_mm[Y_AXIS]) + sq(delta_mm[Z_HEAD])
821 827
       #elif ENABLED(COREYZ)
822 828
         sq(delta_mm[X_AXIS]) + sq(delta_mm[Y_HEAD]) + sq(delta_mm[Z_HEAD])
829
+      #elif ENABLED(DELTA)
830
+        sq(dx) + sq(dy) + sq(dz)
823 831
       #else
824 832
         sq(delta_mm[X_AXIS]) + sq(delta_mm[Y_AXIS]) + sq(delta_mm[Z_AXIS])
825 833
       #endif
826
-    );
834
+    )
835
+      #if ENABLED(DELTA)
836
+        / axis_steps_per_mm[X_AXIS]
837
+      #endif
838
+    ;
827 839
   }
828 840
   float inverse_millimeters = 1.0 / block->millimeters;  // Inverse millimeters to remove multiple divides
829 841
 

Loading…
Cancel
Save